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

z0 - choose zerops yaml setup #142

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/zeropsio/zcli

go 1.21

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

require (
github.com/charmbracelet/bubbles v0.18.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSW
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/zeropsio/zerops-go v1.0.7 h1:vtiaSSu3TrC18BlOxH5/PydUk1+BNDjQhhw6S80SCPE=
github.com/zeropsio/zerops-go v1.0.7/go.mod h1:Nuqf1xWt53IRLyVoXgR4hF4ICc9jlfOfQgnN3ZhJR3E=
github.com/zeropsio/zerops-go v1.0.8 h1:YhSS7+cW1fIRUE1tD5hpGlD3+opxzvI5lfsONgwdn28=
github.com/zeropsio/zerops-go v1.0.8/go.mod h1:Nuqf1xWt53IRLyVoXgR4hF4ICc9jlfOfQgnN3ZhJR3E=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
Expand Down
10 changes: 8 additions & 2 deletions src/cmd/serviceDeploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func serviceDeployCmd() *cmdBuilder.Cmd {
StringFlag("archiveFilePath", "", i18n.T(i18n.BuildArchiveFilePath)).
StringFlag("versionName", "", i18n.T(i18n.BuildVersionName)).
StringFlag("zeropsYamlPath", "", i18n.T(i18n.ZeropsYamlLocation)).
StringFlag("setup", "", i18n.T(i18n.ZeropsYamlSetup)).
BoolFlag("deployGitFolder", false, i18n.T(i18n.ZeropsYamlLocation)).
HelpFlag(i18n.T(i18n.CmdHelpServiceDeploy)).
LoggedUserRunFunc(func(ctx context.Context, cmdData *cmdBuilder.LoggedUserCmdData) error {
Expand All @@ -48,7 +49,11 @@ func serviceDeployCmd() *cmdBuilder.Cmd {
return err
}

err = validateZeropsYamlContent(ctx, cmdData.RestApiClient, cmdData.Service, configContent)
setup := cmdData.Service.Name
if setupParam := cmdData.Params.GetString("setup"); setupParam != "" {
setup = types.NewString(setupParam)
}
err = validateZeropsYamlContent(ctx, cmdData.RestApiClient, cmdData.Service, setup, configContent)
if err != nil {
return err
}
Expand Down Expand Up @@ -155,7 +160,8 @@ func serviceDeployCmd() *cmdBuilder.Cmd {
Id: appVersion.Id,
},
body.PutAppVersionDeploy{
ZeropsYaml: types.NewMediumTextNull(string(configContent)),
ZeropsYaml: types.NewMediumTextNull(string(configContent)),
ZeropsYamlSetup: setup.StringNull(),
},
)
if err != nil {
Expand Down
10 changes: 8 additions & 2 deletions src/cmd/servicePush.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func servicePushCmd() *cmdBuilder.Cmd {
StringFlag("archiveFilePath", "", i18n.T(i18n.BuildArchiveFilePath)).
StringFlag("versionName", "", i18n.T(i18n.BuildVersionName)).
StringFlag("zeropsYamlPath", "", i18n.T(i18n.ZeropsYamlLocation)).
StringFlag("setup", "", i18n.T(i18n.ZeropsYamlSetup)).
BoolFlag("deployGitFolder", false, i18n.T(i18n.UploadGitFolder)).
HelpFlag(i18n.T(i18n.CmdHelpPush)).
LoggedUserRunFunc(func(ctx context.Context, cmdData *cmdBuilder.LoggedUserCmdData) error {
Expand All @@ -49,7 +50,11 @@ func servicePushCmd() *cmdBuilder.Cmd {
return err
}

err = validateZeropsYamlContent(ctx, cmdData.RestApiClient, cmdData.Service, configContent)
setup := cmdData.Service.Name
if setupParam := cmdData.Params.GetString("setup"); setupParam != "" {
setup = types.NewString(setupParam)
}
err = validateZeropsYamlContent(ctx, cmdData.RestApiClient, cmdData.Service, setup, configContent)
if err != nil {
return err
}
Expand Down Expand Up @@ -148,7 +153,8 @@ func servicePushCmd() *cmdBuilder.Cmd {
Id: appVersion.Id,
},
body.PutAppVersionBuildAndDeploy{
ZeropsYaml: types.MediumText(configContent),
ZeropsYaml: types.MediumText(configContent),
ZeropsYamlSetup: setup.StringNull(),
},
)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions src/cmd/servicePushDeployShared.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,15 @@ func validateZeropsYamlContent(
ctx context.Context,
restApiClient *zeropsRestApiClient.Handler,
service *entity.Service,
setup types.String,
yamlContent []byte,
) error {
resp, err := restApiClient.PostServiceStackZeropsYamlValidation(ctx, body.ZeropsYamlValidation{
ServiceStackTypeVersionName: service.ServiceStackTypeVersionName,
ServiceStackName: service.Name,
ServiceStackTypeId: service.ServiceTypeId,
ZeropsYaml: types.NewMediumText(string(yamlContent)),
ZeropsYamlSetup: setup.StringNull(),
})
if err != nil {
return err
Expand Down
5 changes: 3 additions & 2 deletions src/i18n/en.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ var en = map[string]string{
ServiceIdFlag: "If you have access to more than one service, you must specify the service ID for which the\ncommand is to be executed.",
ProjectIdFlag: "If you have access to more than one project, you must specify the project ID for which the\ncommand is to be executed.",
VpnAutoDisconnectFlag: "If set, zCLI will automatically disconnect from the VPN if it is already connected.",
ZeropsYamlSetup: "Choose setup to be used from zerops.yml.",

// archiveClient
ArchClientWorkingDirectory: "working directory: %s",
Expand Down Expand Up @@ -232,9 +233,9 @@ var en = map[string]string{
VpnCheckingConnectionIsActive: "VPN connection is active",
VpnCheckingConnectionIsNotActive: "VPN connection is not active",

////////////
// //////////
// global //
////////////
// //////////
ProcessInvalidState: "last command has finished with error, identifier for communication with our support: %s",

CliTerminalModeEnvVar: "If enabled provides a rich UI to communicate with a user. Possible values: auto, enabled, disabled. Default value is auto.",
Expand Down
5 changes: 3 additions & 2 deletions src/i18n/i18n.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ const (
ServiceIdFlag = "ServiceIdFlag"
ProjectIdFlag = "ProjectIdFlag"
VpnAutoDisconnectFlag = "VpnAutoDisconnectFlag"
ZeropsYamlSetup = "ZeropsYamlSetup"

// archiveClient
ArchClientWorkingDirectory = "ArchClientWorkingDirectory"
Expand Down Expand Up @@ -226,9 +227,9 @@ const (
VpnCheckingConnectionIsActive = "VpnCheckingConnectionIsActive"
VpnCheckingConnectionIsNotActive = "VpnCheckingConnectionIsNotActive"

////////////
// //////////
// global //
////////////
// //////////
ProcessInvalidState = "ProcessInvalidState"

CliTerminalModeEnvVar = "TerminalModeEnv"
Expand Down
Loading