Skip to content

Commit 7a63657

Browse files
Arta AsadiArta Asadi
authored andcommitted
fix: change metaobjects
1 parent 440cdaa commit 7a63657

File tree

3 files changed

+146
-70
lines changed

3 files changed

+146
-70
lines changed

discovery/describers/kubernetes.go

Lines changed: 41 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,13 @@ func KubernetesClusterRole(ctx context.Context, client model.Client, extra strin
4949
ID: fmt.Sprintf("clusterrole/%s", clusterRole.Name),
5050
Name: clusterRole.Name,
5151
Description: model.KubernetesClusterRoleDescription{
52-
MetaObject: clusterRole.ObjectMeta,
53-
ClusterRole: clusterRole,
52+
MetaObject: model.ConvertObjectMeta(&clusterRole.ObjectMeta),
53+
ClusterRole: model.ClusterRole{
54+
TypeMeta: model.ConvertTypeMeta(clusterRole.TypeMeta),
55+
ObjectMeta: model.ConvertObjectMeta(&clusterRole.ObjectMeta),
56+
Rules: model.ConvertPolicyRules(clusterRole.Rules),
57+
AggregationRule: model.ConvertAggregationRule(clusterRole.AggregationRule),
58+
},
5459
},
5560
}
5661

@@ -124,7 +129,7 @@ func KubernetesConfigMap(ctx context.Context, client model.Client, extra string,
124129
ID: fmt.Sprintf("configmap/%s/%s", configMap.Namespace, configMap.Name),
125130
Name: fmt.Sprintf("%s/%s", configMap.Namespace, configMap.Name),
126131
Description: model.KubernetesConfigMapDescription{
127-
MetaObject: configMap.ObjectMeta,
132+
MetaObject: model.ConvertObjectMeta(&configMap.ObjectMeta),
128133
ConfigMap: configMap,
129134
},
130135
}
@@ -157,7 +162,7 @@ func KubernetesCronJob(ctx context.Context, client model.Client, extra string, s
157162
ID: fmt.Sprintf("cronjob/%s/%s", cronJob.Namespace, cronJob.Name),
158163
Name: fmt.Sprintf("%s/%s", cronJob.Namespace, cronJob.Name),
159164
Description: model.KubernetesCronJobDescription{
160-
MetaObject: cronJob.ObjectMeta,
165+
MetaObject: model.ConvertObjectMeta(&cronJob.ObjectMeta),
161166
CronJob: cronJob,
162167
},
163168
}
@@ -205,20 +210,20 @@ func KubernetesCustomResource(ctx context.Context, client model.Client, extra st
205210
ID: fmt.Sprintf("customresource/%s.%s/%s/%s", item.GetKind(), item.GetAPIVersion(), item.GetNamespace(), item.GetName()),
206211
Name: fmt.Sprintf("%s/%s/%s", customResourceDefinition.Name, item.GetNamespace(), item.GetName()),
207212
Description: model.KubernetesCustomResourceDescription{
208-
MetaObject: metav1.ObjectMeta{
213+
MetaObject: model.ObjectMeta{
209214
Name: item.GetName(),
210215
GenerateName: item.GetGenerateName(),
211216
Namespace: item.GetNamespace(),
212217
SelfLink: item.GetSelfLink(),
213218
UID: item.GetUID(),
214219
ResourceVersion: item.GetResourceVersion(),
215220
Generation: item.GetGeneration(),
216-
CreationTimestamp: item.GetCreationTimestamp(),
217-
DeletionTimestamp: item.GetDeletionTimestamp(),
221+
CreationTimestamp: model.ConvertTime(item.GetCreationTimestamp()),
222+
DeletionTimestamp: model.ConvertTimePtr(item.GetDeletionTimestamp()),
218223
DeletionGracePeriodSeconds: item.GetDeletionGracePeriodSeconds(),
219224
Labels: item.GetLabels(),
220225
Annotations: item.GetAnnotations(),
221-
OwnerReferences: item.GetOwnerReferences(),
226+
OwnerReferences: model.ConvertOwnerReferences(item.GetOwnerReferences()),
222227
Finalizers: item.GetFinalizers(),
223228
},
224229
CustomResource: item,
@@ -256,7 +261,7 @@ func KubernetesCustomResourceDefinition(ctx context.Context, client model.Client
256261
ID: fmt.Sprintf("customresourcedefinition/%s", customResourceDefinition.Name),
257262
Name: customResourceDefinition.Name,
258263
Description: model.KubernetesCustomResourceDefinitionDescription{
259-
MetaObject: customResourceDefinition.ObjectMeta,
264+
MetaObject: model.ConvertObjectMeta(&customResourceDefinition.ObjectMeta),
260265
CustomResourceDefinition: customResourceDefinition,
261266
},
262267
}
@@ -289,7 +294,7 @@ func KubernetesDaemonSet(ctx context.Context, client model.Client, extra string,
289294
ID: fmt.Sprintf("daemonset/%s/%s", daemonSet.Namespace, daemonSet.Name),
290295
Name: fmt.Sprintf("%s/%s", daemonSet.Namespace, daemonSet.Name),
291296
Description: model.KubernetesDaemonSetDescription{
292-
MetaObject: daemonSet.ObjectMeta,
297+
MetaObject: model.ConvertObjectMeta(&daemonSet.ObjectMeta),
293298
DaemonSet: daemonSet,
294299
},
295300
}
@@ -322,7 +327,7 @@ func KubernetesDeployment(ctx context.Context, client model.Client, extra string
322327
ID: fmt.Sprintf("deployment/%s/%s", deployment.Namespace, deployment.Name),
323328
Name: fmt.Sprintf("%s/%s", deployment.Namespace, deployment.Name),
324329
Description: model.KubernetesDeploymentDescription{
325-
MetaObject: deployment.ObjectMeta,
330+
MetaObject: model.ConvertObjectMeta(&deployment.ObjectMeta),
326331
Deployment: deployment,
327332
},
328333
}
@@ -355,7 +360,7 @@ func KubernetesEndpointSlice(ctx context.Context, client model.Client, extra str
355360
ID: fmt.Sprintf("endpointslice/%s/%s", endpointSlice.Namespace, endpointSlice.Name),
356361
Name: fmt.Sprintf("%s/%s", endpointSlice.Namespace, endpointSlice.Name),
357362
Description: model.KubernetesEndpointSliceDescription{
358-
MetaObject: endpointSlice.ObjectMeta,
363+
MetaObject: model.ConvertObjectMeta(&endpointSlice.ObjectMeta),
359364
EndpointSlice: endpointSlice,
360365
},
361366
}
@@ -387,7 +392,7 @@ func KubernetesEndpoint(ctx context.Context, client model.Client, extra string,
387392
ID: fmt.Sprintf("endpoint/%s/%s", endpoint.Namespace, endpoint.Name),
388393
Name: fmt.Sprintf("%s/%s", endpoint.Namespace, endpoint.Name),
389394
Description: model.KubernetesEndpointDescription{
390-
MetaObject: endpoint.ObjectMeta,
395+
MetaObject: model.ConvertObjectMeta(&endpoint.ObjectMeta),
391396
Endpoint: endpoint,
392397
},
393398
}
@@ -419,7 +424,7 @@ func KubernetesEvent(ctx context.Context, client model.Client, extra string, str
419424
ID: fmt.Sprintf("event/%s/%s", event.Namespace, event.Name),
420425
Name: fmt.Sprintf("%s/%s", event.Namespace, event.Name),
421426
Description: model.KubernetesEventDescription{
422-
MetaObject: event.ObjectMeta,
427+
MetaObject: model.ConvertObjectMeta(&event.ObjectMeta),
423428
Event: event,
424429
},
425430
}
@@ -451,7 +456,7 @@ func KubernetesHorizontalPodAutoscaler(ctx context.Context, client model.Client,
451456
ID: fmt.Sprintf("horizontalpodautoscaler/%s/%s", horizontalPodAutoscaler.Namespace, horizontalPodAutoscaler.Name),
452457
Name: fmt.Sprintf("%s/%s", horizontalPodAutoscaler.Namespace, horizontalPodAutoscaler.Name),
453458
Description: model.KubernetesHorizontalPodAutoscalerDescription{
454-
MetaObject: horizontalPodAutoscaler.ObjectMeta,
459+
MetaObject: model.ConvertObjectMeta(&horizontalPodAutoscaler.ObjectMeta),
455460
HorizontalPodAutoscaler: horizontalPodAutoscaler,
456461
},
457462
}
@@ -483,7 +488,7 @@ func KubernetesIngress(ctx context.Context, client model.Client, extra string, s
483488
ID: fmt.Sprintf("ingress/%s/%s", ingress.Namespace, ingress.Name),
484489
Name: fmt.Sprintf("%s/%s", ingress.Namespace, ingress.Name),
485490
Description: model.KubernetesIngressDescription{
486-
MetaObject: ingress.ObjectMeta,
491+
MetaObject: model.ConvertObjectMeta(&ingress.ObjectMeta),
487492
Ingress: ingress,
488493
},
489494
}
@@ -515,7 +520,7 @@ func KubernetesJob(ctx context.Context, client model.Client, extra string, strea
515520
ID: fmt.Sprintf("job/%s/%s", job.Namespace, job.Name),
516521
Name: fmt.Sprintf("%s/%s", job.Namespace, job.Name),
517522
Description: model.KubernetesJobDescription{
518-
MetaObject: job.ObjectMeta,
523+
MetaObject: model.ConvertObjectMeta(&job.ObjectMeta),
519524
Job: job,
520525
},
521526
}
@@ -547,7 +552,7 @@ func KubernetesLimitRange(ctx context.Context, client model.Client, extra string
547552
ID: fmt.Sprintf("limitrange/%s/%s", limitRange.Namespace, limitRange.Name),
548553
Name: fmt.Sprintf("%s/%s", limitRange.Namespace, limitRange.Name),
549554
Description: model.KubernetesLimitRangeDescription{
550-
MetaObject: limitRange.ObjectMeta,
555+
MetaObject: model.ConvertObjectMeta(&limitRange.ObjectMeta),
551556
LimitRange: limitRange,
552557
},
553558
}
@@ -579,7 +584,7 @@ func KubernetesNamespace(ctx context.Context, client model.Client, extra string,
579584
ID: fmt.Sprintf("namespace/%s", namespace.Name),
580585
Name: namespace.Name,
581586
Description: model.KubernetesNamespaceDescription{
582-
MetaObject: namespace.ObjectMeta,
587+
MetaObject: model.ConvertObjectMeta(&namespace.ObjectMeta),
583588
Namespace: namespace,
584589
},
585590
}
@@ -611,7 +616,7 @@ func KubernetesNetworkPolicy(ctx context.Context, client model.Client, extra str
611616
ID: fmt.Sprintf("networkpolicy/%s/%s", networkPolicy.Namespace, networkPolicy.Name),
612617
Name: fmt.Sprintf("%s/%s", networkPolicy.Namespace, networkPolicy.Name),
613618
Description: model.KubernetesNetworkPolicyDescription{
614-
MetaObject: networkPolicy.ObjectMeta,
619+
MetaObject: model.ConvertObjectMeta(&networkPolicy.ObjectMeta),
615620
NetworkPolicy: networkPolicy,
616621
},
617622
}
@@ -644,7 +649,7 @@ func KubernetesNode(ctx context.Context, client model.Client, extra string, stre
644649
ID: fmt.Sprintf("node/%s", node.Name),
645650
Name: node.Name,
646651
Description: model.KubernetesNodeDescription{
647-
MetaObject: node.ObjectMeta,
652+
MetaObject: model.ConvertObjectMeta(&node.ObjectMeta),
648653
Node: node,
649654
},
650655
}
@@ -678,7 +683,7 @@ func KubernetesPersistentVolume(ctx context.Context, client model.Client, extra
678683
ID: fmt.Sprintf("persistentvolume/%s", pv.Name),
679684
Name: pv.Name,
680685
Description: model.KubernetesPersistentVolumeDescription{
681-
MetaObject: pv.ObjectMeta,
686+
MetaObject: model.ConvertObjectMeta(&pv.ObjectMeta),
682687
PV: pv,
683688
},
684689
}
@@ -711,7 +716,7 @@ func KubernetesPersistentVolumeClaim(ctx context.Context, client model.Client, e
711716
ID: fmt.Sprintf("persistentvolumeclaim/%s/%s", pvc.Namespace, pvc.Name),
712717
Name: fmt.Sprintf("%s/%s", pvc.Namespace, pvc.Name),
713718
Description: model.KubernetesPersistentVolumeClaimDescription{
714-
MetaObject: pvc.ObjectMeta,
719+
MetaObject: model.ConvertObjectMeta(&pvc.ObjectMeta),
715720
PVC: pvc,
716721
},
717722
}
@@ -744,7 +749,7 @@ func KubernetesPod(ctx context.Context, client model.Client, extra string, strea
744749
ID: fmt.Sprintf("pod/%s/%s", pod.Namespace, pod.Name),
745750
Name: fmt.Sprintf("%s/%s", pod.Namespace, pod.Name),
746751
Description: model.KubernetesPodDescription{
747-
MetaObject: pod.ObjectMeta,
752+
MetaObject: model.ConvertObjectMeta(&pod.ObjectMeta),
748753
Pod: pod,
749754
},
750755
}
@@ -777,7 +782,7 @@ func KubernetesPodDisruptionBudget(ctx context.Context, client model.Client, ext
777782
ID: fmt.Sprintf("poddisruptionbudget/%s/%s", podDisruptionBudget.Namespace, podDisruptionBudget.Name),
778783
Name: fmt.Sprintf("%s/%s", podDisruptionBudget.Namespace, podDisruptionBudget.Name),
779784
Description: model.KubernetesPodDisruptionBudgetDescription{
780-
MetaObject: podDisruptionBudget.ObjectMeta,
785+
MetaObject: model.ConvertObjectMeta(&podDisruptionBudget.ObjectMeta),
781786
PodDisruptionBudget: podDisruptionBudget,
782787
},
783788
}
@@ -810,7 +815,7 @@ func KubernetesPodTemplate(ctx context.Context, client model.Client, extra strin
810815
ID: fmt.Sprintf("podtemplate/%s/%s", podTemplate.Namespace, podTemplate.Name),
811816
Name: fmt.Sprintf("%s/%s", podTemplate.Namespace, podTemplate.Name),
812817
Description: model.KubernetesPodTemplateDescription{
813-
MetaObject: podTemplate.ObjectMeta,
818+
MetaObject: model.ConvertObjectMeta(&podTemplate.ObjectMeta),
814819
PodTemplate: podTemplate,
815820
},
816821
}
@@ -843,7 +848,7 @@ func KubernetesReplicaSet(ctx context.Context, client model.Client, extra string
843848
ID: fmt.Sprintf("replicaset/%s/%s", replicaSet.Namespace, replicaSet.Name),
844849
Name: fmt.Sprintf("%s/%s", replicaSet.Namespace, replicaSet.Name),
845850
Description: model.KubernetesReplicaSetDescription{
846-
MetaObject: replicaSet.ObjectMeta,
851+
MetaObject: model.ConvertObjectMeta(&replicaSet.ObjectMeta),
847852
ReplicaSet: replicaSet,
848853
},
849854
}
@@ -876,7 +881,7 @@ func KubernetesReplicationController(ctx context.Context, client model.Client, e
876881
ID: fmt.Sprintf("replicationcontroller/%s/%s", replicationController.Namespace, replicationController.Name),
877882
Name: fmt.Sprintf("%s/%s", replicationController.Namespace, replicationController.Name),
878883
Description: model.KubernetesReplicationControllerDescription{
879-
MetaObject: replicationController.ObjectMeta,
884+
MetaObject: model.ConvertObjectMeta(&replicationController.ObjectMeta),
880885
ReplicationController: replicationController,
881886
},
882887
}
@@ -909,7 +914,7 @@ func KubernetesResourceQuota(ctx context.Context, client model.Client, extra str
909914
ID: fmt.Sprintf("resourcequota/%s/%s", resourceQuota.Namespace, resourceQuota.Name),
910915
Name: fmt.Sprintf("%s/%s", resourceQuota.Namespace, resourceQuota.Name),
911916
Description: model.KubernetesResourceQuotaDescription{
912-
MetaObject: resourceQuota.ObjectMeta,
917+
MetaObject: model.ConvertObjectMeta(&resourceQuota.ObjectMeta),
913918
ResourceQuota: resourceQuota,
914919
},
915920
}
@@ -942,7 +947,7 @@ func KubernetesRole(ctx context.Context, client model.Client, extra string, stre
942947
ID: fmt.Sprintf("role/%s/%s", role.Namespace, role.Name),
943948
Name: fmt.Sprintf("%s/%s", role.Namespace, role.Name),
944949
Description: model.KubernetesRoleDescription{
945-
MetaObject: role.ObjectMeta,
950+
MetaObject: model.ConvertObjectMeta(&role.ObjectMeta),
946951
Role: role,
947952
},
948953
}
@@ -975,7 +980,7 @@ func KubernetesRoleBinding(ctx context.Context, client model.Client, extra strin
975980
ID: fmt.Sprintf("rolebinding/%s/%s", roleBinding.Namespace, roleBinding.Name),
976981
Name: fmt.Sprintf("%s/%s", roleBinding.Namespace, roleBinding.Name),
977982
Description: model.KubernetesRoleBindingDescription{
978-
MetaObject: roleBinding.ObjectMeta,
983+
MetaObject: model.ConvertObjectMeta(&roleBinding.ObjectMeta),
979984
RoleBinding: roleBinding,
980985
},
981986
}
@@ -1011,7 +1016,7 @@ func KubernetesSecret(ctx context.Context, client model.Client, extra string, st
10111016
ID: fmt.Sprintf("secret/%s/%s", secret.Namespace, secret.Name),
10121017
Name: fmt.Sprintf("%s/%s", secret.Namespace, secret.Name),
10131018
Description: model.KubernetesSecretDescription{
1014-
MetaObject: secret.ObjectMeta,
1019+
MetaObject: model.ConvertObjectMeta(&secret.ObjectMeta),
10151020
Secret: secret,
10161021
},
10171022
}
@@ -1044,7 +1049,7 @@ func KubernetesService(ctx context.Context, client model.Client, extra string, s
10441049
ID: fmt.Sprintf("service/%s/%s", service.Namespace, service.Name),
10451050
Name: fmt.Sprintf("%s/%s", service.Namespace, service.Name),
10461051
Description: model.KubernetesServiceDescription{
1047-
MetaObject: service.ObjectMeta,
1052+
MetaObject: model.ConvertObjectMeta(&service.ObjectMeta),
10481053
Service: service,
10491054
},
10501055
}
@@ -1077,7 +1082,7 @@ func KubernetesServiceAccount(ctx context.Context, client model.Client, extra st
10771082
ID: fmt.Sprintf("serviceaccount/%s/%s", serviceAccount.Namespace, serviceAccount.Name),
10781083
Name: fmt.Sprintf("%s/%s", serviceAccount.Namespace, serviceAccount.Name),
10791084
Description: model.KubernetesServiceAccountDescription{
1080-
MetaObject: serviceAccount.ObjectMeta,
1085+
MetaObject: model.ConvertObjectMeta(&serviceAccount.ObjectMeta),
10811086
ServiceAccount: serviceAccount,
10821087
},
10831088
}
@@ -1110,7 +1115,7 @@ func KubernetesStatefulSet(ctx context.Context, client model.Client, extra strin
11101115
ID: fmt.Sprintf("statefulset/%s/%s", statefulSet.Namespace, statefulSet.Name),
11111116
Name: fmt.Sprintf("%s/%s", statefulSet.Namespace, statefulSet.Name),
11121117
Description: model.KubernetesStatefulSetDescription{
1113-
MetaObject: statefulSet.ObjectMeta,
1118+
MetaObject: model.ConvertObjectMeta(&statefulSet.ObjectMeta),
11141119
StatefulSet: statefulSet,
11151120
},
11161121
}
@@ -1143,7 +1148,7 @@ func KubernetesStorageClass(ctx context.Context, client model.Client, extra stri
11431148
ID: fmt.Sprintf("storageclass/%s", storageClass.Name),
11441149
Name: storageClass.Name,
11451150
Description: model.KubernetesStorageClassDescription{
1146-
MetaObject: storageClass.ObjectMeta,
1151+
MetaObject: model.ConvertObjectMeta(&storageClass.ObjectMeta),
11471152
StorageClass: storageClass,
11481153
},
11491154
}

0 commit comments

Comments
 (0)