Skip to content

Commit

Permalink
update fingerprint docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sami-alajrami committed Jul 3, 2024
1 parent 3785f1e commit 1d81132
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
25 changes: 20 additions & 5 deletions cmd/kosli/fingerprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const fingerprintShortDesc = `Calculate the SHA256 fingerprint of an artifact.`

const fingerprintDirSynopsis = `When fingerprinting a 'dir' artifact, you can exclude certain paths from fingerprint calculation
using the ^--exclude^ flag.
Excluded paths are relative to the artifact path(s) and can be literal paths or
Excluded paths are relative to the DIR-PATH and can be literal paths or
glob patterns.
The supported glob pattern syntax is what is documented here: https://pkg.go.dev/path/filepath#Match ,
plus the ability to use recursive globs "**"`
Expand All @@ -24,6 +24,20 @@ from a remote registry.
` + fingerprintDirSynopsis

const fingerprintExamples = `
# fingerprint a file
kosli fingerprint --artifact-type file file.txt
# fingerprint a dir
kosli fingerprint --artifact-type dir mydir
# fingerprint a dir while excluding paths
kosli fingerprint --artifact-type dir --exclude logs --exclude *.exe mydir
# fingerprint a locally available docker image
kosli fingerprint --artifact-type docker nginx:latest
`

type fingerprintOptions struct {
artifactType string
registryProvider string
Expand All @@ -35,10 +49,11 @@ type fingerprintOptions struct {
func newFingerprintCmd(out io.Writer) *cobra.Command {
o := new(fingerprintOptions)
cmd := &cobra.Command{
Use: "fingerprint {IMAGE-NAME | FILE-PATH | DIR-PATH}",
Short: fingerprintShortDesc,
Long: fingerprintLongDesc,
Args: cobra.ExactArgs(1),
Use: "fingerprint {IMAGE-NAME | FILE-PATH | DIR-PATH}",
Short: fingerprintShortDesc,
Long: fingerprintLongDesc,
Example: fingerprintExamples,
Args: cobra.ExactArgs(1),
PreRunE: func(cmd *cobra.Command, args []string) error {
return ValidateRegistryFlags(cmd, o)
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/kosli/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ The service principal needs to have the following permissions:
maxAPIRetryFlag = "[defaulted] How many times should API calls be retried when the API host is not reachable."
configFileFlag = "[optional] The Kosli config file path."
debugFlag = "[optional] Print debug logs to stdout. A boolean flag https://docs.kosli.com/faq/#boolean-flags (default false)"
artifactTypeFlag = "[conditional] The type of the artifact to calculate its SHA256 fingerprint. One of: [docker, file, dir]. Only required if you don't specify '--fingerprint'."
artifactTypeFlag = "The type of the artifact to calculate its SHA256 fingerprint. One of: [docker, file, dir]. Only required if you want Kosli to calculate the fingerprint for you (i.e. when you don't specify '--fingerprint' on commands that allow it)"
flowNameFlag = "The Kosli flow name."
trailNameFlag = "The Kosli trail name."
trailNameFlagOptional = "[optional] The Kosli trail name."
Expand Down

0 comments on commit 1d81132

Please sign in to comment.