Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: filter package components with strategy interface #2321

Merged
merged 51 commits into from
Mar 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
f8875ec
copy filters over
Noxsios Feb 21, 2024
57fd951
more copying
Noxsios Feb 21, 2024
33cfd78
more copying
Noxsios Feb 21, 2024
3684b69
fixes from copy
Noxsios Feb 21, 2024
8f2e717
fix tests
Noxsios Feb 21, 2024
5d697d2
fix eks test
Noxsios Feb 21, 2024
fea6c6d
docs and schema
Noxsios Feb 21, 2024
34110ed
Merge branch 'main' into filter-strategy
Noxsios Feb 21, 2024
6d75f0f
Merge branch 'main' into filter-strategy
Noxsios Feb 21, 2024
e7b3949
go mod tidy
Noxsios Feb 21, 2024
b62265f
lint
Noxsios Feb 21, 2024
897b380
Merge branch 'main' into filter-strategy
Noxsios Feb 22, 2024
2ce99a4
Merge branch 'main' into filter-strategy
Racer159 Feb 23, 2024
0d2f951
Merge branch 'main' into filter-strategy
Feb 26, 2024
9cbff5b
Merge branch 'main' into filter-strategy
Feb 29, 2024
b1dfca1
Update src/pkg/packager/filters/deploy_test.go
Noxsios Mar 4, 2024
df6b5b2
update unit tests to be much better
Noxsios Mar 4, 2024
490e12c
dont mark required as deprecated yet, wait for the other PR
Noxsios Mar 4, 2024
e60976a
Merge branch 'main' into filter-strategy
Noxsios Mar 4, 2024
37bb092
fix compile error
Noxsios Mar 4, 2024
5d1ffbe
Merge branch 'main' into filter-strategy
Noxsios Mar 5, 2024
50714d3
no more config in interactive
Noxsios Mar 5, 2024
2f6b0f2
cleanup
Noxsios Mar 5, 2024
b6bccc7
Merge branch 'main' into filter-strategy
Noxsios Mar 7, 2024
a8fd62a
cleanup
Noxsios Mar 7, 2024
1dbe066
fix default behavior for interactive
Noxsios Mar 7, 2024
4f1469b
why do i do this to myself
Noxsios Mar 7, 2024
4fbe721
Merge branch 'main' into filter-strategy
Noxsios Mar 13, 2024
14a1a7c
delete again
Noxsios Mar 13, 2024
b14d96e
platform --> localOS due to filtering already occuring in compose
Noxsios Mar 13, 2024
2c9284a
fix create
Noxsios Mar 13, 2024
8337c90
changes from review
Noxsios Mar 13, 2024
f8fdd57
move reading zarf.yaml into sources where it belongs so we can do fil…
Noxsios Mar 13, 2024
89e5486
fix unit tests
Noxsios Mar 13, 2024
41907c8
docs and schema
Noxsios Mar 13, 2024
e6aaa10
lint
Noxsios Mar 14, 2024
f615c6c
lint
Noxsios Mar 14, 2024
be1f270
cleanup
Noxsios Mar 14, 2024
0fb6c94
changes from review
Noxsios Mar 14, 2024
f42f966
Merge branch 'main' into filter-strategy
Noxsios Mar 14, 2024
2517b19
fix test
Noxsios Mar 14, 2024
d58a945
add errors
Noxsios Mar 15, 2024
e052172
update unit tests
Noxsios Mar 15, 2024
42dce8a
Merge branch 'main' into filter-strategy
Noxsios Mar 15, 2024
7edf9d4
fix compile error
Noxsios Mar 15, 2024
b0613a1
cleanup
Noxsios Mar 18, 2024
45ec9b0
Merge branch 'main' into filter-strategy
Noxsios Mar 18, 2024
247d197
fix spinners + interactive
Noxsios Mar 19, 2024
5cbf584
messaging
Noxsios Mar 19, 2024
9a17833
Merge branch 'main' into filter-strategy
Noxsios Mar 19, 2024
eed0129
switch during deploy, not inside of sources
Noxsios Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
changes from review
Signed-off-by: razzle <[email protected]>
Noxsios committed Mar 14, 2024
commit 0fb6c944ab3db9d9da48decb63f423d084b4a330
9 changes: 8 additions & 1 deletion src/pkg/layout/package.go
Original file line number Diff line number Diff line change
@@ -169,13 +169,20 @@ func (pp *PackagePaths) IsLegacyLayout() bool {
}

