Skip to content
Closed
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
11 changes: 9 additions & 2 deletions src/cmd/projectCreate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions src/entity/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand All @@ -25,4 +26,5 @@ type PostProject struct {
Mode enum.ProjectModeEnum
SshIsolation types.StringNull
EnvIsolation types.StringNull
Location stringId.LocationIdNull
}
1 change: 1 addition & 0 deletions src/entity/repository/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading