Skip to content

Commit 8146e37

Browse files
committed
Do not send empty filter criteria into deploy payload
1 parent 06257e5 commit 8146e37

File tree

8 files changed

+32
-28
lines changed

8 files changed

+32
-28
lines changed

.github/workflows/analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ jobs:
2121
- name: Static Code Analysis
2222
uses: golangci/golangci-lint-action@v6
2323
with:
24-
version: latest
24+
version: v1.63.4

commands/common/manifest_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var manifestSample = &model.Manifest{
2929
"hidden1": "hidden1.value",
3030
"hidden2": "hidden2.value",
3131
},
32-
FilterCriteria: model.FilterCriteria{
32+
FilterCriteria: &model.FilterCriteria{
3333
ArtifactFilterCriteria: &model.ArtifactFilterCriteria{
3434
RepoKeys: []string{
3535
"my-repo-local",

commands/deploy_cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func GetDeployCommand() components.Command {
6161
return err
6262
}
6363

64-
if err = common.ValidateFilterCriteria(&manifest.FilterCriteria, actionMeta); err != nil {
64+
if err = common.ValidateFilterCriteria(manifest.FilterCriteria, actionMeta); err != nil {
6565
return err
6666
}
6767

@@ -149,7 +149,7 @@ func prepareDeployRequest(ctx *components.Context, manifest *model.Manifest, act
149149
}
150150

151151
if actionMeta.MandatoryFilter {
152-
payload.FilterCriteria = &manifest.FilterCriteria
152+
payload.FilterCriteria = manifest.FilterCriteria
153153
}
154154

155155
return payload, nil

commands/deploy_cmd_test.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,11 @@ func TestDeployCommand(t *testing.T) {
115115
workerName: "wk-3",
116116
serverBehavior: common.NewServerStub(t).WithGetOneEndpoint(),
117117
patchManifest: func(mf *model.Manifest) {
118-
mf.FilterCriteria.Schedule = &model.ScheduleFilterCriteria{
119-
Cron: "1h",
120-
Timezone: "Asia/New_York",
118+
mf.FilterCriteria = &model.FilterCriteria{
119+
Schedule: &model.ScheduleFilterCriteria{
120+
Cron: "1h",
121+
Timezone: "Asia/New_York",
122+
},
121123
}
122124
},
123125
wantErr: errors.New("manifest validation failed: invalid cron expression"),

commands/edit_schedule_cmd.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ func (c *editScheduleCommand) run() error {
5959
return fmt.Errorf("invalid schedule provided: %w", err)
6060
}
6161

62-
manifest.FilterCriteria.Schedule = newCriteria
62+
manifest.FilterCriteria = &model.FilterCriteria{
63+
Schedule: newCriteria,
64+
}
6365

6466
if err = common.SaveManifest(manifest); err != nil {
6567
return fmt.Errorf("failed to save manifest: %w", err)

model/manifest.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ type FilterCriteria struct {
2020
type Secrets map[string]string
2121

2222
type Manifest struct {
23-
Name string `json:"name"`
24-
Description string `json:"description"`
25-
SourceCodePath string `json:"sourceCodePath"`
26-
Action string `json:"action"`
27-
Enabled bool `json:"enabled"`
28-
Debug bool `json:"debug"`
29-
ProjectKey string `json:"projectKey"`
30-
Secrets Secrets `json:"secrets"`
31-
FilterCriteria FilterCriteria `json:"filterCriteria,omitempty"`
32-
Application string `json:"application,omitempty"`
23+
Name string `json:"name"`
24+
Description string `json:"description"`
25+
SourceCodePath string `json:"sourceCodePath"`
26+
Action string `json:"action"`
27+
Enabled bool `json:"enabled"`
28+
Debug bool `json:"debug"`
29+
ProjectKey string `json:"projectKey"`
30+
Secrets Secrets `json:"secrets"`
31+
FilterCriteria *FilterCriteria `json:"filterCriteria,omitempty"`
32+
Application string `json:"application,omitempty"`
3333
}

model/worker.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ type Secret struct {
66
MarkedForRemoval bool `json:"markedForRemoval"`
77
}
88
type WorkerDetails struct {
9-
Key string `json:"key"`
10-
Description string `json:"description"`
11-
Debug bool `json:"debug"`
12-
Enabled bool `json:"enabled"`
13-
SourceCode string `json:"sourceCode"`
14-
Action string `json:"action"`
15-
FilterCriteria FilterCriteria `json:"filterCriteria,omitempty"`
16-
Secrets []*Secret `json:"secrets"`
17-
ProjectKey string `json:"projectKey"`
9+
Key string `json:"key"`
10+
Description string `json:"description"`
11+
Debug bool `json:"debug"`
12+
Enabled bool `json:"enabled"`
13+
SourceCode string `json:"sourceCode"`
14+
Action string `json:"action"`
15+
FilterCriteria *FilterCriteria `json:"filterCriteria,omitempty"`
16+
Secrets []*Secret `json:"secrets"`
17+
ProjectKey string `json:"projectKey"`
1818
}

test/commands/list_cmd_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestListCommand(t *testing.T) {
5353
Enabled: true,
5454
SourceCode: `export default async function() { return { "status": "OK" } }`,
5555
Action: "BEFORE_DOWNLOAD",
56-
FilterCriteria: model.FilterCriteria{
56+
FilterCriteria: &model.FilterCriteria{
5757
ArtifactFilterCriteria: &model.ArtifactFilterCriteria{
5858
RepoKeys: []string{"example-repo-local"},
5959
},

0 commit comments

Comments
 (0)