mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-05-11 11:47:12 +00:00
add object meta to controller interface
This commit is contained in:
1
go.sum
1
go.sum
@@ -458,6 +458,7 @@ honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWh
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
k8s.io/api v0.0.0-20181213150558-05914d821849 h1:WZFcFPXmLR7g5CxQNmjWv0mg8qulJLxDghbzS4pQtzY=
|
||||
k8s.io/api v0.0.0-20181213150558-05914d821849/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA=
|
||||
k8s.io/api v0.17.0 h1:H9d/lw+VkZKEVIUc8F3wgiQ+FUXTTr21M87jXLU7yqM=
|
||||
k8s.io/apimachinery v0.0.0-20181127025237-2b1284ed4c93 h1:tT6oQBi0qwLbbZSfDkdIsb23EwaLY85hoAV4SpXfdao=
|
||||
k8s.io/apimachinery v0.0.0-20181127025237-2b1284ed4c93/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0=
|
||||
k8s.io/client-go v0.0.0-20181213151034-8d9ed539ba31 h1:OH3z6khCtxnJBAc0C5CMYWLl1CoK5R5fngX7wrwdN5c=
|
||||
|
||||
@@ -59,7 +59,7 @@ func ValidateControllers(config *conf.Configuration, kubeResources *kube.Resourc
|
||||
}
|
||||
|
||||
func hasExemptionAnnotation(ctrl controller.Interface) bool {
|
||||
annot := ctrl.GetAnnotations()
|
||||
annot := ctrl.GetObjectMeta().Annotations
|
||||
val := annot[exemptionAnnotationKey]
|
||||
return strings.ToLower(val) == "true"
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/fairwindsops/polaris/pkg/config"
|
||||
kubeAPIBatchV1beta1 "k8s.io/api/batch/v1beta1"
|
||||
kubeAPICoreV1 "k8s.io/api/core/v1"
|
||||
kubeAPIMetaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// CronJobController is an implementation of controller for deployments
|
||||
@@ -27,9 +28,9 @@ func (c CronJobController) GetKind() config.SupportedController {
|
||||
return config.CronJobs
|
||||
}
|
||||
|
||||
// GetAnnotations returns the controller's annotations
|
||||
func (c CronJobController) GetAnnotations() map[string]string {
|
||||
return c.K8SResource.ObjectMeta.Annotations
|
||||
// GetObjectMeta returns the metadata
|
||||
func (c CronJobController) GetObjectMeta() kubeAPIMetaV1.ObjectMeta {
|
||||
return c.K8SResource.ObjectMeta
|
||||
}
|
||||
|
||||
// NewCronJobController builds a new controller interface for Deployments
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/fairwindsops/polaris/pkg/config"
|
||||
kubeAPIAppsV1 "k8s.io/api/apps/v1"
|
||||
kubeAPICoreV1 "k8s.io/api/core/v1"
|
||||
kubeAPIMetaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// DaemonSetController is an implementation of controller for deployments
|
||||
@@ -22,9 +23,9 @@ func (d DaemonSetController) GetPodSpec() *kubeAPICoreV1.PodSpec {
|
||||
return &d.K8SResource.Spec.Template.Spec
|
||||
}
|
||||
|
||||
// GetAnnotations returns the controller's annotations
|
||||
func (d DaemonSetController) GetAnnotations() map[string]string {
|
||||
return d.K8SResource.ObjectMeta.Annotations
|
||||
// GetObjectMeta returns the metadata
|
||||
func (d DaemonSetController) GetObjectMeta() kubeAPIMetaV1.ObjectMeta {
|
||||
return d.K8SResource.ObjectMeta
|
||||
}
|
||||
|
||||
// GetKind returns the supportedcontroller enum type
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/fairwindsops/polaris/pkg/config"
|
||||
kubeAPIAppsV1 "k8s.io/api/apps/v1"
|
||||
kubeAPICoreV1 "k8s.io/api/core/v1"
|
||||
kubeAPIMetaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// DeploymentController is an implementation of controller for deployments
|
||||
@@ -22,9 +23,9 @@ func (d DeploymentController) GetPodSpec() *kubeAPICoreV1.PodSpec {
|
||||
return &d.K8SResource.Spec.Template.Spec
|
||||
}
|
||||
|
||||
// GetAnnotations returns the controller's annotations
|
||||
func (d DeploymentController) GetAnnotations() map[string]string {
|
||||
return d.K8SResource.ObjectMeta.Annotations
|
||||
// GetObjectMeta returns the metadata
|
||||
func (d DeploymentController) GetObjectMeta() kubeAPIMetaV1.ObjectMeta {
|
||||
return d.K8SResource.ObjectMeta
|
||||
}
|
||||
|
||||
// GetKind returns the supportedcontroller enum type
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/fairwindsops/polaris/pkg/config"
|
||||
"github.com/fairwindsops/polaris/pkg/kube"
|
||||
kubeAPICoreV1 "k8s.io/api/core/v1"
|
||||
kubeAPIMetaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// Interface is an interface for k8s controllers (e.g. Deployments and StatefulSets)
|
||||
@@ -15,7 +16,7 @@ type Interface interface {
|
||||
GetPodTemplate() *kubeAPICoreV1.PodTemplateSpec
|
||||
GetPodSpec() *kubeAPICoreV1.PodSpec
|
||||
GetKind() config.SupportedController
|
||||
GetAnnotations() map[string]string
|
||||
GetObjectMeta() kubeAPIMetaV1.ObjectMeta
|
||||
}
|
||||
|
||||
// GenericController is a base implementation with some free methods for inherited structs
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/fairwindsops/polaris/pkg/config"
|
||||
kubeAPIBatchV1 "k8s.io/api/batch/v1"
|
||||
kubeAPICoreV1 "k8s.io/api/core/v1"
|
||||
kubeAPIMetaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// JobController is an implementation of controller for deployments
|
||||
@@ -22,9 +23,9 @@ func (j JobController) GetPodSpec() *kubeAPICoreV1.PodSpec {
|
||||
return &j.K8SResource.Spec.Template.Spec
|
||||
}
|
||||
|
||||
// GetAnnotations returns the controller's annotations
|
||||
func (j JobController) GetAnnotations() map[string]string {
|
||||
return j.K8SResource.ObjectMeta.Annotations
|
||||
// GetObjectMeta returns the metadata
|
||||
func (j JobController) GetObjectMeta() kubeAPIMetaV1.ObjectMeta {
|
||||
return j.K8SResource.ObjectMeta
|
||||
}
|
||||
|
||||
// GetKind returns the supportedcontroller enum type
|
||||
|
||||
@@ -3,6 +3,7 @@ package controllers
|
||||
import (
|
||||
"github.com/fairwindsops/polaris/pkg/config"
|
||||
kubeAPICoreV1 "k8s.io/api/core/v1"
|
||||
kubeAPIMetaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// NOTE: Maybe this name of ReplicationController is duplicative but it's more explicit since
|
||||
@@ -24,9 +25,9 @@ func (r ReplicationControllerController) GetPodSpec() *kubeAPICoreV1.PodSpec {
|
||||
return &r.K8SResource.Spec.Template.Spec
|
||||
}
|
||||
|
||||
// GetAnnotations returns the controller's annotations
|
||||
func (r ReplicationControllerController) GetAnnotations() map[string]string {
|
||||
return r.K8SResource.ObjectMeta.Annotations
|
||||
// GetObjectMeta returns the metadata
|
||||
func (r ReplicationControllerController) GetObjectMeta() kubeAPIMetaV1.ObjectMeta {
|
||||
return r.K8SResource.ObjectMeta
|
||||
}
|
||||
|
||||
// GetKind returns the supportedcontroller enum type
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"github.com/fairwindsops/polaris/pkg/config"
|
||||
kubeAPIAppsV1 "k8s.io/api/apps/v1"
|
||||
kubeAPICoreV1 "k8s.io/api/core/v1"
|
||||
kubeAPIMetaV1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// StatefulSetController is an implementation of controller for deployments
|
||||
@@ -22,9 +23,9 @@ func (s StatefulSetController) GetPodSpec() *kubeAPICoreV1.PodSpec {
|
||||
return &s.K8SResource.Spec.Template.Spec
|
||||
}
|
||||
|
||||
// GetAnnotations returns the controller's annotations
|
||||
func (s StatefulSetController) GetAnnotations() map[string]string {
|
||||
return s.K8SResource.ObjectMeta.Annotations
|
||||
// GetObjectMeta returns the metadata
|
||||
func (s StatefulSetController) GetObjectMeta() kubeAPIMetaV1.ObjectMeta {
|
||||
return s.K8SResource.ObjectMeta
|
||||
}
|
||||
|
||||
// GetKind returns the supportedcontroller enum type
|
||||
|
||||
Reference in New Issue
Block a user