Documentation ¶
Overview ¶
Package resource contains logic related to Kubernetes resource objects.
Index ¶
- Constants
- func AddAnnotation(obj *Object, key, value string) error
- func AddLabel(ctx context.Context, obj *Object, key, value string, override bool) error
- func AddNamespaceIfMissing(objs Objects, namespace string) error
- func DeploySummary(ctx context.Context, objs Objects) (string, error)
- func EncodeToYAMLString(obj *Object) (string, error)
- func HasObject(ctx context.Context, objs Objects, kind, name string) (bool, error)
- func IsReady(ctx context.Context, obj *Object) (bool, error)
- func ObjectKind(obj *Object) string
- func ObjectName(obj *Object) (string, error)
- func ObjectNamespace(obj *Object) (string, error)
- func SaveAsConfigs(ctx context.Context, objs Objects, outputDir string, ...) (string, error)
- func SetApplicationLinks(obj *Object, links []applicationsv1beta1.Link) error
- func UpdateMatchingContainerImage(ctx context.Context, objs Objects, imageName, replace string) error
- func UpdateNamespace(ctx context.Context, objs Objects, replace string) error
- type Object
- func CreateApplicationObject(name, selectorKey, selectorValue, descriptorType, descriptorVersion string, ...) (*Object, error)
- func CreateDeploymentObject(ctx context.Context, name string, selectorValue, image string) (*Object, error)
- func CreateHorizontalPodAutoscalerObject(ctx context.Context, name, deploymentName string) (*Object, error)
- func CreateNamespaceObject(ctx context.Context, name string) (*Object, error)
- func CreateServiceObject(ctx context.Context, name, selectorKey, selectorValue string, port int) (*Object, error)
- func DecodeFromYAML(ctx context.Context, yaml []byte) (*Object, error)
- type Objects
Constants ¶
const AggregatedFilename = "aggregated-resources.yaml"
AggregatedFilename is the filename for the file created by SaveAsConfigs.
Variables ¶
This section is empty.
Functions ¶
func AddAnnotation ¶
AddAnnotation updates an object to add an annotation with the key and value provided.
func AddNamespaceIfMissing ¶
AddNamespaceIfMissing updates all objects to add a namespace only if the object does not have one already.
func DeploySummary ¶
DeploySummary returns a string representation of a summary of a list of objects' deploy statuses.
func EncodeToYAMLString ¶
EncodeToYAMLString encodes an object from *Object to a string.
func HasObject ¶
HasObject returns true if there exists an object in objs that matches the provided kind and name.
func IsReady ¶
IsReady returns true if a deployed object is ready. Please check the comments of each kind's implementation for a description of what is considered to be ready for that kind of object.
func ObjectName ¶
ObjectName returns the name of an object.
func ObjectNamespace ¶
ObjectNamespace returns the namespace of an object.
func SaveAsConfigs ¶
func SaveAsConfigs(ctx context.Context, objs Objects, outputDir string, lineComments map[string]string, oss services.OSService) (string, error)
SaveAsConfigs saves resource objects as config files to a target output directory. If any lines in a resource object's string representation contain a key in lineComments, the corresponding value will be added as a comment at the end of the line. The string being returned is the path of the saved file.
func SetApplicationLinks ¶
func SetApplicationLinks(obj *Object, links []applicationsv1beta1.Link) error
SetApplicationLinks sets a list of links to an Application object's spec.descriptor.links field.
Types ¶
type Object ¶
type Object struct {
*unstructured.Unstructured
}
Object extends unstructured.Unstructured, which implements runtime.Object
func CreateApplicationObject ¶
func CreateApplicationObject(name, selectorKey, selectorValue, descriptorType, descriptorVersion string, componentObjs Objects) (*Object, error)
CreateApplicationObject creates an Application CR object with the given name and fields. appVersion may be empty, in which case the resulting Application CR will not have a value for spec.descriptor.version. To add links, to the Application, use the SetApplicationLinks function on the output object,
func CreateDeploymentObject ¶
func CreateDeploymentObject(ctx context.Context, name string, selectorValue, image string) (*Object, error)
CreateDeploymentObject creates a Deployment object with the given name and image. The created Deployment will have 3 replicas.
func CreateHorizontalPodAutoscalerObject ¶
func CreateHorizontalPodAutoscalerObject(ctx context.Context, name, deploymentName string) (*Object, error)
CreateHorizontalPodAutoscalerObject creates a Namespace object with the given name. The created HorizontalPodAutoscaler will have minReplicas set to 1, maxReplicas set to 5, and a cpu targetAverageUtilization of 80.
func CreateNamespaceObject ¶
CreateNamespaceObject creates a Namespace object with the given name.
func CreateServiceObject ¶
func CreateServiceObject(ctx context.Context, name, selectorKey, selectorValue string, port int) (*Object, error)
CreateServiceObject creates a Service object with the given name with service type LoadBalancer.
func DecodeFromYAML ¶
DecodeFromYAML decodes an object from a YAML string as bytes.
type Objects ¶
type Objects []*Object
Objects maps resource file base names to corresponding resource objects (mutable).