| 7 | ) |
| 8 | |
| 9 | func pkgPushCmd(buildCmd *cobra.Command) *cobra.Command { |
| 10 | cmd := &cobra.Command{ |
| 11 | Use: "push", |
| 12 | Short: "Alias for 'pkg build --push'", |
| 13 | Long: `Build and push an OCI package from a directory with a yaml configuration file. |
| 14 | 'path' specifies the path to the package source directory. |
| 15 | |
| 16 | The package may or may not be built first, depending on options |
| 17 | `, |
| 18 | Example: ` linuxkit pkg push [options] pkg/dir/`, |
| 19 | SuggestFor: []string{"build"}, |
| 20 | Args: cobra.MinimumNArgs(1), |
| 21 | Deprecated: "use 'pkg build --push' instead", |
| 22 | RunE: func(cmd *cobra.Command, args []string) error { |
| 23 | // Create a copy of buildCmd with push=true |
| 24 | if err := buildCmd.Flags().Set("push", "true"); err != nil { |
| 25 | return fmt.Errorf("'pkg push' unable to set 'pkg build --push': %w", err) |
| 26 | } |
| 27 | |
| 28 | // Pass the args to the build command |
| 29 | buildCmd.SetArgs(args) |
| 30 | return buildCmd.RunE(buildCmd, args) |
| 31 | }, |
| 32 | } |
| 33 | cmd.Flags().AddFlagSet(buildCmd.Flags()) |
| 34 | return cmd |
| 35 | } |