1
0
mirror of synced 2026-07-09 18:20:48 +00:00

Compare commits

...

4 Commits

Author SHA1 Message Date
Matheus Pimenta 16b08d136f Merge pull request #5983 from fluxcd/update-pkg-deps/main
Update fluxcd/pkg dependencies
2026-07-09 15:30:34 +01:00
matheuscscp 23727f7d76 Update fluxcd/pkg dependencies
Signed-off-by: GitHub <noreply@github.com>
2026-07-09 14:16:22 +00:00
Matheus Pimenta f0437e0a8c Merge pull request #5885 from ruslan-shaydullin/feat/add-ignore-paths-flag
Add --add-ignore-paths flag to artifact commands
2026-07-09 09:51:05 +01:00
Ruslan Shaydullin ddf3d9e835 Add --add-ignore-paths flag to artifact commands
The existing --ignore-paths flag replaces the built-in default exclude
list (VCS files and common ignored extensions), which forces users to
re-specify every default when they only need to add one extra pattern.

This change introduces --add-ignore-paths for push/build/diff artifact,
which appends its values to whichever ignore set is currently in effect
(defaults when --ignore-paths is omitted, or the user override when it
is provided). --ignore-paths semantics are unchanged.

Signed-off-by: Ruslan Shaydullin <shaydullin.r.d@outlook.com>
Assisted-by: claude-code/claude-opus-4-7
2026-07-09 13:33:20 +05:00
6 changed files with 87 additions and 11 deletions
+19 -1
View File
@@ -52,17 +52,35 @@ type buildArtifactFlags struct {
output string
path string
ignorePaths []string
addIgnorePaths []string
resolveSymlinks bool
}
var excludeOCI = append(strings.Split(sourceignore.ExcludeVCS, ","), strings.Split(sourceignore.ExcludeExt, ",")...)
// composeIgnorePaths returns the concatenation of two ignore-path slices,
// preserving order. It is used by build, push and diff artifact commands
// to combine --ignore-paths (which replaces the defaults) with
// --add-ignore-paths (which appends to whatever ignore set is currently
// in effect). Duplicate patterns are passed through unchanged since the
// underlying gitignore matcher treats redundant patterns as no-ops.
func composeIgnorePaths(ignorePaths, addIgnorePaths []string) []string {
if len(ignorePaths) == 0 && len(addIgnorePaths) == 0 {
return nil
}
result := make([]string, 0, len(ignorePaths)+len(addIgnorePaths))
result = append(result, ignorePaths...)
result = append(result, addIgnorePaths...)
return result
}
var buildArtifactArgs buildArtifactFlags
func init() {
buildArtifactCmd.Flags().StringVarP(&buildArtifactArgs.path, "path", "p", "", "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", excludeOCI, "set paths to ignore in .gitignore format")
buildArtifactCmd.Flags().StringSliceVar(&buildArtifactArgs.addIgnorePaths, "add-ignore-paths", nil, "additional paths to ignore in .gitignore format (appended to --ignore-paths)")
buildArtifactCmd.Flags().BoolVar(&buildArtifactArgs.resolveSymlinks, "resolve-symlinks", false, "resolve symlinks by copying their targets into the artifact")
buildCmd.AddCommand(buildArtifactCmd)
@@ -100,7 +118,7 @@ func buildArtifactCmdRun(cmd *cobra.Command, args []string) error {
logger.Actionf("building artifact from %s", path)
ociClient := oci.NewClient(oci.DefaultOptions())
if err := ociClient.Build(buildArtifactArgs.output, path, buildArtifactArgs.ignorePaths); err != nil {
if err := ociClient.Build(buildArtifactArgs.output, path, composeIgnorePaths(buildArtifactArgs.ignorePaths, buildArtifactArgs.addIgnorePaths)); err != nil {
return fmt.Errorf("building artifact failed, error: %w", err)
}
+54
View File
@@ -180,6 +180,60 @@ func Test_resolveSymlinks_cycle(t *testing.T) {
g.Expect(os.IsNotExist(err)).To(BeTrue())
}
func Test_composeIgnorePaths(t *testing.T) {
tests := []struct {
name string
ignorePaths []string
addIgnorePaths []string
want []string
}{
{
name: "both nil returns nil",
ignorePaths: nil,
addIgnorePaths: nil,
want: nil,
},
{
name: "only ignore-paths passes through",
ignorePaths: []string{"foo", "bar"},
addIgnorePaths: nil,
want: []string{"foo", "bar"},
},
{
name: "only add-ignore-paths passes through",
ignorePaths: nil,
addIgnorePaths: []string{"baz"},
want: []string{"baz"},
},
{
name: "both provided, order preserved",
ignorePaths: []string{"foo", "bar"},
addIgnorePaths: []string{"baz", "qux"},
want: []string{"foo", "bar", "baz", "qux"},
},
{
name: "duplicates retained as-is",
ignorePaths: []string{"foo", "bar"},
addIgnorePaths: []string{"foo"},
want: []string{"foo", "bar", "foo"},
},
{
name: "defaults plus add",
ignorePaths: excludeOCI,
addIgnorePaths: []string{"my-secrets/"},
want: append(append([]string{}, excludeOCI...), "my-secrets/"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)
got := composeIgnorePaths(tt.ignorePaths, tt.addIgnorePaths)
g.Expect(got).To(Equal(tt.want))
})
}
}
func Test_resolveSymlinks_multipleLinksSameTarget(t *testing.T) {
g := NewWithT(t)
+8 -6
View File
@@ -39,11 +39,12 @@ flux diff artifact oci://ghcr.io/stefanprodan/manifests:podinfo:6.2.0 --path=./k
}
type diffArtifactFlags struct {
path string
creds string
provider flags.SourceOCIProvider
ignorePaths []string
insecure bool
path string
creds string
provider flags.SourceOCIProvider
ignorePaths []string
addIgnorePaths []string
insecure bool
}
var diffArtifactArgs = newDiffArtifactArgs()
@@ -59,6 +60,7 @@ func init() {
diffArtifactCmd.Flags().StringVar(&diffArtifactArgs.creds, "creds", "", "credentials for OCI registry in the format <username>[:<password>] if --provider is generic")
diffArtifactCmd.Flags().Var(&diffArtifactArgs.provider, "provider", sourceOCIRepositoryArgs.provider.Description())
diffArtifactCmd.Flags().StringSliceVar(&diffArtifactArgs.ignorePaths, "ignore-paths", excludeOCI, "set paths to ignore in .gitignore format")
diffArtifactCmd.Flags().StringSliceVar(&diffArtifactArgs.addIgnorePaths, "add-ignore-paths", nil, "additional paths to ignore in .gitignore format (appended to --ignore-paths)")
diffArtifactCmd.Flags().BoolVar(&diffArtifactArgs.insecure, "insecure-registry", false, "allows the remote artifact to be pulled without TLS")
diffCmd.AddCommand(diffArtifactCmd)
}
@@ -109,7 +111,7 @@ func diffArtifactCmdRun(cmd *cobra.Command, args []string) error {
}
}
if err := ociClient.Diff(ctx, url, diffArtifactArgs.path, diffArtifactArgs.ignorePaths); err != nil {
if err := ociClient.Diff(ctx, url, diffArtifactArgs.path, composeIgnorePaths(diffArtifactArgs.ignorePaths, diffArtifactArgs.addIgnorePaths)); err != nil {
return err
}
+3 -1
View File
@@ -109,6 +109,7 @@ type pushArtifactFlags struct {
creds string
provider flags.SourceOCIProvider
ignorePaths []string
addIgnorePaths []string
annotations []string
output string
debug bool
@@ -132,6 +133,7 @@ func init() {
pushArtifactCmd.Flags().StringVar(&pushArtifactArgs.creds, "creds", "", "credentials for OCI registry in the format <username>[:<password>] if --provider is generic")
pushArtifactCmd.Flags().Var(&pushArtifactArgs.provider, "provider", pushArtifactArgs.provider.Description())
pushArtifactCmd.Flags().StringSliceVar(&pushArtifactArgs.ignorePaths, "ignore-paths", excludeOCI, "set paths to ignore in .gitignore format")
pushArtifactCmd.Flags().StringSliceVar(&pushArtifactArgs.addIgnorePaths, "add-ignore-paths", nil, "additional paths to ignore in .gitignore format (appended to --ignore-paths)")
pushArtifactCmd.Flags().StringArrayVarP(&pushArtifactArgs.annotations, "annotations", "a", nil, "Set custom OCI annotations in the format '<key>=<value>'")
pushArtifactCmd.Flags().StringVarP(&pushArtifactArgs.output, "output", "o", "",
"the format in which the artifact digest should be printed, can be 'json' or 'yaml'")
@@ -286,7 +288,7 @@ func pushArtifactCmdRun(cmd *cobra.Command, args []string) error {
ociClient := oci.NewClient(opts)
digestURL, err := ociClient.Push(ctx, url, path,
oci.WithPushMetadata(meta),
oci.WithPushIgnorePaths(pushArtifactArgs.ignorePaths...),
oci.WithPushIgnorePaths(composeIgnorePaths(pushArtifactArgs.ignorePaths, pushArtifactArgs.addIgnorePaths)...),
)
if err != nil {
return fmt.Errorf("pushing artifact failed: %w", err)
+1 -1
View File
@@ -24,7 +24,7 @@ require (
github.com/fluxcd/pkg/chartutil v1.28.0
github.com/fluxcd/pkg/envsubst v1.7.0
github.com/fluxcd/pkg/git v0.52.0
github.com/fluxcd/pkg/kustomize v1.37.0
github.com/fluxcd/pkg/kustomize v1.38.0
github.com/fluxcd/pkg/oci v0.68.0
github.com/fluxcd/pkg/runtime v0.111.0
github.com/fluxcd/pkg/sourceignore v0.18.0
+2 -2
View File
@@ -206,8 +206,8 @@ github.com/fluxcd/pkg/git v0.52.0 h1:dgsliHdaLADUcDO4pI0pc11N4dZ21NfDdhNcgRNuAkM
github.com/fluxcd/pkg/git v0.52.0/go.mod h1:mOvFDxoiuz+Mm4Ux1wKeTTckvBgZFvbTK8lNxmVHzKs=
github.com/fluxcd/pkg/gittestserver v0.29.0 h1:2j03zKVL6iVn6oiUuecG/O/3Q1pULWM9JrF/HSjkpnc=
github.com/fluxcd/pkg/gittestserver v0.29.0/go.mod h1:O8151jV0ppBZTb9IUXMjxh6hZpkiuLq8JQHDBPOkZFw=
github.com/fluxcd/pkg/kustomize v1.37.0 h1:vgUmoRJaC8kTgePaLCZd+S9bfJUVkDNx1pAUI1Kp5d0=
github.com/fluxcd/pkg/kustomize v1.37.0/go.mod h1:JTP6RWr9/ED89Y+7/shgndBj7g5Bzj200+1/glxx6LA=
github.com/fluxcd/pkg/kustomize v1.38.0 h1:95KIqpk3UBkxFNC1kCnqbawdiNAbgATVWE5THfbq7PY=
github.com/fluxcd/pkg/kustomize v1.38.0/go.mod h1:OCKAb5Tc0bFVpeclk/W0uWjjlB9dcLm/6XMvx69zu/4=
github.com/fluxcd/pkg/oci v0.68.0 h1:eykB9HrMGOmCTT6MSKRIBMxTiieBigah1wFedMMyhYM=
github.com/fluxcd/pkg/oci v0.68.0/go.mod h1:lNxvxqjGSGfEKI4Lnpj8mHTVDMy4Fdiico6Oml0tafU=
github.com/fluxcd/pkg/runtime v0.111.0 h1:nbmFuYstyN2a1SDW0SZU5dG9+9x+yDP4A39kKQKjj2A=