|
|
|
@ -20,10 +20,12 @@ import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
|
|
|
|
"os"
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
|
|
|
|
|
|
oci "github.com/fluxcd/pkg/oci/client"
|
|
|
|
|
"github.com/fluxcd/pkg/sourceignore"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var pushArtifactCmd = &cobra.Command{
|
|
|
|
@ -49,9 +51,10 @@ The command uses the credentials from '~/.docker/config.json'.`,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type pushArtifactFlags struct {
|
|
|
|
|
path string
|
|
|
|
|
source string
|
|
|
|
|
revision string
|
|
|
|
|
path string
|
|
|
|
|
source string
|
|
|
|
|
revision string
|
|
|
|
|
ignorePaths []string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var pushArtifactArgs pushArtifactFlags
|
|
|
|
@ -60,6 +63,8 @@ func init() {
|
|
|
|
|
pushArtifactCmd.Flags().StringVar(&pushArtifactArgs.path, "path", "", "path to the directory where the Kubernetes manifests are located")
|
|
|
|
|
pushArtifactCmd.Flags().StringVar(&pushArtifactArgs.source, "source", "", "the source address, e.g. the Git URL")
|
|
|
|
|
pushArtifactCmd.Flags().StringVar(&pushArtifactArgs.revision, "revision", "", "the source revision in the format '<branch|tag>/<commit-sha>'")
|
|
|
|
|
pushArtifactCmd.Flags().StringSliceVar(&pushArtifactArgs.ignorePaths, "ignore-paths", strings.Split(sourceignore.ExcludeVCS, ","), "set paths to ignore (can specify multiple paths with commas: path1,path2)")
|
|
|
|
|
|
|
|
|
|
pushCmd.AddCommand(pushArtifactCmd)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -101,7 +106,7 @@ func pushArtifactCmdRun(cmd *cobra.Command, args []string) error {
|
|
|
|
|
|
|
|
|
|
logger.Actionf("pushing artifact to %s", url)
|
|
|
|
|
|
|
|
|
|
digest, err := ociClient.Push(ctx, url, pushArtifactArgs.path, meta)
|
|
|
|
|
digest, err := ociClient.Push(ctx, url, pushArtifactArgs.path, meta, pushArtifactArgs.ignorePaths)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return fmt.Errorf("pushing artifact failed: %w", err)
|
|
|
|
|
}
|
|
|
|
@ -109,5 +114,4 @@ func pushArtifactCmdRun(cmd *cobra.Command, args []string) error {
|
|
|
|
|
logger.Successf("artifact successfully pushed to %s", digest)
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|