Use long names for k8s object constants

varsha/versions
Varsha Varadarajan 2019-06-27 08:07:35 -04:00
parent ae35752083
commit 3384e0b25d
5 changed files with 17 additions and 17 deletions

View File

@ -84,7 +84,7 @@ func checkPodTemplates(items *corev1.PodTemplateList, alert *alert) {
func checkPVCs(items *corev1.PersistentVolumeClaimList, alert *alert) {
for _, item := range items.Items {
if corev1.NamespaceDefault == item.GetNamespace() {
alert.warn(checks.PVC, item.ObjectMeta)
alert.warn(checks.PersistentVolumeClaim, item.ObjectMeta)
}
}
}
@ -120,7 +120,7 @@ func checkSecrets(items *corev1.SecretList, alert *alert) {
func checkSA(items *corev1.ServiceAccountList, alert *alert) {
for _, item := range items.Items {
if corev1.NamespaceDefault == item.GetNamespace() && item.GetName() != "default" {
alert.warn(checks.SA, item.ObjectMeta)
alert.warn(checks.ServiceAccount, item.ObjectMeta)
}
}
}

View File

@ -100,7 +100,7 @@ func errors() []checks.Diagnostic {
{
Severity: checks.Warning,
Message: "Avoid using the default namespace",
Kind: checks.PVC,
Kind: checks.PersistentVolumeClaim,
Object: &pvc.ObjectMeta,
Owners: pvc.ObjectMeta.GetOwnerReferences(),
},
@ -128,7 +128,7 @@ func errors() []checks.Diagnostic {
{
Severity: checks.Warning,
Message: "Avoid using the default namespace",
Kind: checks.SA,
Kind: checks.ServiceAccount,
Object: &sa.ObjectMeta,
Owners: sa.ObjectMeta.GetOwnerReferences(),
},

View File

@ -39,7 +39,7 @@ func (pv *unusedPVCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, error)
d := checks.Diagnostic{
Severity: checks.Warning,
Message: fmt.Sprintf("Unused Persistent Volume '%s'.", pv.GetName()),
Kind: checks.PV,
Kind: checks.PersistentVolume,
Object: &pv.ObjectMeta,
Owners: pv.ObjectMeta.GetOwnerReferences(),
}

View File

@ -47,7 +47,7 @@ func TestUnusedPVWarning(t *testing.T) {
{
Severity: checks.Warning,
Message: "Unused Persistent Volume 'pv_foo'.",
Kind: checks.PV,
Kind: checks.PersistentVolume,
Object: &metav1.ObjectMeta{Name: "pv_foo"},
Owners: GetOwners(),
},

View File

@ -24,15 +24,15 @@ type Severity string
type Kind string
const (
Error Severity = "error"
Warning Severity = "warning"
Suggestion Severity = "suggestion"
Pod Kind = "pod"
PodTemplate Kind = "pod template"
PVC Kind = "persistent volume claim"
ConfigMap Kind = "config map"
Service Kind = "service"
Secret Kind = "secret"
SA Kind = "service account"
PV Kind = "persistent volume"
Error Severity = "error"
Warning Severity = "warning"
Suggestion Severity = "suggestion"
Pod Kind = "pod"
PodTemplate Kind = "pod template"
PersistentVolumeClaim Kind = "persistent volume claim"
ConfigMap Kind = "config map"
Service Kind = "service"
Secret Kind = "secret"
ServiceAccount Kind = "service account"
PersistentVolume Kind = "persistent volume"
)