// SignPackage signs the zarf.yaml in a Zarf package.
func (pp *PackagePaths) SignPackage(signingKeyPath, signingKeyPassword string) error {
func (pp *PackagePaths) SignPackage(signingKeyPath, signingKeyPassword string, isInteractive bool) error {
if signingKeyPath == "" {
return nil
}

pp.Signature = filepath.Join(pp.Base, Signature)

passwordFunc := func(_ bool) ([]byte, error) {
if signingKeyPassword != "" {
return []byte(signingKeyPassword), nil
}
if !isInteractive {
return nil, nil
}
return interactive.PromptSigPassword()
}
_, err := utils.CosignSignBlob(pp.ZarfYAML, pp.Signature, signingKeyPath, passwordFunc)
6 changes: 2 additions & 4 deletions src/pkg/packager/creator/normal.go
Original file line number Diff line number Diff line change
@@ -254,10 +254,8 @@ func (pc *PackageCreator) Output(dst *layout.PackagePaths, pkg *types.ZarfPackag
}

// Sign the package if a key has been provided
if pc.createOpts.SigningKeyPath != "" {
if err := dst.SignPackage(pc.createOpts.SigningKeyPath, pc.createOpts.SigningKeyPassword); err != nil {
return err
}
if err := dst.SignPackage(pc.createOpts.SigningKeyPath, pc.createOpts.SigningKeyPassword, !config.CommonOptions.Confirm); err != nil {
return err
}

// Create a remote ref + client for the package (if output is OCI)
10 changes: 2 additions & 8 deletions src/pkg/packager/creator/skeleton.go
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ import (
"strconv"
"strings"

"github.com/defenseunicorns/zarf/src/config"
"github.com/defenseunicorns/zarf/src/config/lang"
"github.com/defenseunicorns/zarf/src/extensions/bigbang"
"github.com/defenseunicorns/zarf/src/internal/packager/helm"
@@ -114,14 +115,7 @@ func (sc *SkeletonCreator) Output(dst *layout.PackagePaths, pkg *types.ZarfPacka
return fmt.Errorf("unable to write zarf.yaml: %w", err)
}

// Sign the package if a key has been provided
if sc.publishOpts.SigningKeyPath != "" {
if err := dst.SignPackage(sc.publishOpts.SigningKeyPath, sc.publishOpts.SigningKeyPassword); err != nil {
return err
}
}

return nil
return dst.SignPackage(sc.publishOpts.SigningKeyPath, sc.publishOpts.SigningKeyPassword, !config.CommonOptions.Confirm)
}

func (sc *SkeletonCreator) processExtensions(components []types.ZarfComponent, layout *layout.PackagePaths) (processedComponents []types.ZarfComponent, err error) {
5 changes: 0 additions & 5 deletions src/pkg/packager/deploy.go
Original file line number Diff line number Diff line change
@@ -71,11 +71,6 @@ func (p *Packager) Deploy() (err error) {
return fmt.Errorf("deployment cancelled")
}

p.cfg.Pkg.Components, err = filter.Apply(p.cfg.Pkg)
if err != nil {
return err
}

// Set variables and prompt if --confirm is not set
if err := variables.SetVariableMapInConfig(p.cfg); err != nil {
return err
6 changes: 2 additions & 4 deletions src/pkg/packager/publish.go
Original file line number Diff line number Diff line change
@@ -79,10 +79,8 @@ func (p *Packager) Publish() (err error) {
}

// Sign the package if a key has been provided
if p.cfg.PublishOpts.SigningKeyPath != "" {
if err := p.layout.SignPackage(p.cfg.PublishOpts.SigningKeyPath, p.cfg.PublishOpts.SigningKeyPassword); err != nil {
return err
}
if err := p.layout.SignPackage(p.cfg.PublishOpts.SigningKeyPath, p.cfg.PublishOpts.SigningKeyPassword, !config.CommonOptions.Confirm); err != nil {
return err
}
}

5 changes: 5 additions & 0 deletions src/pkg/packager/sources/oci.go
Original file line number Diff line number Diff line change
@@ -75,11 +75,16 @@ func (s *OCISource) LoadPackage(dst *layout.PackagePaths, filter filters.Compone
dst.SetFromLayers(layersFetched)

// if --confirm is not set, read the zarf.yaml that was pulled
// and apply the filter to the components
if !config.CommonOptions.Confirm {
pkg, warnings, err = dst.ReadZarfYAML()
if err != nil {
return pkg, nil, err
}
pkg.Components, err = filter.Apply(pkg)
if err != nil {
return pkg, nil, err
}
}

if err := dst.MigrateLegacy(); err != nil {