data

package
v0.1.940 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: Apache-2.0, MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ResourceDetails

type ResourceDetails struct {
	// Id is the octopus ID of the exported resource
	Id string
	// ResourceType is the type of Octopus resource (almost always related to the path that the resource is loaded from)
	ResourceType string
	// Lookup is the ID of the resource created or looked up by Terraform
	Lookup string
	// Dependency provides a way for one resource to depend on this resource. Usually the same of the Lookup, but can be
	// a reference to a group of resources in stateless mode.
	Dependency string
	// FileName is the file contains the exported resource
	FileName string
	// ToHCL is a function that generates the HCL from the Octopus resource
	ToHcl ToHcl
	// A collection of any parameters that relate to the resource. These are used when building up a step template.
	Parameters []ResourceParameter
}

ResourceDetails is used to capture the dependencies required by the root resources that was exported. The process works like this: 1. The root resources is captured in a ResourceDetails from the Octopus API. 2. Any dependencies of the root object are captured in their own ResourceDetails objects. 3. Repeat step 2 for dependencies of dependencies. 4. Once all dependencies are captured, run ToHcl feeding in the collection of ResourceDetails built in steps 1 - 3. 5. ToHcl converts the object to HCL, and uses the Lookup field in the appropriate ResourceDetails to reference a dependency.

type ResourceDetailsCollection

type ResourceDetailsCollection struct {
	Resources []ResourceDetails
}

func (*ResourceDetailsCollection) AddResource

func (c *ResourceDetailsCollection) AddResource(resource ...ResourceDetails)

AddResource adds a resource to the collection

func (*ResourceDetailsCollection) GetAllResource

func (c *ResourceDetailsCollection) GetAllResource(resourceType string) []ResourceDetails

GetAllResource returns a slice of resources in the collection of type resourceType

func (*ResourceDetailsCollection) GetResource

func (c *ResourceDetailsCollection) GetResource(resourceType string, id string) string

GetResource returns the terraform references for a given resource type and id. If the resource is not found, an empty string is returned. There is no valid reason to return an empty string, but we treat a mostly valid output as a "graceful fallback" rather than failing hard, as the resulting text can still be edited by hand.

func (*ResourceDetailsCollection) GetResourceDependency

func (c *ResourceDetailsCollection) GetResourceDependency(resourceType string, id string) string

GetResourceDependency returns the terraform references for a given resource type and id. The returned string is used only for the depends_on field, as it may reference to a collection of resources rather than a single ID.

func (*ResourceDetailsCollection) GetResourcePointer

func (c *ResourceDetailsCollection) GetResourcePointer(resourceType string, id *string) *string

GetResourcePointer returns the Terraform reference for a given resource type and id as a string pointer.

func (*ResourceDetailsCollection) GetResources

func (c *ResourceDetailsCollection) GetResources(resourceType string, ids ...string) []string

GetResources returns the Terraform references for resources of the given type and with the supplied ids.

func (*ResourceDetailsCollection) HasResource

func (c *ResourceDetailsCollection) HasResource(id string, resourceType string) bool

HasResource returns true if the resource with the id and resourceType exist in the collection, and false otherwise

type ResourceParameter added in v0.1.900

type ResourceParameter struct {
	VariableName  string
	Description   string
	Label         string
	ResourceName  string
	ParameterType string
	Sensitive     bool
}

type ToHcl

type ToHcl func() (string, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL