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: set annotations to generate additional bash completion information #2221

Merged
merged 1 commit into from Sep 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/cosign/cli/options/attach.go
Expand Up @@ -61,6 +61,7 @@ func (o *AttachSBOMOptions) AddFlags(cmd *cobra.Command) {

cmd.Flags().StringVar(&o.SBOM, "sbom", "",
"path to the sbom, or {-} for stdin")
_ = cmd.Flags().SetAnnotation("sbom", cobra.BashCompFilenameExt, []string{})

cmd.Flags().StringVar(&o.SBOMType, "type", "spdx",
"type of sbom (spdx|cyclonedx|syft)")
Expand Down
3 changes: 3 additions & 0 deletions cmd/cosign/cli/options/attest.go
Expand Up @@ -52,15 +52,18 @@ func (o *AttestOptions) AddFlags(cmd *cobra.Command) {

cmd.Flags().StringVar(&o.Key, "key", "",
"path to the private key file, KMS URI or Kubernetes Secret")
_ = cmd.Flags().SetAnnotation("key", cobra.BashCompFilenameExt, []string{"key"})

cmd.Flags().StringVar(&o.Cert, "certificate", "",
"path to the X.509 certificate in PEM format to include in the OCI Signature")
_ = cmd.Flags().SetAnnotation("certificate", cobra.BashCompFilenameExt, []string{"cert"})

cmd.Flags().StringVar(&o.CertChain, "certificate-chain", "",
"path to a list of CA X.509 certificates in PEM format which will be needed "+
"when building the certificate chain for the signing certificate. "+
"Must start with the parent intermediate CA certificate of the "+
"signing certificate and end with the root certificate. Included in the OCI Signature")
_ = cmd.Flags().SetAnnotation("certificate-chain", cobra.BashCompFilenameExt, []string{"cert"})

cmd.Flags().BoolVar(&o.NoUpload, "no-upload", false,
"do not upload the generated attestation")
Expand Down
2 changes: 2 additions & 0 deletions cmd/cosign/cli/options/certificate.go
Expand Up @@ -38,6 +38,7 @@ var _ Interface = (*RekorOptions)(nil)
func (o *CertVerifyOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&o.Cert, "certificate", "",
"path to the public certificate. The certificate will be verified against the Fulcio roots if the --certificate-chain option is not passed.")
_ = cmd.Flags().SetAnnotation("certificate", cobra.BashCompFilenameExt, []string{"cert"})

cmd.Flags().StringVar(&o.CertEmail, "certificate-email", "",
"the email expected in a valid Fulcio certificate")
Expand Down Expand Up @@ -67,6 +68,7 @@ func (o *CertVerifyOptions) AddFlags(cmd *cobra.Command) {
"when building the certificate chain for the signing certificate. "+
"Must start with the parent intermediate CA certificate of the "+
"signing certificate and end with the root certificate")
_ = cmd.Flags().SetAnnotation("certificate-chain", cobra.BashCompFilenameExt, []string{"cert"})

cmd.Flags().BoolVar(&o.EnforceSCT, "enforce-sct", false,
"whether to enforce that a certificate contain an embedded SCT, a proof of "+
Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/options/files.go
Expand Up @@ -54,4 +54,5 @@ func (o *FilesOptions) String() string {
func (o *FilesOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringSliceVarP(&o.Files, "files", "f", nil,
"<filepath>:[platform/arch]")
_ = cmd.Flags().SetAnnotation("files", cobra.BashCompFilenameExt, []string{})
}
1 change: 1 addition & 0 deletions cmd/cosign/cli/options/import_key_pair.go
Expand Up @@ -31,4 +31,5 @@ var _ Interface = (*ImportKeyPairOptions)(nil)
func (o *ImportKeyPairOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&o.Key, "key", "",
"import key pair to use for signing")
_ = cmd.Flags().SetAnnotation("key", cobra.BashCompFilenameExt, []string{})
}
1 change: 1 addition & 0 deletions cmd/cosign/cli/options/initialize.go
Expand Up @@ -35,4 +35,5 @@ func (o *InitializeOptions) AddFlags(cmd *cobra.Command) {

cmd.Flags().StringVar(&o.Root, "root", "",
"path to trusted initial root. defaults to embedded root")
_ = cmd.Flags().SetAnnotation("root", cobra.BashCompSubdirsInDir, []string{})
}
1 change: 1 addition & 0 deletions cmd/cosign/cli/options/load.go
Expand Up @@ -30,5 +30,6 @@ var _ Interface = (*LoadOptions)(nil)
func (o *LoadOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&o.Directory, "dir", "",
"path to directory where the signed image is stored on disk")
_ = cmd.Flags().SetAnnotation("dir", cobra.BashCompSubdirsInDir, []string{})
_ = cmd.MarkFlagRequired("dir")
}
1 change: 1 addition & 0 deletions cmd/cosign/cli/options/oidc.go
Expand Up @@ -64,6 +64,7 @@ func (o *OIDCOptions) AddFlags(cmd *cobra.Command) {

cmd.Flags().StringVar(&o.clientSecretFile, "oidc-client-secret-file", "",
"[EXPERIMENTAL] Path to file containing OIDC client secret for application")
_ = cmd.Flags().SetAnnotation("oidc-client-secret-file", cobra.BashCompFilenameExt, []string{})

cmd.Flags().StringVar(&o.RedirectURL, "oidc-redirect-url", "",
"[EXPERIMENTAL] OIDC redirect URL (Optional). The default oidc-redirect-url is 'http://localhost:0/auth/callback'.")
Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/options/pkcs11_tool.go
Expand Up @@ -45,6 +45,7 @@ var _ Interface = (*PKCS11ToolListKeysUrisOptions)(nil)
func (o *PKCS11ToolListKeysUrisOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&o.ModulePath, "module-path", "",
"absolute path to the PKCS11 module")
_ = cmd.Flags().SetAnnotation("module-path", cobra.BashCompFilenameExt, []string{})

cmd.Flags().UintVar(&o.SlotID, "slot-id", 0,
"id of the PKCS11 slot, uses 0 if empty")
Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/options/policy.go
Expand Up @@ -39,6 +39,7 @@ func (o *PolicyInitOptions) AddFlags(cmd *cobra.Command) {

cmd.Flags().StringVar(&o.OutFile, "out", "o",
"output policy locally")
_ = cmd.Flags().SetAnnotation("out", cobra.BashCompSubdirsInDir, []string{})

cmd.Flags().StringVar(&o.Issuer, "issuer", "",
"trusted issuer to use for identity tokens, e.g. https://accounts.google.com")
Expand Down
2 changes: 2 additions & 0 deletions cmd/cosign/cli/options/public_key.go
Expand Up @@ -34,7 +34,9 @@ func (o *PublicKeyOptions) AddFlags(cmd *cobra.Command) {

cmd.Flags().StringVar(&o.Key, "key", "",
"path to the private key file, KMS URI or Kubernetes Secret")
_ = cmd.Flags().SetAnnotation("key", cobra.BashCompFilenameExt, []string{})

cmd.Flags().StringVar(&o.OutFile, "outfile", "",
"path to a payload file to use rather than generating one")
_ = cmd.Flags().SetAnnotation("outfile", cobra.BashCompFilenameExt, []string{})
}
1 change: 1 addition & 0 deletions cmd/cosign/cli/options/root.go
Expand Up @@ -37,6 +37,7 @@ var _ Interface = (*RootOptions)(nil)
func (o *RootOptions) AddFlags(cmd *cobra.Command) {
cmd.PersistentFlags().StringVar(&o.OutputFile, "output-file", "",
"log output to a file")
_ = cmd.Flags().SetAnnotation("output-file", cobra.BashCompFilenameExt, []string{})

cmd.PersistentFlags().BoolVarP(&o.Verbose, "verbose", "d", false,
"log debug output")
Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/options/save.go
Expand Up @@ -30,5 +30,6 @@ var _ Interface = (*SaveOptions)(nil)
func (o *SaveOptions) AddFlags(cmd *cobra.Command) {
cmd.Flags().StringVar(&o.Directory, "dir", "",
"path to dir where the signed image should be stored on disk")
_ = cmd.Flags().SetAnnotation("dir", cobra.BashCompSubdirsInDir, []string{})
_ = cmd.MarkFlagRequired("dir")
}
6 changes: 6 additions & 0 deletions cmd/cosign/cli/options/sign.go
Expand Up @@ -56,27 +56,33 @@ func (o *SignOptions) AddFlags(cmd *cobra.Command) {

cmd.Flags().StringVar(&o.Key, "key", "",
"path to the private key file, KMS URI or Kubernetes Secret")
_ = cmd.Flags().SetAnnotation("key", cobra.BashCompFilenameExt, []string{})

cmd.Flags().StringVar(&o.Cert, "certificate", "",
"path to the X.509 certificate in PEM format to include in the OCI Signature")
_ = cmd.Flags().SetAnnotation("certificate", cobra.BashCompFilenameExt, []string{"cert"})

cmd.Flags().StringVar(&o.CertChain, "certificate-chain", "",
"path to a list of CA X.509 certificates in PEM format which will be needed "+
"when building the certificate chain for the signing certificate. "+
"Must start with the parent intermediate CA certificate of the "+
"signing certificate and end with the root certificate. Included in the OCI Signature")
_ = cmd.Flags().SetAnnotation("certificate-chain", cobra.BashCompFilenameExt, []string{"cert"})

cmd.Flags().BoolVar(&o.Upload, "upload", true,
"whether to upload the signature")

cmd.Flags().StringVar(&o.OutputSignature, "output-signature", "",
"write the signature to FILE")
_ = cmd.Flags().SetAnnotation("output-signature", cobra.BashCompFilenameExt, []string{})

cmd.Flags().StringVar(&o.OutputCertificate, "output-certificate", "",
"write the certificate to FILE")
_ = cmd.Flags().SetAnnotation("output-certificate", cobra.BashCompFilenameExt, []string{})

cmd.Flags().StringVar(&o.PayloadPath, "payload", "",
"path to a payload file to use rather than generating one")
_ = cmd.Flags().SetAnnotation("payload", cobra.BashCompFilenameExt, []string{})

cmd.Flags().BoolVarP(&o.Force, "force", "f", false,
"skip warnings and confirmations")
Expand Down
4 changes: 4 additions & 0 deletions cmd/cosign/cli/options/signblob.go
Expand Up @@ -48,21 +48,25 @@ func (o *SignBlobOptions) AddFlags(cmd *cobra.Command) {

cmd.Flags().StringVar(&o.Key, "key", "",
"path to the private key file, KMS URI or Kubernetes Secret")
_ = cmd.Flags().SetAnnotation("key", cobra.BashCompFilenameExt, []string{})

cmd.Flags().BoolVar(&o.Base64Output, "b64", true,
"whether to base64 encode the output")

cmd.Flags().StringVar(&o.OutputSignature, "output-signature", "",
"write the signature to FILE")
_ = cmd.Flags().SetAnnotation("output-signature", cobra.BashCompFilenameExt, []string{})

// TODO: remove when output flag is fully deprecated
cmd.Flags().StringVar(&o.Output, "output", "", "write the signature to FILE")

cmd.Flags().StringVar(&o.OutputCertificate, "output-certificate", "",
"write the certificate to FILE")
_ = cmd.Flags().SetAnnotation("key", cobra.BashCompFilenameExt, []string{})

cmd.Flags().StringVar(&o.BundlePath, "bundle", "",
"write everything required to verify the blob to a FILE")
_ = cmd.Flags().SetAnnotation("bundle", cobra.BashCompFilenameExt, []string{})

cmd.Flags().BoolVarP(&o.SkipConfirmation, "yes", "y", false,
"skip confirmation prompts for non-destructive operations")
Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/options/upload.go
Expand Up @@ -51,5 +51,6 @@ func (o *UploadWASMOptions) AddFlags(cmd *cobra.Command) {

cmd.Flags().StringVarP(&o.File, "file", "f", "",
"path to the wasm file to upload")
_ = cmd.Flags().SetAnnotation("file", cobra.BashCompFilenameExt, []string{})
_ = cmd.MarkFlagRequired("file")
}
1 change: 1 addition & 0 deletions cmd/cosign/cli/options/verify.go
Expand Up @@ -49,6 +49,7 @@ func (o *VerifyOptions) AddFlags(cmd *cobra.Command) {

cmd.Flags().StringVar(&o.Key, "key", "",
"path to the public key file, KMS URI or Kubernetes Secret")
_ = cmd.Flags().SetAnnotation("key", cobra.BashCompFilenameExt, []string{})

cmd.Flags().BoolVar(&o.CheckClaims, "check-claims", true,
"whether to check the claims found")
Expand Down