Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Commit

Permalink
Merge pull request #732 from jpodivin/boolpointerswitch
Browse files Browse the repository at this point in the history
Switching deployOnAllNodeSets from *bool to bool
  • Loading branch information
openshift-merge-bot[bot] authored Mar 6, 2024
2 parents 7298157 + cf9b522 commit 203540b
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 16 deletions.
2 changes: 1 addition & 1 deletion api/v1beta1/openstackdataplaneservice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type OpenStackDataPlaneServiceSpec struct {
// DeployOnAllNodeSets - should the service be deploy across all nodesets
// This will override default target of a service play, setting it to 'all'.
// +kubebuilder:validation:Optional
DeployOnAllNodeSets *bool `json:"deployOnAllNodeSets,omitempty" yaml:"deployOnAllNodeSets,omitempty"`
DeployOnAllNodeSets bool `json:"deployOnAllNodeSets,omitempty" yaml:"deployOnAllNodeSets,omitempty"`
}

// OpenStackDataPlaneServiceStatus defines the observed state of OpenStackDataPlaneService
Expand Down
5 changes: 0 additions & 5 deletions api/v1beta1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion docs/assemblies/custom_resources.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ OpenStackDataPlaneServiceSpec defines the desired state of OpenStackDataPlaneSer
| deployOnAllNodeSets
| DeployOnAllNodeSets - should the service be deploy across all nodesets This will override default target of a service play, setting it to 'all'.
| *bool
| bool
| false
|===
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func CheckGlobalServiceExecutionConsistency(ctx context.Context, helper *helper.
return err
}

if service.Spec.DeployOnAllNodeSets != nil && *service.Spec.DeployOnAllNodeSets {
if service.Spec.DeployOnAllNodeSets {
if serviceInList(service.Name, globalServices) {
return fmt.Errorf("global service %s defined multiple times", service.Name)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/util/ansible_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func AnsibleExecution(
if ansibleEE.Spec.ExtraVars == nil {
ansibleEE.Spec.ExtraVars = make(map[string]json.RawMessage)
}
if service.Spec.DeployOnAllNodeSets != nil && *service.Spec.DeployOnAllNodeSets {
if service.Spec.DeployOnAllNodeSets {
ansibleEE.Spec.ExtraVars["edpm_override_hosts"] = json.RawMessage([]byte("\"all\""))
util.LogForObject(helper, fmt.Sprintf("for service %s, substituting existing ansible play host with 'all'.", service.Name), ansibleEE)
} else {
Expand All @@ -123,7 +123,7 @@ func AnsibleExecution(
}

for sshKeyNodeName, sshKeySecret := range sshKeySecrets {
if service.Spec.DeployOnAllNodeSets != nil && *service.Spec.DeployOnAllNodeSets {
if service.Spec.DeployOnAllNodeSets {
sshKeyName = fmt.Sprintf("ssh-key-%s", sshKeyNodeName)
sshKeyMountSubPath = fmt.Sprintf("ssh_key_%s", targetNodeset)
sshKeyMountPath = fmt.Sprintf("/runner/env/ssh_key/%s", sshKeyMountSubPath)
Expand Down Expand Up @@ -158,7 +158,7 @@ func AnsibleExecution(

// Mounting inventory and secrets
for inventoryIndex, inventorySecret := range inventorySecrets {
if service.Spec.DeployOnAllNodeSets != nil && *service.Spec.DeployOnAllNodeSets {
if service.Spec.DeployOnAllNodeSets {
inventoryName = fmt.Sprintf("inventory-%d", inventoryIndex)
inventoryMountPath = fmt.Sprintf("/runner/inventory/%s", inventoryName)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ var _ = Describe("Dataplane Deployment Test", func() {

g.Expect(th.K8sClient.Status().Update(th.Ctx, ansibleEE)).To(Succeed())
g.Expect(ansibleEE.Spec.ExtraVars).To(HaveKey("edpm_override_hosts"))
if service.Spec.DeployOnAllNodeSets != nil && *service.Spec.DeployOnAllNodeSets {
if service.Spec.DeployOnAllNodeSets {
g.Expect(string(ansibleEE.Spec.ExtraVars["edpm_override_hosts"])).To(Equal("\"all\""))
} else {
g.Expect(string(ansibleEE.Spec.ExtraVars["edpm_override_hosts"])).To(Equal(fmt.Sprintf("\"%s\"", dataplaneNodeSetName.Name)))
Expand Down Expand Up @@ -387,7 +387,7 @@ var _ = Describe("Dataplane Deployment Test", func() {
g.Expect(th.K8sClient.Get(th.Ctx, ansibleeeName, ansibleEE)).To(Succeed())
ansibleEE.Status.JobStatus = ansibleeev1.JobStatusSucceeded
g.Expect(th.K8sClient.Status().Update(th.Ctx, ansibleEE)).To(Succeed())
if service.Spec.DeployOnAllNodeSets != nil && *service.Spec.DeployOnAllNodeSets {
if service.Spec.DeployOnAllNodeSets {
g.Expect(string(ansibleEE.Spec.ExtraVars["edpm_override_hosts"])).To(Equal("\"all\""))
}
}, th.Timeout, th.Interval).Should(Succeed())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ var _ = Describe("Dataplane NodeSet Test", func() {

It("Should have service called 'global-service'", func() {
service := GetService(dataplaneGlobalServiceName)
Expect(*service.Spec.DeployOnAllNodeSets).Should(BeTrue())
Expect(service.Spec.DeployOnAllNodeSets).Should(BeTrue())
})
})

Expand Down
4 changes: 2 additions & 2 deletions tests/functional/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var _ = Describe("OpenstackDataplaneService Test", func() {
Expect(service.Spec.Secrets).To(BeEmpty())
Expect(service.Spec.Playbook).To(BeEmpty())
Expect(service.Spec.ConfigMaps).To(BeEmpty())
Expect(service.Spec.DeployOnAllNodeSets).To(BeNil())
Expect(service.Spec.DeployOnAllNodeSets).To(BeFalse())
})
})

Expand All @@ -60,7 +60,7 @@ var _ = Describe("OpenstackDataplaneService Test", func() {
Expect(service.Spec.Secrets).To(BeEmpty())
Expect(service.Spec.Playbook).To(BeEmpty())
Expect(service.Spec.ConfigMaps).To(BeEmpty())
Expect(*service.Spec.DeployOnAllNodeSets).To(BeTrue())
Expect(service.Spec.DeployOnAllNodeSets).To(BeTrue())
})
})
})

0 comments on commit 203540b

Please sign in to comment.