1
0
mirror of synced 2026-02-13 13:06:56 +00:00

Add --ignore-paths arg to flux build|push artifact

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
This commit is contained in:
Stefan Prodan
2022-08-16 15:31:39 +03:00
parent 02b38ac8e0
commit 899a1fffca
4 changed files with 25 additions and 11 deletions

View File

@@ -19,10 +19,12 @@ package main
import (
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
oci "github.com/fluxcd/pkg/oci/client"
"github.com/fluxcd/pkg/sourceignore"
)
var buildArtifactCmd = &cobra.Command{
@@ -39,8 +41,9 @@ var buildArtifactCmd = &cobra.Command{
}
type buildArtifactFlags struct {
output string
path string
output string
path string
ignorePaths []string
}
var buildArtifactArgs buildArtifactFlags
@@ -48,6 +51,8 @@ var buildArtifactArgs buildArtifactFlags
func init() {
buildArtifactCmd.Flags().StringVar(&buildArtifactArgs.path, "path", "", "Path to the directory where the Kubernetes manifests are located.")
buildArtifactCmd.Flags().StringVarP(&buildArtifactArgs.output, "output", "o", "artifact.tgz", "Path to where the artifact tgz file should be written.")
buildArtifactCmd.Flags().StringSliceVar(&buildArtifactArgs.ignorePaths, "ignore-paths", strings.Split(sourceignore.ExcludeVCS, ","), "set paths to ignore (can specify multiple paths with commas: path1,path2)")
buildCmd.AddCommand(buildArtifactCmd)
}
@@ -63,7 +68,8 @@ func buildArtifactCmdRun(cmd *cobra.Command, args []string) error {
logger.Actionf("building artifact from %s", buildArtifactArgs.path)
ociClient := oci.NewLocalClient()
if err := ociClient.Build(buildArtifactArgs.output, buildArtifactArgs.path); err != nil {
logger.Successf("%v", buildArtifactArgs.ignorePaths)
if err := ociClient.Build(buildArtifactArgs.output, buildArtifactArgs.path, buildArtifactArgs.ignorePaths); err != nil {
return fmt.Errorf("bulding artifact failed, error: %w", err)
}