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

Rename JobType from on-demand to workflow_dispatch #11243

Merged
merged 7 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
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
4 changes: 2 additions & 2 deletions cmd/image-builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func loadADOGitState() (GitStateConfig, error) {
if !present {
return GitStateConfig{}, fmt.Errorf("JOB_TYPE environment variable is not set, please set it to valid job type")
}
if !slices.Contains([]string{"presubmit", "postsubmit"}, jobType) {
if !slices.Contains([]string{"presubmit", "postsubmit", "workflow_dispatch"}, jobType) {
return GitStateConfig{}, fmt.Errorf("image builder is running for unsupported event %s", jobType)
}

Expand Down Expand Up @@ -266,7 +266,7 @@ func loadGithubActionsGitState() (GitStateConfig, error) {
return GitStateConfig{
RepositoryName: *payload.Repo.Name,
RepositoryOwner: *payload.Repo.Owner.Login,
JobType: "on-demand",
JobType: "workflow_dispatch",
BaseCommitSHA: os.Getenv("GITHUB_SHA"),
BaseCommitRef: os.Getenv("GITHUB_REF"),
}, nil
Expand Down
2 changes: 1 addition & 1 deletion cmd/image-builder/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func TestLoadGitStateConfig(t *testing.T) {
gitState: GitStateConfig{
RepositoryName: "test-infra",
RepositoryOwner: "KacperMalachowski",
JobType: "on-demand",
JobType: "workflow_dispatch",
BaseCommitSHA: "d42f5051757b3e0699eb979d7581404e36fc0eee",
BaseCommitRef: "refs/heads/main",
isPullRequest: false,
Expand Down
4 changes: 2 additions & 2 deletions cmd/image-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ func prepareADOTemplateParameters(options options) (adopipelines.OCIImageBuilder
templateParameters.SetPresubmitJobType()
} else if options.gitState.JobType == "postsubmit" {
templateParameters.SetPostsubmitJobType()
} else if options.gitState.JobType == "on-demand" {
templateParameters.SetOnDemandJobType()
} else if options.gitState.JobType == "workflow_dispatch" {
templateParameters.SetWorkflowDispatchJobType()
}

if options.gitState.IsPullRequest() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/image-builder/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ func Test_prepareADOTemplateParameters(t *testing.T) {
name: "On demand job type with base commit SHA and base commit ref",
options: options{
gitState: GitStateConfig{
JobType: "on-demand",
JobType: "workflow_dispatch",
BaseCommitSHA: "abc123",
BaseCommitRef: "main",
},
Expand All @@ -666,7 +666,7 @@ func Test_prepareADOTemplateParameters(t *testing.T) {
"Context": "",
"Dockerfile": "",
"ExportTags": "false",
"JobType": "on-demand",
"JobType": "workflow_dispatch",
"Name": "",
"PullBaseSHA": "abc123",
"BaseRef": "main",
Expand Down
10 changes: 5 additions & 5 deletions pkg/azuredevops/pipelines/templatesParams.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func (p OCIImageBuilderTemplateParams) SetPostsubmitJobType() {
p["JobType"] = "postsubmit"
}

// SetOnDemandJobType sets required parameter JobType to on-demand.
func (p OCIImageBuilderTemplateParams) SetOnDemandJobType() {
p["JobType"] = "on-demand"
// SetWorkflowDispatchJobType sets required parameter JobType to workflow_dispatch.
func (p OCIImageBuilderTemplateParams) SetWorkflowDispatchJobType() {
p["JobType"] = "workflow_dispatch"
}

// SetPullNumber sets optional parameter PullNumber.
Expand Down Expand Up @@ -149,8 +149,8 @@ func (p OCIImageBuilderTemplateParams) Validate() error {
if jobType, ok = p["JobType"]; !ok {
return ErrRequiredParamNotSet("JobType")
}
if jobType != "presubmit" && jobType != "postsubmit" && jobType != "on-demand" {
return fmt.Errorf("JobType must be either presubmit, postsubmit or on-demand, got: %s", jobType)
if jobType != "presubmit" && jobType != "postsubmit" && jobType != "workflow_dispatch" {
return fmt.Errorf("JobType must be either presubmit, postsubmit or workflow_dispatch, got: %s", jobType)
Sawthis marked this conversation as resolved.
Show resolved Hide resolved
}
if _, ok = p["PullBaseSHA"]; !ok {
return ErrRequiredParamNotSet("BaseSHA")
Expand Down
8 changes: 4 additions & 4 deletions pkg/azuredevops/pipelines/templatesParams_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ var _ = Describe("Test OCIImageBuilderTemplateParams", func() {
Expect(params["JobType"]).To(Equal("postsubmit"))
})

It("sets the correct JobType to on-demand", func() {
params.SetOnDemandJobType()
Expect(params["JobType"]).To(Equal("on-demand"))
It("sets the correct JobType to workflow_dispatch", func() {
params.SetWorkflowDispatchJobType()
Expect(params["JobType"]).To(Equal("workflow_dispatch"))
})

It("sets the correct PullNumber", func() {
Expand Down Expand Up @@ -117,7 +117,7 @@ var _ = Describe("Test OCIImageBuilderTemplateParams", func() {
Expect(err).NotTo(BeNil())
})

It("returns error if JobType is not presubmit or postsubmit or on-demand", func() {
It("returns error if JobType is not presubmit or postsubmit or workflow_dispatch", func() {
params["JobType"] = "otherType"

err := params.Validate()
Expand Down
Loading