@@ -15,15 +15,15 @@ import (
1515)
1616
1717type deployRequest struct {
18- Key string `json:"key"`
19- Description string `json:"description"`
20- Enabled bool `json:"enabled"`
21- Debug bool `json:"debug"`
22- SourceCode string `json:"sourceCode"`
23- Action string `json:"action"`
24- FilterCriteria model.FilterCriteria `json:"filterCriteria,omitempty"`
25- Secrets []* model.Secret `json:"secrets"`
26- ProjectKey string `json:"projectKey"`
18+ Key string `json:"key"`
19+ Description string `json:"description"`
20+ Enabled bool `json:"enabled"`
21+ Debug bool `json:"debug"`
22+ SourceCode string `json:"sourceCode"`
23+ Action string `json:"action"`
24+ FilterCriteria * model.FilterCriteria `json:"filterCriteria,omitempty"`
25+ Secrets []* model.Secret `json:"secrets"`
26+ ProjectKey string `json:"projectKey"`
2727}
2828
2929func GetDeployCommand () components.Command {
@@ -61,10 +61,8 @@ func GetDeployCommand() components.Command {
6161 return err
6262 }
6363
64- if actionMeta .MandatoryFilter && actionMeta .FilterType == model .FilterTypeSchedule {
65- if err = common .ValidateScheduleCriteria (& manifest .FilterCriteria .Schedule ); err != nil {
66- return fmt .Errorf ("manifest validation failed: %w" , err )
67- }
64+ if err = common .ValidateFilterCriteria (& manifest .FilterCriteria , actionMeta ); err != nil {
65+ return err
6866 }
6967
7068 if ! c .GetBoolFlagValue (model .FlagNoSecrets ) {
@@ -73,18 +71,18 @@ func GetDeployCommand() components.Command {
7371 }
7472 }
7573
76- return runDeployCommand (c , manifest , server .GetUrl (), server .GetAccessToken ())
74+ return runDeployCommand (c , manifest , actionMeta , server .GetUrl (), server .GetAccessToken ())
7775 },
7876 }
7977}
8078
81- func runDeployCommand (ctx * components.Context , manifest * model.Manifest , serverUrl string , token string ) error {
79+ func runDeployCommand (ctx * components.Context , manifest * model.Manifest , actionMeta * model. ActionMetadata , serverUrl string , token string ) error {
8280 existingWorker , err := common .FetchWorkerDetails (ctx , serverUrl , token , manifest .Name , manifest .ProjectKey )
8381 if err != nil {
8482 return err
8583 }
8684
87- body , err := prepareDeployRequest (ctx , manifest , existingWorker )
85+ body , err := prepareDeployRequest (ctx , manifest , actionMeta , existingWorker )
8886 if err != nil {
8987 return err
9088 }
@@ -126,7 +124,7 @@ func runDeployCommand(ctx *components.Context, manifest *model.Manifest, serverU
126124 return err
127125}
128126
129- func prepareDeployRequest (ctx * components.Context , manifest * model.Manifest , existingWorker * model.WorkerDetails ) (* deployRequest , error ) {
127+ func prepareDeployRequest (ctx * components.Context , manifest * model.Manifest , actionMeta * model. ActionMetadata , existingWorker * model.WorkerDetails ) (* deployRequest , error ) {
130128 sourceCode , err := common .ReadSourceCode (manifest )
131129 if err != nil {
132130 return nil , err
@@ -140,15 +138,18 @@ func prepareDeployRequest(ctx *components.Context, manifest *model.Manifest, exi
140138 }
141139
142140 payload := & deployRequest {
143- Key : manifest .Name ,
144- Action : manifest .Action ,
145- Description : manifest .Description ,
146- Enabled : manifest .Enabled ,
147- Debug : manifest .Debug ,
148- FilterCriteria : manifest .FilterCriteria ,
149- SourceCode : sourceCode ,
150- Secrets : secrets ,
151- ProjectKey : manifest .ProjectKey ,
141+ Key : manifest .Name ,
142+ Action : manifest .Action ,
143+ Description : manifest .Description ,
144+ Enabled : manifest .Enabled ,
145+ Debug : manifest .Debug ,
146+ SourceCode : sourceCode ,
147+ Secrets : secrets ,
148+ ProjectKey : manifest .ProjectKey ,
149+ }
150+
151+ if actionMeta .MandatoryFilter {
152+ payload .FilterCriteria = & manifest .FilterCriteria
152153 }
153154
154155 return payload , nil
0 commit comments