Documentation ¶
Index ¶
- Constants
- func AddSpinnakerAnnotations(u *unstructured.Unstructured, application string) error
- func AddSpinnakerLabels(u *unstructured.Unstructured, application string) error
- func AddSpinnakerVersionAnnotations(u *unstructured.Unstructured, version SpinnakerVersion) error
- func AddSpinnakerVersionLabels(u *unstructured.Unstructured, version SpinnakerVersion) error
- func AnnotateTemplate(u *unstructured.Unstructured, key, value string) error
- func GetCurrentVersion(ul *unstructured.UnstructuredList, kind, name string) string
- func GetStatus(kind string, m map[string]interface{}) manifest.Status
- func IsVersioned(u unstructured.Unstructured) bool
- func NewRequirement(op string, key string, values []string) (*labels.Requirement, error)
- func SetDefaultNamespaceIfScopedAndNoneSet(u *unstructured.Unstructured, helper *resource.Helper)
- func SetNamespaceIfScoped(namespace string, u *unstructured.Unstructured, helper *resource.Helper)
- func SortManifests(manifests []unstructured.Unstructured) []unstructured.Unstructured
- func ToUnstructured(manifest map[string]interface{}) (unstructured.Unstructured, error)
- func VersionVolumes(u *unstructured.Unstructured, ...) error
- type Client
- type Clientset
- type Controller
- type DaemonSet
- type Deployment
- type HorizontalPodAutoscaler
- type Job
- type ManifestFilter
- type Metadata
- type Pod
- type Provider
- type ProviderPermissions
- type ReplicaSet
- type Resource
- type SpinnakerVersion
- type StatefulSet
Constants ¶
const ( AnnotationSpinnakerArtifactLocation = `artifact.spinnaker.io/location` AnnotationSpinnakerArtifactName = `artifact.spinnaker.io/name` AnnotationSpinnakerArtifactType = `artifact.spinnaker.io/type` AnnotationSpinnakerMonikerApplication = `moniker.spinnaker.io/application` AnnotationSpinnakerMonikerCluster = `moniker.spinnaker.io/cluster` AnnotationSpinnakerStrategyVersioned = `strategy.spinnaker.io/versioned` )
const ( // https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ LabelKubernetesName = `app.kubernetes.io/name` LabelKubernetesManagedBy = `app.kubernetes.io/managed-by` LabelSpinnakerMonikerSequence = `moniker.spinnaker.io/sequence` )
const ( // https://kubernetes.io/docs/concepts/overview/working-with-objects/common-labels/ AnnotationSpinnakerArtifactVersion = `artifact.spinnaker.io/version` AnnotationSpinnakerMonikerSequence = `moniker.spinnaker.io/sequence` )
const (
ControllerInstanceKey = `KubeController`
)
Variables ¶
This section is empty.
Functions ¶
func AddSpinnakerAnnotations ¶
func AddSpinnakerAnnotations(u *unstructured.Unstructured, application string) error
AddSpinnakerAnnotations adds Spinnaker-defined annotations to a given unstructured resource.
func AddSpinnakerLabels ¶
func AddSpinnakerLabels(u *unstructured.Unstructured, application string) error
AddSpinnakerLabels labels a given unstructured Kubernetes resource with Spinnaker defined labels.
func AddSpinnakerVersionAnnotations ¶
func AddSpinnakerVersionAnnotations(u *unstructured.Unstructured, version SpinnakerVersion) error
AddSpinnakerVersionAnnotations adds the following annotations: `artifact.spinnaker.io/version` `moniker.spinnaker.io/sequence` to the manifest to identify the version number of that resource.
func AddSpinnakerVersionLabels ¶
func AddSpinnakerVersionLabels(u *unstructured.Unstructured, version SpinnakerVersion) error
AddSpinnakerVersionLabels adds the `moniker.spinnaker.io/sequence` label to the manifest to identify the version number of that resource.
func AnnotateTemplate ¶
func AnnotateTemplate(u *unstructured.Unstructured, key, value string) error
AnnotateTemplate annotates the nested string map located at .spec.template.metadata.annotations.
func GetCurrentVersion ¶
func GetCurrentVersion(ul *unstructured.UnstructuredList, kind, name string) string
GetCurrentVersion returns the latest "Spinnaker version" from an unstructured list of Kubernetes resources.
func GetStatus ¶
Status definitions of kinds can be found at https://github.com/spinnaker/clouddriver/tree/master/clouddriver-kubernetes/src/main/java/com/netflix/spinnaker/clouddriver/kubernetes/op/handler
func IsVersioned ¶
func IsVersioned(u unstructured.Unstructured) bool
IsVersioned returns true is a given Kubernetes unstructured resource is "versioned". A resource is version if its annotation `strategy.spinnaker.io/versioned` is set to "true" or if it is of kind Pod, ReplicaSet, ConfigMap, or Secret.
See https://spinnaker.io/reference/providers/kubernetes-v2/#workloads for more info.
func NewRequirement ¶
func SetDefaultNamespaceIfScopedAndNoneSet ¶
func SetDefaultNamespaceIfScopedAndNoneSet(u *unstructured.Unstructured, helper *resource.Helper)
func SetNamespaceIfScoped ¶
func SetNamespaceIfScoped(namespace string, u *unstructured.Unstructured, helper *resource.Helper)
func SortManifests ¶
func SortManifests(manifests []unstructured.Unstructured) []unstructured.Unstructured
SortManifests takes in a list of manifests and sorts them by the priority of their kind. The kind's priorities are defined above in the var 'priorities'. Lower numbered priorities should be deployed first.
func ToUnstructured ¶
func ToUnstructured(manifest map[string]interface{}) (unstructured.Unstructured, error)
ToUnstructured converts a map[string]interface{} to a kubernetes unstructured.Unstructured object. An unstructured's "Object" field is technically just a map[string]interface{}, so we could do the following:
return unstructured.Unstructured{ Object: manifest }
and not have this function return an error, but we miss out on some validation that happens during `kubectl`, such as when you attempt to apply a bad manifest, like something without "kind" specified. Example:
$ k apply -f bad.yaml --validate=false error: unable to decode "bad.yaml": Object 'Kind' is missing in '{}'
If we decide to not cycle through the encoding/decoding process, these errors will be deferred to when the manifest gets applied, and will fail with some error like
error applying manifest (kind: , apiVersion: v1, name: bad-gke): no matches for kind "" in version "apps/v1"
For now, we are not deferring the error.
func VersionVolumes ¶
func VersionVolumes(u *unstructured.Unstructured, artifacts map[string]clouddriver.TaskCreatedArtifact) error
Types ¶
type Client ¶
type Client interface { Apply(*unstructured.Unstructured) (Metadata, error) ApplyWithNamespaceOverride(*unstructured.Unstructured, string) (Metadata, error) DeleteResourceByKindAndNameAndNamespace(string, string, string, metav1.DeleteOptions) error Discover() error GVRForKind(string) (schema.GroupVersionResource, error) Get(string, string, string) (*unstructured.Unstructured, error) ListByGVR(schema.GroupVersionResource, metav1.ListOptions) (*unstructured.UnstructuredList, error) ListByGVRWithContext(context.Context, schema.GroupVersionResource, metav1.ListOptions) (*unstructured.UnstructuredList, error) ListResource(string, metav1.ListOptions) (*unstructured.UnstructuredList, error) ListResourceWithContext(context.Context, string, metav1.ListOptions) (*unstructured.UnstructuredList, error) Patch(string, string, string, []byte) (Metadata, *unstructured.Unstructured, error) PatchUsingStrategy(string, string, string, []byte, types.PatchType) (Metadata, *unstructured.Unstructured, error) ListResourcesByKindAndNamespace(string, string, metav1.ListOptions) (*unstructured.UnstructuredList, error) }
type Controller ¶
type Controller interface { NewClient(*rest.Config) (Client, error) NewClientset(*rest.Config) (Clientset, error) }
Controller holds the ability to generate a new dynamic kubernetes client.
func ControllerInstance ¶
func ControllerInstance(c *gin.Context) Controller
func NewController ¶
func NewController() Controller
NewController returns an instance of Controller.
type DaemonSet ¶
type DaemonSet struct {
// contains filtered or unexported fields
}
func NewDaemonSet ¶
type Deployment ¶
type Deployment struct {
// contains filtered or unexported fields
}
func NewDeployment ¶
func NewDeployment(m map[string]interface{}) *Deployment
func (*Deployment) Object ¶
func (d *Deployment) Object() *v1.Deployment
func (*Deployment) Status ¶
func (d *Deployment) Status() manifest.Status
type HorizontalPodAutoscaler ¶
type HorizontalPodAutoscaler struct {
// contains filtered or unexported fields
}
func NewHorizontalPodAutoscaler ¶
func NewHorizontalPodAutoscaler(m map[string]interface{}) *HorizontalPodAutoscaler
func (*HorizontalPodAutoscaler) Object ¶
func (hpa *HorizontalPodAutoscaler) Object() *v1.HorizontalPodAutoscaler
func (*HorizontalPodAutoscaler) Status ¶
func (hpa *HorizontalPodAutoscaler) Status() manifest.Status
type ManifestFilter ¶
type ManifestFilter struct {
// contains filtered or unexported fields
}
func NewManifestFilter ¶
func NewManifestFilter(items []unstructured.Unstructured) *ManifestFilter
func (*ManifestFilter) FilterOnClusterAnnotation ¶
func (f *ManifestFilter) FilterOnClusterAnnotation(cluster string) []unstructured.Unstructured
func (*ManifestFilter) FilterOnLabel ¶
func (f *ManifestFilter) FilterOnLabel(label string) []unstructured.Unstructured
type Provider ¶
type Provider struct { Name string `json:"name" gorm:"primary_key"` Host string `json:"host"` CAData string `json:"caData" gorm:"size:8192"` BearerToken string `json:"bearerToken,omitempty" gorm:"size:2048"` TokenProvider string `json:"tokenProvider,omitempty" gorm:"size:32;not null;default:'google'"` Permissions ProviderPermissions `json:"permissions" gorm:"-"` }
type ProviderPermissions ¶
type ReplicaSet ¶
type ReplicaSet struct {
// contains filtered or unexported fields
}
func NewReplicaSet ¶
func NewReplicaSet(m map[string]interface{}) *ReplicaSet
func (*ReplicaSet) Object ¶
func (rs *ReplicaSet) Object() *v1.ReplicaSet
func (*ReplicaSet) Status ¶
func (rs *ReplicaSet) Status() manifest.Status
type Resource ¶
type Resource struct { AccountName string `json:"accountName"` ID string `json:"id" gorm:"primary_key"` Timestamp time.Time `json:"timestamp,omitempty" gorm:"type:timestamp;DEFAULT:current_timestamp"` TaskID string `json:"taskId"` TaskType string `json:"-"` APIGroup string `json:"apiGroup"` Name string `json:"name"` ArtifactName string `json:"_"` Namespace string `json:"namespace"` Resource string `json:"resource"` Version string `json:"version"` Kind string `json:"kind"` SpinnakerApp string `json:"spinnakerApp"` Cluster string `json:"-"` }
type SpinnakerVersion ¶
func IncrementVersion ¶
func IncrementVersion(currentVersion string) SpinnakerVersion
type StatefulSet ¶
type StatefulSet struct {
// contains filtered or unexported fields
}
func NewStatefulSet ¶
func NewStatefulSet(m map[string]interface{}) *StatefulSet
func (*StatefulSet) Object ¶
func (ss *StatefulSet) Object() *v1.StatefulSet
func (*StatefulSet) Status ¶
func (ss *StatefulSet) Status() manifest.Status
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cached
|
|
disk/diskfakes
Code generated by counterfeiter.
|
Code generated by counterfeiter. |
Code generated by counterfeiter.
|
Code generated by counterfeiter. |