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: deprecate and replace zarf package inspect with child commands zarf package inspect definition|sbom|images #3416

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

AustinAbro321
Copy link
Contributor

@AustinAbro321 AustinAbro321 commented Jan 21, 2025

Description

feat: change zarf package inspect to a parent command, zarf package inspect definition|sbom|images

This also removes the ability to view SBOMs directly in browser with the --sbom flag

Related Issue

ZEP#9

Checklist before merging

Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
Copy link

netlify bot commented Jan 21, 2025

Deploy Preview for zarf-docs canceled.

Name Link
🔨 Latest commit 40581dc
🔍 Latest deploy log https://app.netlify.com/sites/zarf-docs/deploys/679137e399089c00087e4a60

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 0.75758% with 131 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/cmd/package.go 0.00% 130 Missing ⚠️
src/internal/packager2/remove.go 0.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/internal/packager2/load.go 57.14% <100.00%> (ø)
src/internal/packager2/remove.go 0.00% <0.00%> (ø)
src/cmd/package.go 0.00% <0.00%> (ø)

Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
@AustinAbro321 AustinAbro321 changed the title feat: change zarf package inspect to a parent command, zarf package inspect definition|sbom|images feat: replace zarf package inspect to a parent command, zarf package inspect definition|sbom|images Jan 21, 2025
@AustinAbro321 AustinAbro321 changed the title feat: replace zarf package inspect to a parent command, zarf package inspect definition|sbom|images feat: deprecate and replace zarf package inspect with child commands zarf package inspect definition|sbom|images Jan 21, 2025
@AustinAbro321 AustinAbro321 marked this pull request as ready for review January 21, 2025 20:52
@AustinAbro321 AustinAbro321 requested review from a team as code owners January 21, 2025 20:52
Signed-off-by: Austin Abro <[email protected]>
definitionOpts := PackageInspectDefinitionOptions{
SkipSignatureValidation: pkgConfig.PkgOpts.SkipSignatureValidation,
}
return definitionOpts.Run(cmd, args)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff 👍

RunE: o.Run,
}

cmd.Flags().BoolVar(&o.SkipSignatureValidation, "skip-signature-validation", false, lang.CmdPackageFlagSkipSignatureValidation)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't implemented that bit yet, but ideally you want to have NewPackageInspectSBOMOptions function which folks can invoke and get default options for a command. Then when you wire your flags here instead of providing defaults directly, you're just using the field from options struct.

A nice example of that is in kubectl api-resources command. Notice how NewAPIResourceOptions is passed with IO streams, and then each flag is automatically wired to the default value of a particular options.

The main benefit of such an approach is that you have only a single source of truth wrt defaults.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went ahead and implemented this

}

// NewPackageInspectSBOMCommand creates the `package inspect sbom` sub-command.
func NewPackageInspectSBOMCommand(v *viper.Viper) *cobra.Command {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as in #3413 about exporting these functions.

return err
}

cluster, _ := cluster.NewCluster() //nolint:errcheck
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whenever explicitly ignoring error it's good to explain why you're doing so. I'm guessing that since this is only showing the contents of the file we don't care about the error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We actually don't know at this point yet if a cluster is needed, which is why we avoid the error. Added context in comments

Signed-off-by: Austin Abro <[email protected]>
Signed-off-by: Austin Abro <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants