Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.

Commit 2ea6520

Browse files
committed
operator/crd: Fix typo in additional columns field
An e2e test to validate the deployment fields listed by `kubectl get`.
1 parent 726e26c commit 2ea6520

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

deploy/crd/pmem-csi.intel.com_deployments.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ spec:
3030
- jsonPath: .status.phase
3131
name: Status
3232
type: string
33-
- jsonPath: .metatdata.creationTimestamp
33+
- jsonPath: .metadata.creationTimestamp
3434
name: Age
3535
type: date
3636
name: v1alpha1

pkg/apis/pmemcsi/v1alpha1/deployment_types.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ type DeploymentStatus struct {
193193
// +kubebuilder:printcolumn:name="NodeSelector",type=string,JSONPath=`.spec.nodeSelector`
194194
// +kubebuilder:printcolumn:name="Image",type=string,JSONPath=`.spec.image`
195195
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.phase`
196-
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metatdata.creationTimestamp`
196+
// +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`
197197
type Deployment struct {
198198
metav1.TypeMeta `json:",inline"`
199199
metav1.ObjectMeta `json:"metadata,omitempty"`

test/e2e/operator/deployment_api.go

+29
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"time"
1515

1616
api "github.com/intel/pmem-csi/pkg/apis/pmemcsi/v1alpha1"
17+
"github.com/intel/pmem-csi/pkg/exec"
1718
"github.com/intel/pmem-csi/pkg/k8sutil"
1819
"github.com/intel/pmem-csi/pkg/pmem-csi-operator/controller/deployment/testcases"
1920
"github.com/intel/pmem-csi/pkg/version"
@@ -160,6 +161,34 @@ var _ = deploy.DescribeForSome("API", func(d *deploy.Deployment) bool {
160161
})
161162
}
162163

164+
It("get deployment shall list expected fields", func() {
165+
lblKey := "storage"
166+
lblValue := "unknown-node"
167+
deployment := getDeployment("test-get-deployment-fields")
168+
// Only values that are visible in Deployment CR are shown in `kubectl get`
169+
// but, not the default values chosen by the operator.
170+
// So provide the values that are expected to list.
171+
deployment.Spec.DeviceMode = api.DeviceModeDirect
172+
deployment.Spec.PullPolicy = corev1.PullNever
173+
deployment.Spec.Image = dummyImage
174+
deployment.Spec.NodeSelector = map[string]string{
175+
lblKey: lblValue,
176+
}
177+
178+
deployment = deploy.CreateDeploymentCR(f, deployment)
179+
defer deploy.DeleteDeploymentCR(f, deployment.Name)
180+
validateDriver(deployment, "validate driver")
181+
182+
d := deploy.GetDeploymentCR(f, deployment.Name)
183+
184+
// Run in-cluster kubectl from master node
185+
ssh := os.Getenv("REPO_ROOT") + "/_work/" + os.Getenv("CLUSTER") + "/ssh.0"
186+
out, err := exec.RunCommand(ssh, "kubectl", "get", "deployments.pmem-csi.intel.com", "--no-headers")
187+
Expect(err).ShouldNot(HaveOccurred(), "kubectl get: %v", out)
188+
Expect(out).Should(MatchRegexp(`%s\s+%s\s+.*"?%s"?:"?%s"?.*\s+%s\s+%s\s+[0-9]+(s|m)`,
189+
d.Name, d.Spec.DeviceMode, lblKey, lblValue, d.Spec.Image, d.Status.Phase), "fields mismatch")
190+
})
191+
163192
It("driver image shall default to operator image", func() {
164193
deployment := getDeployment("test-deployment-driver-image")
165194
deployment.Spec.Image = ""

0 commit comments

Comments
 (0)