Documentation ¶
Overview ¶
Package wiringplugin provides the wiring-related types surrounding "WiringPlugin"
Index ¶
- Constants
- func CopyShape(source, target Shape) error
- type BundleResource
- type ClusterConfig
- type DependantResource
- type ResourceContract
- type Shape
- type ShapeMeta
- type ShapeName
- type StateContext
- type StatusContext
- type StatusResult
- type StatusResultFailure
- type StatusResultSuccess
- type StatusResultType
- type UnstructuredShape
- type WiredDependency
- type WiringContext
- type WiringPlugin
- type WiringResult
- type WiringResultFailure
- type WiringResultSuccess
- type WiringResultType
Constants ¶
const ( WiringResultSuccessType WiringResultType = "success" WiringResultFailureType WiringResultType = "failure" StatusResultSuccessType StatusResultType = "success" StatusResultFailureType StatusResultType = "failure" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BundleResource ¶
type BundleResource struct { // Resource is the Smith resource that has been produced as the result of processing an Orchestration StateResource. Resource smith_v1.Resource `json:"resource"` // Status is the status of that object as reported by Smith. Status smith_v1.ResourceStatusData `json:"status"` }
type ClusterConfig ¶
type DependantResource ¶
type DependantResource struct { Name voyager.ResourceName Type voyager.ResourceType // Attributes are attributes attached to the edge between resources. Attributes map[string]interface{} Resource orch_v1.StateResource }
DependantResource represents a resource that depends on the resource that is currently being processed.
type ResourceContract ¶
type ResourceContract struct {
Shapes []Shape `json:"shapes,omitempty"`
}
ResourceContract contains information about a resource for consumption by other autowiring functions. It is the API of a resource that can be depended upon and hence should not change unexpectedly without a proper migration path to a new version.
type Shape ¶
type Shape interface { // Name returns the name of the shape. Name() ShapeName // DeepCopyShape returns a deep copy of the shape. DeepCopyShape() Shape }
Shape represents an autowiring shape. Shapes are bits of information that an autowiring function exposes to provide information to other functions that depend on that resource. This is pretty much the same as Bazel providers. See https://docs.bazel.build/versions/master/skylark/rules.html#providers
Shapes in JSON look like this:
{ "name": "voyager.atl-paas.net/MyShape", "data": { "field1": 42, "field2": { "a": 7, "b": "x" } } }
type ShapeMeta ¶
type ShapeMeta struct { // ShapeName is the name of the shape. ShapeName ShapeName `json:"name"` }
ShapeMeta is a reusable container for bits of information common to all shapes.
type ShapeName ¶
type ShapeName string
ShapeName is a globally unique identifier for the type of a shape.
type StateContext ¶
type StateContext struct { // Location is constructed from a combination of ClusterLocation and the label // from the EntanglerContext. Location voyager.Location ServiceName voyager.ServiceName // ServiceProperties is extra metadata we pulled from the EntanglerContext // which comes from a ConfigMap tied to the State. ServiceProperties orch_meta.ServiceProperties // Tags is the final computed tags that include business_unit and service_name // and etc. Tags map[voyager.Tag]string // ClusterConfig is the cluster config. ClusterConfig ClusterConfig }
StateContext is used as input for the plugins. Everything in the StateContext is constructed from a combination of the Entangler struct, the State resource, and the EntanglerContext. This has a few legacy concepts tied to Atlassian which we could probably move to being read from user-provided autowiring functions.
type StatusContext ¶
type StatusContext struct { // BundleResources is a list of resources and their statuses in a Bundle. // Only resources for a particular StateResource are in the list. BundleResources []BundleResource `json:"bundleResources,omitempty"` // PluginStatuses is a list of statuses for Smith plugins used in a Bundle. PluginStatuses []smith_v1.PluginStatus `json:"pluginStatuses,omitempty"` }
type StatusResult ¶
type StatusResult interface {
StatusType() StatusResultType
}
type StatusResultFailure ¶
func (*StatusResultFailure) StatusType ¶
func (s *StatusResultFailure) StatusType() StatusResultType
type StatusResultSuccess ¶
type StatusResultSuccess struct {
ResourceStatusData orch_v1.ResourceStatusData `json:"resourceStatusData"`
}
func (*StatusResultSuccess) StatusType ¶
func (s *StatusResultSuccess) StatusType() StatusResultType
type StatusResultType ¶
type StatusResultType string
type UnstructuredShape ¶
type UnstructuredShape struct { ShapeMeta `json:",inline"` // Data is the data attached to the shape. // Only contains types produced by json.Unmarshal() and also int64: // bool, int64, float64, string, []interface{}, map[string]interface{}, json.Number and nil Data map[string]interface{} `json:"data,omitempty"` }
UnstructuredShape allows to unmarshal any shape from JSON/YAML into a generic representation. +k8s:deepcopy-gen=true +k8s:deepcopy-gen:interfaces=github.com/atlassian/voyager/pkg/orchestration/wiring/wiringplugin.Shape
func (*UnstructuredShape) DeepCopy ¶
func (in *UnstructuredShape) DeepCopy() *UnstructuredShape
DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UnstructuredShape.
func (*UnstructuredShape) DeepCopyInto ¶
func (u *UnstructuredShape) DeepCopyInto(out *UnstructuredShape)
DeepCopyInto handle the interface{} deepcopy (which k8s can't autogen, since it doesn't know it's JSON).
func (*UnstructuredShape) DeepCopyShape ¶
func (in *UnstructuredShape) DeepCopyShape() Shape
DeepCopyShape is an autogenerated deepcopy function, copying the receiver, creating a new Shape.
type WiredDependency ¶
type WiredDependency struct { Name voyager.ResourceName Contract ResourceContract // Attributes are attributes attached to the edge between resources. Attributes map[string]interface{} }
WiredDependency represents a resource that has been processed by a corresponding autowiring function.
type WiringContext ¶
type WiringContext struct { StateMeta meta_v1.ObjectMeta StateContext StateContext Dependencies []WiredDependency Dependants []DependantResource }
WiringContext contains context information that is passed to an autowiring function to perform autowiring for a resource.
func (*WiringContext) FindTheOnlyDependency ¶
func (c *WiringContext) FindTheOnlyDependency() (*WiredDependency, bool, error)
FindTheOnlyDependency will return a single dependency if found, returning and error if more than one is found
func (*WiringContext) TheOnlyDependency ¶
func (c *WiringContext) TheOnlyDependency() (*WiredDependency, error)
TheOnlyDependency will return a single dependency, returning an error if there is more or less than one
type WiringPlugin ¶
type WiringPlugin interface { // WireUp wires up the resource. // Error may be retriable if its an RPC error (like network error). Most errors are not retriable because // this method should be pure/deterministic so if it fails, it fails. WireUp(resource *orch_v1.StateResource, context *WiringContext) (result WiringResult) Status(resource *orch_v1.StateResource, context *StatusContext) (result StatusResult) }
WiringPlugin represents an autowiring plugin. Autowiring plugin is an in-code representation of an autowiring function.
type WiringResult ¶
type WiringResult interface {
StatusType() WiringResultType
}
type WiringResultFailure ¶
func (*WiringResultFailure) StatusType ¶
func (w *WiringResultFailure) StatusType() WiringResultType
type WiringResultSuccess ¶
type WiringResultSuccess struct { Contract ResourceContract Resources []smith_v1.Resource }
func (*WiringResultSuccess) StatusType ¶
func (w *WiringResultSuccess) StatusType() WiringResultType
type WiringResultType ¶
type WiringResultType string