Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Move JobID label suffix to constants #2852

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const (
LabelKeyCreatedBy = "createdBy"
LabelValueKanister = "kanister"
LabelPrefix = "kanister.io/"
JobIDLabelSuffix = "JobID"
mabhi marked this conversation as resolved.
Show resolved Hide resolved
)

// These names are used to query ActionSet API objects.
Expand Down
5 changes: 2 additions & 3 deletions pkg/function/kube_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ import (
)

const (
jobPrefix = "kanister-job-"
jobIDSuffix = "JobID"
jobPrefix = "kanister-job-"

// KubeTaskFuncName gives the function name
KubeTaskFuncName = "KubeTask"
Expand Down Expand Up @@ -68,7 +67,7 @@ func kubeTask(ctx context.Context, cli kubernetes.Interface, namespace, image st
PodOverride: podOverride,
}
// Mark pod with label having key `kanister.io/JobID`, the value of which is a reference to the origin of the pod.
kube.AddLabelsToPodOptionsFromContext(ctx, options, path.Join(consts.LabelPrefix, jobIDSuffix))
kube.AddLabelsToPodOptionsFromContext(ctx, options, path.Join(consts.LabelPrefix, consts.JobIDLabelSuffix))
pr := kube.NewPodRunner(cli, options)
podFunc := kubeTaskPodFunc()
return pr.Run(ctx, podFunc)
Expand Down
2 changes: 1 addition & 1 deletion pkg/kube/pod_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func (s *PodRunnerTestSuite) TestPodRunnerForSuccessCase(c *C) {
// TestPodRunnerWithDebugLabelForSuccessCase adds a debug entry into the context and verifies the
// pod got created with corresponding label using the entry or not.
func (s *PodRunnerTestSuite) TestPodRunnerWithDebugLabelForSuccessCase(c *C) {
jobIDSuffix := "JobID"
jobIDSuffix := consts.JobIDLabelSuffix
for _, tc := range []struct {
name string
targetKey string
Expand Down