Use long names for k8s object constants
parent
ae35752083
commit
3384e0b25d
|
@ -84,7 +84,7 @@ func checkPodTemplates(items *corev1.PodTemplateList, alert *alert) {
|
||||||
func checkPVCs(items *corev1.PersistentVolumeClaimList, alert *alert) {
|
func checkPVCs(items *corev1.PersistentVolumeClaimList, alert *alert) {
|
||||||
for _, item := range items.Items {
|
for _, item := range items.Items {
|
||||||
if corev1.NamespaceDefault == item.GetNamespace() {
|
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) {
|
func checkSA(items *corev1.ServiceAccountList, alert *alert) {
|
||||||
for _, item := range items.Items {
|
for _, item := range items.Items {
|
||||||
if corev1.NamespaceDefault == item.GetNamespace() && item.GetName() != "default" {
|
if corev1.NamespaceDefault == item.GetNamespace() && item.GetName() != "default" {
|
||||||
alert.warn(checks.SA, item.ObjectMeta)
|
alert.warn(checks.ServiceAccount, item.ObjectMeta)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ func errors() []checks.Diagnostic {
|
||||||
{
|
{
|
||||||
Severity: checks.Warning,
|
Severity: checks.Warning,
|
||||||
Message: "Avoid using the default namespace",
|
Message: "Avoid using the default namespace",
|
||||||
Kind: checks.PVC,
|
Kind: checks.PersistentVolumeClaim,
|
||||||
Object: &pvc.ObjectMeta,
|
Object: &pvc.ObjectMeta,
|
||||||
Owners: pvc.ObjectMeta.GetOwnerReferences(),
|
Owners: pvc.ObjectMeta.GetOwnerReferences(),
|
||||||
},
|
},
|
||||||
|
@ -128,7 +128,7 @@ func errors() []checks.Diagnostic {
|
||||||
{
|
{
|
||||||
Severity: checks.Warning,
|
Severity: checks.Warning,
|
||||||
Message: "Avoid using the default namespace",
|
Message: "Avoid using the default namespace",
|
||||||
Kind: checks.SA,
|
Kind: checks.ServiceAccount,
|
||||||
Object: &sa.ObjectMeta,
|
Object: &sa.ObjectMeta,
|
||||||
Owners: sa.ObjectMeta.GetOwnerReferences(),
|
Owners: sa.ObjectMeta.GetOwnerReferences(),
|
||||||
},
|
},
|
||||||
|
|
|
@ -39,7 +39,7 @@ func (pv *unusedPVCheck) Run(objects *kube.Objects) ([]checks.Diagnostic, error)
|
||||||
d := checks.Diagnostic{
|
d := checks.Diagnostic{
|
||||||
Severity: checks.Warning,
|
Severity: checks.Warning,
|
||||||
Message: fmt.Sprintf("Unused Persistent Volume '%s'.", pv.GetName()),
|
Message: fmt.Sprintf("Unused Persistent Volume '%s'.", pv.GetName()),
|
||||||
Kind: checks.PV,
|
Kind: checks.PersistentVolume,
|
||||||
Object: &pv.ObjectMeta,
|
Object: &pv.ObjectMeta,
|
||||||
Owners: pv.ObjectMeta.GetOwnerReferences(),
|
Owners: pv.ObjectMeta.GetOwnerReferences(),
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ func TestUnusedPVWarning(t *testing.T) {
|
||||||
{
|
{
|
||||||
Severity: checks.Warning,
|
Severity: checks.Warning,
|
||||||
Message: "Unused Persistent Volume 'pv_foo'.",
|
Message: "Unused Persistent Volume 'pv_foo'.",
|
||||||
Kind: checks.PV,
|
Kind: checks.PersistentVolume,
|
||||||
Object: &metav1.ObjectMeta{Name: "pv_foo"},
|
Object: &metav1.ObjectMeta{Name: "pv_foo"},
|
||||||
Owners: GetOwners(),
|
Owners: GetOwners(),
|
||||||
},
|
},
|
||||||
|
|
|
@ -24,15 +24,15 @@ type Severity string
|
||||||
type Kind string
|
type Kind string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Error Severity = "error"
|
Error Severity = "error"
|
||||||
Warning Severity = "warning"
|
Warning Severity = "warning"
|
||||||
Suggestion Severity = "suggestion"
|
Suggestion Severity = "suggestion"
|
||||||
Pod Kind = "pod"
|
Pod Kind = "pod"
|
||||||
PodTemplate Kind = "pod template"
|
PodTemplate Kind = "pod template"
|
||||||
PVC Kind = "persistent volume claim"
|
PersistentVolumeClaim Kind = "persistent volume claim"
|
||||||
ConfigMap Kind = "config map"
|
ConfigMap Kind = "config map"
|
||||||
Service Kind = "service"
|
Service Kind = "service"
|
||||||
Secret Kind = "secret"
|
Secret Kind = "secret"
|
||||||
SA Kind = "service account"
|
ServiceAccount Kind = "service account"
|
||||||
PV Kind = "persistent volume"
|
PersistentVolume Kind = "persistent volume"
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue