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

Merged
merged 16 commits into from
Jan 28, 2025

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 ready!

Name Link
🔨 Latest commit 960dc9f
🔍 Latest deploy log https://app.netlify.com/sites/zarf-docs/deploys/6798e8fe51da110007aeab75
😎 Deploy Preview https://deploy-preview-3416--zarf-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Great!

}

// 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]>
soltysh
soltysh previously approved these changes Jan 28, 2025
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

lgtm

@AustinAbro321 AustinAbro321 added this pull request to the merge queue Jan 28, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 28, 2025
Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

lgtm

@AustinAbro321 AustinAbro321 added this pull request to the merge queue Jan 28, 2025
Merged via the queue into main with commit 4b6e2b5 Jan 28, 2025
38 checks passed
@AustinAbro321 AustinAbro321 deleted the package-inspect-parent branch January 28, 2025 15:16
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