Skip to content

Commit

Permalink
addressing comments from Bart
Browse files Browse the repository at this point in the history
  • Loading branch information
edcdavid committed Sep 30, 2024
1 parent 42a1e84 commit 4ee1a9a
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 56 deletions.
6 changes: 3 additions & 3 deletions api/v1alpha1/clustertemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ type ClusterTemplateSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// HumanReadableName defines a Human readable name of the Template.
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="HumanReadableName",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
HumanReadableName string `json:"name"`
// Name defines a Human readable name of the Template.
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Name",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
Name string `json:"name"`
// Description defines a Human readable description of the Template.
//+operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Description",xDescriptors={"urn:alm:descriptor:com.tectonic.ui:text"}
Description string `json:"description,omitempty"`
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions bundle/manifests/oran-o2ims.clusterserviceversion.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ spec:
metadata associated with the template.>
type: object
name:
description: HumanReadableName defines a Human readable name of the
Template.
description: Name defines a Human readable name of the Template.
type: string
templateID:
description: TemplateID defines a Identifier for the O-Cloud Template.
Expand Down
4 changes: 2 additions & 2 deletions config/manifests/bases/oran-o2ims.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ spec:
path: metadata
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
- description: HumanReadableName defines a Human readable name of the Template.
displayName: HumanReadableName
- description: Name defines a Human readable name of the Template.
displayName: Name
path: name
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:text
Expand Down
20 changes: 10 additions & 10 deletions internal/controllers/clusterrequest_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,8 @@ var _ = Describe("ClusterRequestReconcile", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
Name: ctHumaneName,
Version: ctVersion,
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand Down Expand Up @@ -1482,8 +1482,8 @@ var _ = Describe("getCrClusterTemplateRef", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: "other-cluster-template-name",
Version: "v1",
Name: "other-cluster-template-name",
Version: "v1",
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand Down Expand Up @@ -1512,8 +1512,8 @@ var _ = Describe("getCrClusterTemplateRef", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
Name: ctHumaneName,
Version: ctVersion,
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand Down Expand Up @@ -1858,8 +1858,8 @@ var _ = Describe("renderHardwareTemplate", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
Name: ctHumaneName,
Version: ctVersion,
Templates: oranv1alpha1.Templates{
HwTemplate: hwTemplateCm,
},
Expand Down Expand Up @@ -2386,8 +2386,8 @@ var _ = Describe("policyManagement", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
Name: ctHumaneName,
Version: ctVersion,
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand Down
9 changes: 4 additions & 5 deletions internal/controllers/clustertemplate_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ func (t *clusterTemplateReconcilerTask) validateClusterTemplateCR(ctx context.Co
var validationErrs []string

// Validate the ClusterInstance name
err := validateName(t.client, t.object.Spec.HumanReadableName, t.object.Spec.Version, t.object.Name, t.object.Namespace)
err := validateName(t.client, t.object.Spec.Name, t.object.Spec.Version, t.object.Name, t.object.Namespace)
if err != nil {
validationErrs = append(validationErrs, err.Error())
}

// Validate the ClusterInstance name
// Validate the Template ID
err = validateTemplateID(ctx, t.client, t.object)
if err != nil {
validationErrs = append(validationErrs, err.Error())
Expand Down Expand Up @@ -275,7 +275,7 @@ func validateName(c client.Client, name, version, metadataName, namespace string
if aClusterTemplate.Name == metadataName {
sameMetadataName[aClusterTemplate.Namespace] = true
}
if aClusterTemplate.Spec.HumanReadableName == name &&
if aClusterTemplate.Spec.Name == name &&
aClusterTemplate.Spec.Version == version {
sameNameVersion[aClusterTemplate.Namespace] = true
}
Expand All @@ -291,8 +291,7 @@ func validateName(c client.Client, name, version, metadataName, namespace string
return nil
}

// validateName return true if the ClusterTemplate name is the
// format: <name>.<version>, false otherwise
// validateTemplateID return true if the templateID is a valid uuid, false otherwise
func validateTemplateID(ctx context.Context, c client.Client, object *oranv1alpha1.ClusterTemplate) error {
if object.Spec.TemplateID != "" {
_, err := uuid.Parse(object.Spec.TemplateID)
Expand Down
60 changes: 30 additions & 30 deletions internal/controllers/clustertemplate_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ var _ = Describe("ClusterTemplateReconciler", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
Name: ctHumaneName,
Version: ctVersion,
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand Down Expand Up @@ -176,9 +176,9 @@ var _ = Describe("enqueueClusterTemplatesForConfigmap", func() {
Namespace: "cluster-template-a",
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: "cluster-template-a",
Version: "v1",
Templates: oranv1alpha1.Templates{},
Name: "cluster-template-a",
Version: "v1",
Templates: oranv1alpha1.Templates{},
},
},
{
Expand All @@ -187,9 +187,9 @@ var _ = Describe("enqueueClusterTemplatesForConfigmap", func() {
Namespace: "cluster-template-a",
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: "cluster-template-a",
Version: "v2",
Templates: oranv1alpha1.Templates{},
Name: "cluster-template-a",
Version: "v2",
Templates: oranv1alpha1.Templates{},
},
},
{
Expand All @@ -198,9 +198,9 @@ var _ = Describe("enqueueClusterTemplatesForConfigmap", func() {
Namespace: "cluster-template-b",
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: "cluster-template-b",
Version: "v1",
Templates: oranv1alpha1.Templates{},
Name: "cluster-template-b",
Version: "v1",
Templates: oranv1alpha1.Templates{},
},
},
}
Expand Down Expand Up @@ -282,8 +282,8 @@ var _ = Describe("validateClusterTemplateCR", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
Name: ctHumaneName,
Version: ctVersion,
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand Down Expand Up @@ -533,8 +533,8 @@ var _ = Describe("Validate Cluster Instance Name", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
Name: ctHumaneName,
Version: ctVersion,
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand All @@ -556,8 +556,8 @@ var _ = Describe("Validate Cluster Instance Name", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
Name: ctHumaneName,
Version: ctVersion,
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand All @@ -571,8 +571,8 @@ var _ = Describe("Validate Cluster Instance Name", func() {
Namespace: "namespace1",
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
Name: ctHumaneName,
Version: ctVersion,
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand Down Expand Up @@ -602,8 +602,8 @@ var _ = Describe("Validate Cluster Instance Name", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
Name: ctHumaneName,
Version: ctVersion,
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand Down Expand Up @@ -645,9 +645,9 @@ var _ = Describe("Validate Cluster Instance TemplateID", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
TemplateID: "",
Name: ctHumaneName,
Version: ctVersion,
TemplateID: "",
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand All @@ -671,9 +671,9 @@ var _ = Describe("Validate Cluster Instance TemplateID", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
TemplateID: "kjwchbjkdbckj",
Name: ctHumaneName,
Version: ctVersion,
TemplateID: "kjwchbjkdbckj",
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand All @@ -693,9 +693,9 @@ var _ = Describe("Validate Cluster Instance TemplateID", func() {
Namespace: ctNamespace,
},
Spec: oranv1alpha1.ClusterTemplateSpec{
HumanReadableName: ctHumaneName,
Version: ctVersion,
TemplateID: "71ba1920-77f8-4842-a474-010b1af1d40b",
Name: ctHumaneName,
Version: ctVersion,
TemplateID: "71ba1920-77f8-4842-a474-010b1af1d40b",
Templates: oranv1alpha1.Templates{
ClusterInstanceDefaults: ciDefaultsCm,
PolicyTemplateDefaults: ptDefaultsCm,
Expand Down

0 comments on commit 4ee1a9a

Please sign in to comment.