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

WIP - Add clone environment support #45

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ build_debug:: ensure_go
build_python::
PYPI_VERSION=$(PYTHON_SDK_VERSION) ./scripts/build_python_sdk.sh

build_typescript::
cd sdk/typescript && \
npm i && npm run build && \
cp ../../README.md ../../LICENSE package.json package-lock.json ./bin/ && \
sed -i.bak -e "s/\$${VERSION}/$(VERSION)/g" ./bin/package.json && \
rm -rf ./bin/tests/*

test_go:: build_go
cd sdk && ${GO} test --timeout 30m -short -count 1 -parallel ${CONCURRENCY} ./...

Expand Down
1 change: 1 addition & 0 deletions sdk/go/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ configuration.go
model_access.go
model_accessor.go
model_check_environment.go
model_clone_environment.go
model_create_environment.go
model_create_environment_revision_tag.go
model_create_environment_tag.go
Expand Down
198 changes: 198 additions & 0 deletions sdk/go/api_esc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions sdk/go/api_esc_extensions.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,29 @@ func (c *EscClient) CreateEnvironment(ctx context.Context, org, projectName, env
return err
}

type CloneEnvironmentOptions struct {
Version int32
PreserveHistory bool
PreserveAccess bool
PreserveEnvironmentTags bool
PreserveRevisionTags bool
}

// CloneEnvironment clones an existing environment into a new environment.
func (c *EscClient) CloneEnvironment(ctx context.Context, org, srcProjectName, srcEnvName, destProjectName, destEnvName string, cloneEnvironmentOptions *CloneEnvironmentOptions) error {
cloneEnvironment := NewCloneEnvironment(destProjectName, destEnvName)
if cloneEnvironmentOptions.Version != 0 {
cloneEnvironment.Version = &cloneEnvironmentOptions.Version
}
cloneEnvironment.PreserveHistory = &cloneEnvironmentOptions.PreserveHistory
cloneEnvironment.PreserveAccess = &cloneEnvironmentOptions.PreserveAccess
cloneEnvironment.PreserveEnvironmentTags = &cloneEnvironmentOptions.PreserveEnvironmentTags
cloneEnvironment.PreserveRevisionTags = &cloneEnvironmentOptions.PreserveRevisionTags

_, err := c.EscAPI.CloneEnvironment(ctx, org, srcProjectName, srcEnvName).CloneEnvironment(*cloneEnvironment).Execute()
return err
}

// UpdateEnvironmentYaml updates the environment with the given name in the given organization with the given YAML definition.
func (c *EscClient) UpdateEnvironmentYaml(ctx context.Context, org, projectName, envName, yaml string) (*EnvironmentDiagnostics, error) {
diags, _, err := c.EscAPI.UpdateEnvironmentYaml(ctx, org, projectName, envName).Body(yaml).Execute()
Expand Down
Loading
Loading