diff --git a/src/cmd/projectCreate.go b/src/cmd/projectCreate.go index 40c989e..0a70391 100644 --- a/src/cmd/projectCreate.go +++ b/src/cmd/projectCreate.go @@ -16,6 +16,7 @@ import ( "github.com/zeropsio/zcli/src/uxHelpers" "github.com/zeropsio/zerops-go/types" "github.com/zeropsio/zerops-go/types/enum" + "github.com/zeropsio/zerops-go/types/stringId" "github.com/zeropsio/zerops-go/types/uuid" ) @@ -34,6 +35,7 @@ func projectCreateCmd() *cmdBuilder.Cmd { StringFlag("mode", enumDefaultForFlag(enum.ProjectModeEnumLight), "Project mode"+enumValuesForFlag(enum.ProjectModeEnumAllPublic())). StringFlag("env-isolation", "service", "Env isolation rule [service, none] for more info see docs https://docs.zerops.io/features/env-variables#isolation-modes"). StringFlag("ssh-isolation", "vpn", "SSH isolation rules, for more info see docs https://docs.zerops.io/references/ssh#ssh-access-control"). + StringFlag("location", "", "Project location (e.g. us-east, defaults to eu-central)"). HelpFlag("Help for the project create command."). LoggedUserRunFunc(func(ctx context.Context, cmdData *cmdBuilder.LoggedUserCmdData) error { var err error @@ -108,14 +110,19 @@ func projectCreateCmd() *cmdBuilder.Cmd { return errors.New("Must specify name with --name") } - project, err := repository.PostProject(ctx, cmdData.RestApiClient, entity.PostProject{ + postProject := entity.PostProject{ OrgId: org.Id, Name: types.NewString(name), Tags: cmdData.Params.GetStringSlice("tags"), Mode: enum.ProjectModeEnum(mode), SshIsolation: types.NewStringNull(cmdData.Params.GetString("ssh-isolation")), EnvIsolation: types.NewStringNull(cmdData.Params.GetString("env-isolation")), - }) + } + if loc := cmdData.Params.GetString("location"); loc != "" { + postProject.Location = stringId.NewLocationIdNullFromString(loc) + } + + project, err := repository.PostProject(ctx, cmdData.RestApiClient, postProject) if err != nil { return err } diff --git a/src/entity/project.go b/src/entity/project.go index c9cca84..cc78384 100644 --- a/src/entity/project.go +++ b/src/entity/project.go @@ -3,6 +3,7 @@ package entity import ( "github.com/zeropsio/zerops-go/types" "github.com/zeropsio/zerops-go/types/enum" + "github.com/zeropsio/zerops-go/types/stringId" "github.com/zeropsio/zerops-go/types/uuid" ) @@ -25,4 +26,5 @@ type PostProject struct { Mode enum.ProjectModeEnum SshIsolation types.StringNull EnvIsolation types.StringNull + Location stringId.LocationIdNull } diff --git a/src/entity/repository/project.go b/src/entity/repository/project.go index 905ac5d..5df1f68 100644 --- a/src/entity/repository/project.go +++ b/src/entity/repository/project.go @@ -83,6 +83,7 @@ func PostProject( TagList: post.Tags, SshIsolation: post.SshIsolation, EnvIsolation: post.EnvIsolation, + Location: post.Location, } if postBody.TagList == nil { postBody.TagList = make(types.StringArray, 0)