func NewPushCommand(ctx context.Context, logger *log.Logger) *cobra.Command {
	cmd := cobra.Command{
		Use:   "push <repository> [filepath]",
		Short: "Upload OPA bundles to an OCI registry",
		Long:  pushDesc,
		Args:  cobra.RangeArgs(1, 2),

		RunE: func(cmd *cobra.Command, args []string) error {
			var path string
			if len(args) == 2 {
				path = args[1]
			} else {
				var err error
				path, err = os.Getwd()
				if err != nil {
					return fmt.Errorf("get working directory: %w", err)
				}
			}

			repository := args[0]

			logger.Printf("pushing bundle to: %s\n", repository)
			manifest, err := pushBundle(ctx, repository, path)
			if err != nil {
				return fmt.Errorf("push bundle: %w", err)
			}
			logger.Printf("pushed bundle with digest: %s\n", manifest.Digest)

			return nil
		},
	}

	return &cmd
}
// NewPushCommand creates a new push command which allows users to push
// bundles to an OCI registry
NewPushCommand creates a new push command which allows users to push
bundles to an OCI registry
// NewPushCommand creates a new push command which allows users to push // bundles to an OCI registry
func NewPushCommand(ctx context.Context, logger *log.Logger) *cobra.Command {
	cmd := cobra.Command{
		Use:   "push <repository> [filepath]",
		Short: "Upload OPA bundles to an OCI registry",
		Long:  pushDesc,
		Args:  cobra.RangeArgs(1, 2),
		RunE: func(cmd *cobra.Command, args []string) error {
			var path string
			if len(args) == 2 {
				path = args[1]
			} else {
				var err error
				path, err = os.Getwd()
				if err != nil {
					return fmt.Errorf("get working directory: %w", err)
				}
			}
			repository := args[0]
			logger.Printf("pushing bundle to: %s\n", repository)
			manifest, err := pushBundle(ctx, repository, path)
			if err != nil {
				return fmt.Errorf("push bundle: %w", err)
			}
			logger.Printf("pushed bundle with digest: %s\n", manifest.Digest)
			return nil
		},
	}
	return &cmd
}
func NewPushCommand ( ctx context . Context , logger * log . Logger ) * cobra . Command { cmd := cobra . Command { Use : " " , Short : " " , Long : pushDesc , Args : cobra . RangeArgs ( 1 , 2 ) , RunE : func ( cmd * cobra . Command , args [ ] string ) error { var path string if len ( args ) == 2 { path = args [ 1 ] } else { var err error path , err = os . Getwd ( ) if err != nil { return fmt . Errorf ( " " , err ) } } repository := args [ 0 ] logger . Printf ( " \n " , repository ) manifest , err := pushBundle ( ctx , repository , path ) if err != nil { return fmt . Errorf ( " " , err ) } logger . Printf ( " \n " , manifest . Digest ) return nil } , } return & cmd }
NewPushCommand creates a new push command which allows users to push
bundles to an OCI registry
NewPushCommand creates a new push command which allows users to push bundles to an OCI registry