mirror of
https://github.com/FairwindsOps/polaris.git
synced 2026-05-11 03:37:42 +00:00
PR updates
This commit is contained in:
committed by
Robert Brennan
parent
db0fa8f359
commit
a0d1b2ce04
@@ -21,8 +21,8 @@ const (
|
||||
TargetController TargetKind = "Controller"
|
||||
// TargetIngress points to the ingress spec
|
||||
TargetIngress TargetKind = "Ingress"
|
||||
// TargetArbitrary points to the generic spec
|
||||
TargetArbitrary TargetKind = "Arbitrary"
|
||||
// TargetOther points to the generic spec
|
||||
TargetOther TargetKind = "Other"
|
||||
)
|
||||
|
||||
// SchemaCheck is a Polaris check that runs using JSON Schema
|
||||
|
||||
@@ -40,7 +40,7 @@ type ResourceProvider struct {
|
||||
Namespaces []corev1.Namespace
|
||||
Controllers []GenericWorkload
|
||||
Ingresses []v1beta1.Ingress
|
||||
ArbitraryKinds []*unstructured.Unstructured
|
||||
ArbitraryKinds map[string]*unstructured.Unstructured
|
||||
}
|
||||
|
||||
type k8sResource struct {
|
||||
@@ -232,13 +232,12 @@ func CreateResourceProviderFromAPI(ctx context.Context, kube kubernetes.Interfac
|
||||
}
|
||||
}
|
||||
|
||||
var arbitraryObjects []*unstructured.Unstructured
|
||||
var arbitraryObjects map[string]*unstructured.Unstructured
|
||||
for _, kind := range additionalKinds {
|
||||
apiVersion := "Not sure where to get this"
|
||||
fqKind := schema.FromAPIVersionAndKind(apiVersion, string(kind))
|
||||
mapping, err := (restMapper).RESTMapping(fqKind.GroupKind(), fqKind.Version)
|
||||
groupKind := schema.ParseGroupKind(string(kind))
|
||||
mapping, err := (restMapper).RESTMapping(groupKind)
|
||||
if err != nil {
|
||||
logrus.Warnf("Error retrieving mapping of API %s and Kind %s because of error: %v", apiVersion, kind, err)
|
||||
logrus.Warnf("Error retrieving mapping of Kind %s because of error: %v", kind, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -248,7 +247,7 @@ func CreateResourceProviderFromAPI(ctx context.Context, kube kubernetes.Interfac
|
||||
return nil, err
|
||||
}
|
||||
for _, obj := range objects.Items {
|
||||
arbitraryObjects = append(arbitraryObjects, &obj)
|
||||
arbitraryObjects[string(kind)] = &obj
|
||||
}
|
||||
}
|
||||
|
||||
@@ -389,7 +388,7 @@ func addResourceFromString(contents string, resources *ResourceProvider) error {
|
||||
fmt.Println(resource.Kind)
|
||||
return err
|
||||
}
|
||||
resources.ArbitraryKinds = append(resources.ArbitraryKinds, &unst)
|
||||
resources.ArbitraryKinds[resource.Kind] = &unst
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
||||
@@ -240,7 +240,7 @@ func applyArbitrarySchemaChecks(conf *config.Configuration, unst *unstructured.U
|
||||
}
|
||||
checkIDs := getSortedKeys(conf.Checks)
|
||||
for _, checkID := range checkIDs {
|
||||
check, err := resolveCheck(conf, checkID, unst.GetKind(), config.TargetArbitrary, objMeta, "", false)
|
||||
check, err := resolveCheck(conf, checkID, unst.GetKind(), config.TargetOther, objMeta, "", false)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user