Skip to content

Commit ffeb8e1

Browse files
committed
Fixed value set completion improvements
Signed-off-by: Ville Skyttä <[email protected]>
1 parent abd2ef0 commit ffeb8e1

File tree

8 files changed

+32
-13
lines changed

8 files changed

+32
-13
lines changed

cmd/cosign/cli/options/attach.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,15 @@ func (o *AttachSBOMOptions) AddFlags(cmd *cobra.Command) {
8282
"path to the sbom, or {-} for stdin")
8383
_ = cmd.MarkFlagFilename("sbom", sbomExts...)
8484

85-
cmd.Flags().StringVar(&o.SBOMType, "type", "spdx",
86-
"type of sbom (spdx|cyclonedx|syft)")
85+
sbomTypes := []string{"spdx", "cyclonedx", "syft"}
86+
cmd.Flags().StringVar(&o.SBOMType, "type", sbomTypes[0],
87+
"type of sbom ("+strings.Join(sbomTypes, "|")+")")
88+
_ = cmd.RegisterFlagCompletionFunc("type", cobra.FixedCompletions(sbomTypes, cobra.ShellCompDirectiveNoFileComp))
8789

90+
inputFormats := []string{ctypes.JSONInputFormat, ctypes.XMLInputFormat, ctypes.TextInputFormat}
8891
cmd.Flags().StringVar(&o.SBOMInputFormat, "input-format", "",
89-
"type of sbom input format (json|xml|text)")
92+
"type of sbom input format ("+strings.Join(inputFormats, "|")+")")
93+
_ = cmd.RegisterFlagCompletionFunc("input-format", cobra.FixedCompletions(inputFormats, cobra.ShellCompDirectiveNoFileComp))
9094
}
9195

9296
func (o *AttachSBOMOptions) MediaType() (types.MediaType, error) {

cmd/cosign/cli/options/attest.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package options
1717

1818
import (
19+
"strings"
20+
1921
"github.com/spf13/cobra"
2022
)
2123

@@ -87,8 +89,9 @@ func (o *AttestOptions) AddFlags(cmd *cobra.Command) {
8789
cmd.Flags().BoolVar(&o.TlogUpload, "tlog-upload", true,
8890
"whether or not to upload to the tlog")
8991

90-
cmd.Flags().StringVar(&o.RekorEntryType, "rekor-entry-type", "dsse",
91-
"specifies the type to be used for a rekor entry upload. Options are intoto or dsse (default). ")
92+
cmd.Flags().StringVar(&o.RekorEntryType, "rekor-entry-type", rekorEntryTypes[0],
93+
"specifies the type to be used for a rekor entry upload ("+strings.Join(rekorEntryTypes, "|")+")")
94+
_ = cmd.RegisterFlagCompletionFunc("rekor-entry-type", cobra.FixedCompletions(rekorEntryTypes, cobra.ShellCompDirectiveNoFileComp))
9295

9396
cmd.Flags().StringVar(&o.TSAClientCACert, "timestamp-client-cacert", "",
9497
"path to the X.509 CA certificate file in PEM format to be used for the connection to the TSA Server")

cmd/cosign/cli/options/attest_blob.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
package options
1616

1717
import (
18+
"strings"
19+
1820
"github.com/spf13/cobra"
1921
)
2022

@@ -105,8 +107,9 @@ func (o *AttestBlobOptions) AddFlags(cmd *cobra.Command) {
105107
cmd.Flags().BoolVar(&o.TlogUpload, "tlog-upload", true,
106108
"whether or not to upload to the tlog")
107109

108-
cmd.Flags().StringVar(&o.RekorEntryType, "rekor-entry-type", "dsse",
109-
"specifies the type to be used for a rekor entry upload. Options are intoto or dsse (default). ")
110+
cmd.Flags().StringVar(&o.RekorEntryType, "rekor-entry-type", rekorEntryTypes[0],
111+
"specifies the type to be used for a rekor entry upload ("+strings.Join(rekorEntryTypes, "|")+")")
112+
_ = cmd.RegisterFlagCompletionFunc("rekor-entry-type", cobra.FixedCompletions(rekorEntryTypes, cobra.ShellCompDirectiveNoFileComp))
110113

111114
cmd.Flags().StringVar(&o.TSAClientCACert, "timestamp-client-cacert", "",
112115
"path to the X.509 CA certificate file in PEM format to be used for the connection to the TSA Server")

cmd/cosign/cli/options/bundle.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package options
1717

1818
import (
19+
"strings"
20+
1921
"github.com/spf13/cobra"
2022
)
2123

@@ -79,9 +81,11 @@ func (o *BundleCreateOptions) AddFlags(cmd *cobra.Command) {
7981
cmd.Flags().BoolVar(&o.Sk, "sk", false,
8082
"whether to use a hardware security key")
8183

82-
cmd.Flags().StringVar(&o.Slot, "slot", "",
83-
"security key slot to use for generated key (default: signature) "+
84-
"(authentication|signature|card-authentication|key-management)")
84+
slots := []string{"authentication", "signature", "card-authentication", "key-management"}
85+
cmd.Flags().StringVar(&o.Slot, "slot", "signature",
86+
"security key slot to use for generated key ("+
87+
strings.Join(slots, "|")+")")
88+
_ = cmd.RegisterFlagCompletionFunc("slot", cobra.FixedCompletions(slots, cobra.ShellCompDirectiveNoFileComp))
8589

8690
cmd.MarkFlagsMutuallyExclusive("bundle", "certificate")
8791
cmd.MarkFlagsMutuallyExclusive("bundle", "signature")

cmd/cosign/cli/options/options.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,8 @@ var signatureExts = []string{
5555
var wasmExts = []string{
5656
"wasm",
5757
}
58+
59+
var rekorEntryTypes = []string{
60+
"dsse", // first one is the default
61+
"intoto",
62+
}

doc/cosign_attest-blob.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/cosign_attest.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

doc/cosign_bundle_create.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)