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

Function createRun

pkg/cmd/package/zip/create/create.go:45–93  ·  view source on GitHub ↗
(cmd *cobra.Command, opts *pack.PackageCreateOptions)

Source from the content-addressed store, hash-verified

43}
44
45func createRun(cmd *cobra.Command, opts *pack.PackageCreateOptions) error {
46 outputFormat, err := cmd.Flags().GetString(constants.FlagOutputFormat)
47 if err != nil { // should never happen, but fallback if it does
48 outputFormat = constants.OutputFormatTable
49 }
50
51 if !opts.NoPrompt {
52 if err := pack.PackageCreatePromptMissing(opts); err != nil {
53 return err
54 }
55 }
56
57 if opts.Id.Value == "" {
58 return errors.New("must supply a package ID")
59 }
60 applyDefaultsToUnspecifiedOptions(opts)
61
62 pack.VerboseOut(opts.Writer, opts.Verbose.Value, "Packing \"%s\" version \"%s\"...\n", opts.Id.Value, opts.Version.Value)
63
64 if !opts.NoPrompt {
65 autoCmd := flag.GenerateAutomationCmd(
66 opts.CmdPath, "",
67 opts.Id,
68 opts.Version,
69 opts.BasePath,
70 opts.OutFolder,
71 opts.Include,
72 opts.Verbose,
73 opts.Overwrite,
74 )
75 fmt.Fprintf(opts.Writer, "\nAutomation Command: %s\n", autoCmd)
76 }
77
78 outFilePath := pack.BuildOutFileName("zip", opts.Id.Value, opts.Version.Value)
79
80 zip, err := pack.BuildPackage(opts, outFilePath)
81 if zip != nil {
82 switch outputFormat {
83 case constants.OutputFormatBasic:
84 cmd.Printf("%s\n", zip.Name())
85 case constants.OutputFormatJson:
86 cmd.Printf(`{"Path":"%s"}`, zip.Name())
87 cmd.Println()
88 default: // table
89 cmd.Printf("Successfully created package %s\n", zip.Name())
90 }
91 }
92 return err
93}
94
95func applyDefaultsToUnspecifiedOptions(opts *pack.PackageCreateOptions) {
96 if opts.Version.Value == "" {

Callers 1

NewCmdCreateFunction · 0.70

Calls 2

GenerateAutomationCmdFunction · 0.92

Tested by

no test coverage detected