Skip to content

Commit 901c44b

Browse files
Lukáš Hellmannl-hellmann
authored andcommitted
z0 - choose zerops yaml setup
1 parent f3c6f47 commit 901c44b

File tree

7 files changed

+27
-9
lines changed

7 files changed

+27
-9
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module github.com/zeropsio/zcli
22

33
go 1.21
44

5-
require github.com/zeropsio/zerops-go v1.0.7
5+
require github.com/zeropsio/zerops-go v1.0.8
66

77
require (
88
github.com/charmbracelet/bubbles v0.18.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSW
104104
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
105105
github.com/zeropsio/zerops-go v1.0.7 h1:vtiaSSu3TrC18BlOxH5/PydUk1+BNDjQhhw6S80SCPE=
106106
github.com/zeropsio/zerops-go v1.0.7/go.mod h1:Nuqf1xWt53IRLyVoXgR4hF4ICc9jlfOfQgnN3ZhJR3E=
107+
github.com/zeropsio/zerops-go v1.0.8 h1:YhSS7+cW1fIRUE1tD5hpGlD3+opxzvI5lfsONgwdn28=
108+
github.com/zeropsio/zerops-go v1.0.8/go.mod h1:Nuqf1xWt53IRLyVoXgR4hF4ICc9jlfOfQgnN3ZhJR3E=
107109
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
108110
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
109111
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=

src/cmd/serviceDeploy.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func serviceDeployCmd() *cmdBuilder.Cmd {
3030
StringFlag("archiveFilePath", "", i18n.T(i18n.BuildArchiveFilePath)).
3131
StringFlag("versionName", "", i18n.T(i18n.BuildVersionName)).
3232
StringFlag("zeropsYamlPath", "", i18n.T(i18n.ZeropsYamlLocation)).
33+
StringFlag("setup", "", i18n.T(i18n.ZeropsYamlSetup)).
3334
BoolFlag("deployGitFolder", false, i18n.T(i18n.ZeropsYamlLocation)).
3435
HelpFlag(i18n.T(i18n.CmdHelpServiceDeploy)).
3536
LoggedUserRunFunc(func(ctx context.Context, cmdData *cmdBuilder.LoggedUserCmdData) error {
@@ -48,7 +49,11 @@ func serviceDeployCmd() *cmdBuilder.Cmd {
4849
return err
4950
}
5051

51-
err = validateZeropsYamlContent(ctx, cmdData.RestApiClient, cmdData.Service, configContent)
52+
setup := cmdData.Service.Name
53+
if setupParam := cmdData.Params.GetString("setup"); setupParam != "" {
54+
setup = types.NewString(setupParam)
55+
}
56+
err = validateZeropsYamlContent(ctx, cmdData.RestApiClient, cmdData.Service, setup, configContent)
5257
if err != nil {
5358
return err
5459
}
@@ -155,7 +160,8 @@ func serviceDeployCmd() *cmdBuilder.Cmd {
155160
Id: appVersion.Id,
156161
},
157162
body.PutAppVersionDeploy{
158-
ZeropsYaml: types.NewMediumTextNull(string(configContent)),
163+
ZeropsYaml: types.NewMediumTextNull(string(configContent)),
164+
ZeropsYamlSetup: setup.StringNull(),
159165
},
160166
)
161167
if err != nil {

src/cmd/servicePush.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func servicePushCmd() *cmdBuilder.Cmd {
2929
StringFlag("archiveFilePath", "", i18n.T(i18n.BuildArchiveFilePath)).
3030
StringFlag("versionName", "", i18n.T(i18n.BuildVersionName)).
3131
StringFlag("zeropsYamlPath", "", i18n.T(i18n.ZeropsYamlLocation)).
32+
StringFlag("setup", "", i18n.T(i18n.ZeropsYamlSetup)).
3233
BoolFlag("deployGitFolder", false, i18n.T(i18n.UploadGitFolder)).
3334
HelpFlag(i18n.T(i18n.CmdHelpPush)).
3435
LoggedUserRunFunc(func(ctx context.Context, cmdData *cmdBuilder.LoggedUserCmdData) error {
@@ -49,7 +50,11 @@ func servicePushCmd() *cmdBuilder.Cmd {
4950
return err
5051
}
5152

52-
err = validateZeropsYamlContent(ctx, cmdData.RestApiClient, cmdData.Service, configContent)
53+
setup := cmdData.Service.Name
54+
if setupParam := cmdData.Params.GetString("setup"); setupParam != "" {
55+
setup = types.NewString(setupParam)
56+
}
57+
err = validateZeropsYamlContent(ctx, cmdData.RestApiClient, cmdData.Service, setup, configContent)
5358
if err != nil {
5459
return err
5560
}
@@ -148,7 +153,8 @@ func servicePushCmd() *cmdBuilder.Cmd {
148153
Id: appVersion.Id,
149154
},
150155
body.PutAppVersionBuildAndDeploy{
151-
ZeropsYaml: types.MediumText(configContent),
156+
ZeropsYaml: types.MediumText(configContent),
157+
ZeropsYamlSetup: setup.StringNull(),
152158
},
153159
)
154160
if err != nil {

src/cmd/servicePushDeployShared.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,15 @@ func validateZeropsYamlContent(
145145
ctx context.Context,
146146
restApiClient *zeropsRestApiClient.Handler,
147147
service *entity.Service,
148+
setup types.String,
148149
yamlContent []byte,
149150
) error {
150151
resp, err := restApiClient.PostServiceStackZeropsYamlValidation(ctx, body.ZeropsYamlValidation{
151152
ServiceStackTypeVersionName: service.ServiceStackTypeVersionName,
152153
ServiceStackName: service.Name,
153154
ServiceStackTypeId: service.ServiceTypeId,
154155
ZeropsYaml: types.NewMediumText(string(yamlContent)),
156+
ZeropsYamlSetup: setup.StringNull(),
155157
})
156158
if err != nil {
157159
return err

src/i18n/en.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ var en = map[string]string{
204204
ServiceIdFlag: "If you have access to more than one service, you must specify the service ID for which the\ncommand is to be executed.",
205205
ProjectIdFlag: "If you have access to more than one project, you must specify the project ID for which the\ncommand is to be executed.",
206206
VpnAutoDisconnectFlag: "If set, zCLI will automatically disconnect from the VPN if it is already connected.",
207+
ZeropsYamlSetup: "Choose setup to be used from zerops.yml.",
207208

208209
// archiveClient
209210
ArchClientWorkingDirectory: "working directory: %s",
@@ -232,9 +233,9 @@ var en = map[string]string{
232233
VpnCheckingConnectionIsActive: "VPN connection is active",
233234
VpnCheckingConnectionIsNotActive: "VPN connection is not active",
234235

235-
////////////
236+
// //////////
236237
// global //
237-
////////////
238+
// //////////
238239
ProcessInvalidState: "last command has finished with error, identifier for communication with our support: %s",
239240

240241
CliTerminalModeEnvVar: "If enabled provides a rich UI to communicate with a user. Possible values: auto, enabled, disabled. Default value is auto.",

src/i18n/i18n.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ const (
198198
ServiceIdFlag = "ServiceIdFlag"
199199
ProjectIdFlag = "ProjectIdFlag"
200200
VpnAutoDisconnectFlag = "VpnAutoDisconnectFlag"
201+
ZeropsYamlSetup = "ZeropsYamlSetup"
201202

202203
// archiveClient
203204
ArchClientWorkingDirectory = "ArchClientWorkingDirectory"
@@ -226,9 +227,9 @@ const (
226227
VpnCheckingConnectionIsActive = "VpnCheckingConnectionIsActive"
227228
VpnCheckingConnectionIsNotActive = "VpnCheckingConnectionIsNotActive"
228229

229-
////////////
230+
// //////////
230231
// global //
231-
////////////
232+
// //////////
232233
ProcessInvalidState = "ProcessInvalidState"
233234

234235
CliTerminalModeEnvVar = "TerminalModeEnv"

0 commit comments

Comments
 (0)