Skip to content

Commit

Permalink
fix(crd): Solve the problem of testing error after crd version upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
00pf00 committed Jan 15, 2024
1 parent c99f606 commit 8757e40
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions pkg/utils/test/test_customresourcedefinition.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,23 @@ func (c *customResourceDefinitionBuilder) Get() *extensionv1.CustomResourceDefin
APIVersion: "apiextensions.k8s.io/v1",
},
Spec: extensionv1.CustomResourceDefinitionSpec{
Group: c.group,
Version: c.version,
Scope: "Namespaced",
Group: c.group,
Versions: []extensionv1.CustomResourceDefinitionVersion{{
Name: c.version,
Subresources: c.subresources,
}},
Scope: "Namespaced",
Names: extensionv1.CustomResourceDefinitionNames{
Plural: plural,
Singular: name,
Kind: kind,
ListKind: kind + "List",
},
Subresources: c.subresources,
},
}
}

// CrdApiVersionAndKind returns the apiVersion and kind of the given CustomResourceDefinition
func CrdApiVersionAndKind(crd *extensionv1.CustomResourceDefinition) (string, string) {
return crd.Spec.Group + "/" + crd.Spec.Version, crd.Spec.Names.Kind
return crd.Spec.Group + "/" + crd.Spec.Versions[0].Name, crd.Spec.Names.Kind
}
2 changes: 1 addition & 1 deletion pkg/utils/test/test_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func CreateCRDPod(name, namespace string, annotations map[string]string,
return Pod().WithName(name).WithNamespace(namespace).
WithAnnotations(annotations).WithLabels(map[string]string{"app": appName}).
AddOwnerReferences(v1.OwnerReference{
APIVersion: crd.Spec.Version,
APIVersion: crd.Spec.Versions[0].Name,
Kind: crd.Spec.Names.Kind,
Name: appName,
}).
Expand Down

0 comments on commit 8757e40

Please sign in to comment.