MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / cloneRun

Function cloneRun

pkg/cmd/tenant/clone/clone.go:85–112  ·  view source on GitHub ↗
(opts *CloneOptions)

Source from the content-addressed store, hash-verified

83}
84
85func cloneRun(opts *CloneOptions) error {
86 if !opts.NoPrompt {
87 if err := PromptMissing(opts); err != nil {
88 return err
89 }
90 }
91
92 tenant, err := opts.GetTenantCallback(opts.SourceTenant.Value)
93 if err != nil {
94 return err
95 }
96
97 clonedTenant, err := opts.Client.Tenants.Clone(tenant, tenants.TenantCloneRequest{Name: opts.Name.Value, Description: opts.Description.Value})
98 if err != nil {
99 return err
100 }
101
102 fmt.Fprintf(opts.Out, "Successfully cloned tenant '%s' to '%s'.\n", tenant.Name, clonedTenant.Name)
103 if !opts.NoPrompt {
104 autoCmd := flag.GenerateAutomationCmd(opts.CmdPath, opts.GetSpaceNameOrEmpty(), opts.SourceTenant, opts.Name, opts.Description)
105 fmt.Fprintf(opts.Out, "\nAutomation Command: %s\n", autoCmd)
106 }
107
108 link := output.Bluef("%s/app#/%s/tenants/%s/overview", opts.Host, opts.Space.GetID(), clonedTenant.GetID())
109 fmt.Fprintf(opts.Out, "View this tenant on Octopus Deploy: %s\n", link)
110
111 return nil
112}
113
114func PromptMissing(opts *CloneOptions) error {
115 err := question.AskName(opts.Ask, "", "Tenant", &opts.Name.Value)

Callers 1

NewCmdCloneFunction · 0.70

Calls 4

GenerateAutomationCmdFunction · 0.92
BluefFunction · 0.92
GetSpaceNameOrEmptyMethod · 0.80
PromptMissingFunction · 0.70

Tested by

no test coverage detected