Skip to content

Commit

Permalink
fix(core): always set metadata.name (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
shinebayar-g authored Dec 19, 2024
1 parent a510c6a commit 4ec20ab
Show file tree
Hide file tree
Showing 81 changed files with 81 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/cli/src/generateCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ function morph() {
if (prop.getName() === 'metadata') {
interfaceProp.hasQuestionToken = true;
c.statements.push('this.metadata = args.metadata || { name };');
c.statements.push('this.metadata.name ??= name;');
prop.setHasQuestionToken(false);
if (groupVersionKindMap[className].namespaced) {
classDeclaration.setExtends('NamespacedApiObject');
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/APIServicev1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class APIServicev1 extends ApiObject {
constructor(app: K8sApp, name: string, args: APIServicev1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/AuthenticationTokenRequestv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class AuthenticationTokenRequestv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: AuthenticationTokenRequestv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/Bindingv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class Bindingv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: Bindingv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.target = args.target;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/CSIDriverv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class CSIDriverv1 extends ApiObject {
constructor(app: K8sApp, name: string, args: CSIDriverv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/CSINodev1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class CSINodev1 extends ApiObject {
constructor(app: K8sApp, name: string, args: CSINodev1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/CSIStorageCapacityv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class CSIStorageCapacityv1 extends NamespacedApiObject {
this.capacity = args.capacity;
this.maximumVolumeSize = args.maximumVolumeSize;
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.nodeTopology = args.nodeTopology;
this.storageClassName = args.storageClassName;
app.resources.push(this);
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/CertificateSigningRequestv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class CertificateSigningRequestv1 extends ApiObject {
constructor(app: K8sApp, name: string, args: CertificateSigningRequestv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/ClusterRoleBindingv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class ClusterRoleBindingv1 extends ApiObject {
constructor(app: K8sApp, name: string, args: ClusterRoleBindingv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.roleRef = args.roleRef;
this.subjects = args.subjects;
app.resources.push(this);
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/ClusterRolev1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class ClusterRolev1 extends ApiObject {
super();
this.aggregationRule = args.aggregationRule;
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.rules = args.rules;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/ClusterTrustBundlev1alpha1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class ClusterTrustBundlev1alpha1 extends ApiObject {
constructor(app: K8sApp, name: string, args: ClusterTrustBundlev1alpha1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/ConfigMapv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class ConfigMapv1 extends NamespacedApiObject {
this.data = args.data;
this.immutable = args.immutable;
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
app.resources.push(this);
}
}
1 change: 1 addition & 0 deletions packages/core/src/models/ControllerRevisionv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class ControllerRevisionv1 extends NamespacedApiObject {
super();
this.data = args.data;
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.revision = args.revision;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/CoreEventv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class CoreEventv1 extends NamespacedApiObject {
this.lastTimestamp = args.lastTimestamp;
this.message = args.message;
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.reason = args.reason;
this.related = args.related;
this.reportingComponent = args.reportingComponent;
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/CronJobv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class CronJobv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: CronJobv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/CustomResourceDefinitionv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class CustomResourceDefinitionv1 extends ApiObject {
constructor(app: K8sApp, name: string, args: CustomResourceDefinitionv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/DaemonSetv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class DaemonSetv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: DaemonSetv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/Deploymentv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class Deploymentv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: Deploymentv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/DeviceClassv1alpha3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class DeviceClassv1alpha3 extends ApiObject {
constructor(app: K8sApp, name: string, args: DeviceClassv1alpha3Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/DeviceClassv1beta1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class DeviceClassv1beta1 extends ApiObject {
constructor(app: K8sApp, name: string, args: DeviceClassv1beta1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/EndpointSlicev1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export class EndpointSlicev1 extends NamespacedApiObject {
this.addressType = args.addressType;
this.endpoints = args.endpoints;
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.ports = args.ports;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/Endpointsv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class Endpointsv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: Endpointsv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.subsets = args.subsets;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/EventsEventv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class EventsEventv1 extends NamespacedApiObject {
this.deprecatedSource = args.deprecatedSource;
this.eventTime = args.eventTime;
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.note = args.note;
this.reason = args.reason;
this.regarding = args.regarding;
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/Evictionv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class Evictionv1 extends NamespacedApiObject {
super();
this.deleteOptions = args.deleteOptions;
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
app.resources.push(this);
}
}
1 change: 1 addition & 0 deletions packages/core/src/models/FlowSchemav1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class FlowSchemav1 extends ApiObject {
constructor(app: K8sApp, name: string, args: FlowSchemav1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/HorizontalPodAutoscalerv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class HorizontalPodAutoscalerv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: HorizontalPodAutoscalerv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/HorizontalPodAutoscalerv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class HorizontalPodAutoscalerv2 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: HorizontalPodAutoscalerv2Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/IPAddressv1beta1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class IPAddressv1beta1 extends ApiObject {
constructor(app: K8sApp, name: string, args: IPAddressv1beta1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/IngressClassv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class IngressClassv1 extends ApiObject {
constructor(app: K8sApp, name: string, args: IngressClassv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/Ingressv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class Ingressv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: Ingressv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/Jobv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class Jobv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: Jobv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/LeaseCandidatev1alpha2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class LeaseCandidatev1alpha2 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: LeaseCandidatev1alpha2Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/Leasev1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class Leasev1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: Leasev1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/LimitRangev1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class LimitRangev1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: LimitRangev1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/LocalSubjectAccessReviewv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class LocalSubjectAccessReviewv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: LocalSubjectAccessReviewv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class MutatingAdmissionPolicyBindingv1alpha1 extends ApiObject {
constructor(app: K8sApp, name: string, args: MutatingAdmissionPolicyBindingv1alpha1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class MutatingAdmissionPolicyv1alpha1 extends ApiObject {
constructor(app: K8sApp, name: string, args: MutatingAdmissionPolicyv1alpha1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/MutatingWebhookConfigurationv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class MutatingWebhookConfigurationv1 extends ApiObject {
constructor(app: K8sApp, name: string, args: MutatingWebhookConfigurationv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.webhooks = args.webhooks;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/Namespacev1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class Namespacev1 extends ApiObject {
constructor(app: K8sApp, name: string, args: Namespacev1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/NetworkPolicyv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class NetworkPolicyv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: NetworkPolicyv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/Nodev1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class Nodev1 extends ApiObject {
constructor(app: K8sApp, name: string, args: Nodev1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/PersistentVolumev1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class PersistentVolumev1 extends ApiObject {
constructor(app: K8sApp, name: string, args: PersistentVolumev1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/PodDisruptionBudgetv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class PodDisruptionBudgetv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: PodDisruptionBudgetv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/PodTemplatev1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class PodTemplatev1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: PodTemplatev1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.template = args.template;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/Podv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class Podv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: Podv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/PriorityClassv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class PriorityClassv1 extends ApiObject {
this.description = args.description;
this.globalDefault = args.globalDefault;
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.preemptionPolicy = args.preemptionPolicy;
this.value = args.value;
app.resources.push(this);
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/PriorityLevelConfigurationv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class PriorityLevelConfigurationv1 extends ApiObject {
constructor(app: K8sApp, name: string, args: PriorityLevelConfigurationv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/ReplicaSetv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class ReplicaSetv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: ReplicaSetv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/ReplicationControllerv1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class ReplicationControllerv1 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: ReplicationControllerv1Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/models/ResourceClaimTemplatev1alpha3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class ResourceClaimTemplatev1alpha3 extends NamespacedApiObject {
constructor(app: K8sApp, name: string, args: ResourceClaimTemplatev1alpha3Args) {
super();
this.metadata = args.metadata || { name };
this.metadata.name ??= name;
this.spec = args.spec;
app.resources.push(this);
}
Expand Down
Loading

0 comments on commit 4ec20ab

Please sign in to comment.