-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance artifact pull and push commands (#112)
* Rename GetCreds() to GenerateCraneOptions(), check for oci urls for 'oci://' prefix - Users can now pass Registry Tokens as credential while using pull/push commands. - OCI URLs need to provided prefixed with 'oci://' to differenciate between HTTP and OCI operations. - Implementation of exponential retry logic while pulling and pushing from registries. - Update OCI urls for pulling deault policies for Rego validation. Signed-off-by: Santosh <ksantosh@intelops.dev> * Add completion command Signed-off-by: Santosh <ksantosh@intelops.dev> * Add Rego validation for Dockerfiles with policies stored in OCI registries Signed-off-by: Santosh <ksantosh@intelops.dev> * Fix: lint errors Signed-off-by: santoshkal <ksantosh@intelops.dev> * Fix: lint errors Signed-off-by: santoshkal <ksantosh@intelops.dev> * Update: accept Rego policies from oci registries Signed-off-by: santoshkal <ksantosh@intelops.dev> * Add examples in commands and fix typos Signed-off-by: santoshkal <ksantosh@intelops.dev> * Update: validate with default policies and policies stored in OCI registries for dockerfile command Signed-off-by: santoshkal <ksantosh@intelops.dev> * Refactor conditional logic to accept default Rego policies and Rego policies from OCI registries for all Rego commands Signed-off-by: santoshkal <ksantosh@intelops.dev> * Refactor Auth and OCI Push Options in ociClient pkg - Move out auth related logic to its own GetCreds(). - Now, users can pass creds through --credentials flag - accepts auth in <$USER:$PAT> or <$TOKEN> format - If none provided falls back to /home/santosh/.docker/config.json - Updated examples for all commands for using default policies and policies from OCI registries Signed-off-by: santoshkal <ksantosh@intelops.dev> * Update: Reading of OCI URLs for cuemods from a const instead of a .env file This behaviour is for testing the commands and would be updated to read the URLs for all commands from a .env file stored in a repo Signed-off-by: santoshkal <ksantosh@intelops.dev> * Update retry logic in GenerateCraneOptions() in line with go-containerregistry Signed-off-by: santoshkal <ksantosh@intelops.dev> * Update README about new workflows of validating iwth default policies and policies from OCI registries Signed-off-by: santoshkal <ksantosh@intelops.dev> * Update rootCmd for supressing the usage info printed with errors Signed-off-by: santoshkal <ksantosh@intelops.dev> * Fix changelog printing for releases in goreleaser Signed-off-by: santoshkal <ksantosh@intelops.dev> --------- Signed-off-by: Santosh <ksantosh@intelops.dev> Signed-off-by: santoshkal <ksantosh@intelops.dev>
- Loading branch information
1 parent
ce9bc91
commit dd7f5e3
Showing
20 changed files
with
504 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
Copyright © 2024 NAME HERE <EMAIL ADDRESS> | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var completionCmd = &cobra.Command{ | ||
Use: "completion [bash|zsh|fish|powershell]", | ||
Short: "Generate completion script", | ||
Long: fmt.Sprintf(`To load completions: | ||
Bash: | ||
$ source <(%[1]s completion bash) | ||
# To load completions for each session, execute once: | ||
# Linux: | ||
$ %[1]s completion bash > /etc/bash_completion.d/%[1]s | ||
# macOS: | ||
$ %[1]s completion bash > $(brew --prefix)/etc/bash_completion.d/%[1]s | ||
Zsh: | ||
# If shell completion is not already enabled in your environment, | ||
# you will need to enable it. You can execute the following once: | ||
$ echo "autoload -U compinit; compinit" >> ~/.zshrc | ||
# To load completions for each session, execute once: | ||
$ %[1]s completion zsh > "${fpath[1]}/_%[1]s" | ||
# You will need to start a new shell for this setup to take effect. | ||
fish: | ||
$ %[1]s completion fish | source | ||
# To load completions for each session, execute once: | ||
$ %[1]s completion fish > ~/.config/fish/completions/%[1]s.fish | ||
PowerShell: | ||
PS> %[1]s completion powershell | Out-String | Invoke-Expression | ||
# To load completions for every new session, run: | ||
PS> %[1]s completion powershell > %[1]s.ps1 | ||
# and source this file from your PowerShell profile. | ||
`, rootCmd.Name()), | ||
DisableFlagsInUseLine: true, | ||
ValidArgs: []string{"bash", "zsh", "fish", "powershell"}, | ||
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if len(args) == 0 { | ||
log.Error("No shell specified") | ||
} | ||
var err error | ||
switch args[0] { | ||
case "bash": | ||
err = rootCmd.GenBashCompletion(os.Stdout) | ||
case "zsh": | ||
err = rootCmd.GenZshCompletion(os.Stdout) | ||
case "fish": | ||
err = rootCmd.GenFishCompletion(os.Stdout, true) | ||
case "powershell": | ||
err = rootCmd.GenPowerShellCompletionWithDesc(os.Stdout) | ||
default: | ||
log.Printf("Unknown shell: %s", args[0]) | ||
return | ||
} | ||
if err != nil { | ||
log.Printf("Error generating completion for %s: %v", args[0], err) | ||
return | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(completionCmd) | ||
} |
Oops, something went wrong.