mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
feat(cli): Add support for Source Integrity configuration (#26997)
Signed-off-by: Oliver Gondža <[email protected]>
This commit is contained in:
@@ -36,6 +36,9 @@ packages:
|
||||
interfaces:
|
||||
ClusterServiceClient: {}
|
||||
ClusterServiceServer: {}
|
||||
github.com/argoproj/argo-cd/v3/pkg/apiclient/gpgkey:
|
||||
interfaces:
|
||||
GPGKeyServiceClient: {}
|
||||
github.com/argoproj/argo-cd/v3/pkg/apiclient/project:
|
||||
interfaces:
|
||||
ProjectServiceClient: {}
|
||||
|
||||
@@ -35,7 +35,7 @@ func NewDefaultPluginHandler() *DefaultPluginHandler {
|
||||
// HandleCommandExecutionError processes the error returned from executing the command.
|
||||
// It handles both standard Argo CD commands and plugin commands. We don't require returning
|
||||
// an error, but we are doing it to cover various test scenarios.
|
||||
func (h *DefaultPluginHandler) HandleCommandExecutionError(err error, isArgocdCLI bool, args []string) error {
|
||||
func (h *DefaultPluginHandler) HandleCommandExecutionError(err error, isArgocdCLI bool, args []string) (msg string, retErr error) {
|
||||
// the log level needs to be setup manually here since the initConfig()
|
||||
// set by the cobra.OnInitialize() was never executed because cmd.Execute()
|
||||
// gave us a non-nil error.
|
||||
@@ -51,19 +51,16 @@ func (h *DefaultPluginHandler) HandleCommandExecutionError(err error, isArgocdCL
|
||||
// This means the command is neither a normal Argo CD Command nor a plugin.
|
||||
if pluginErr != nil {
|
||||
// If plugin handling fails, report the plugin error and exit
|
||||
fmt.Printf("Error: %v\n", pluginErr)
|
||||
return pluginErr
|
||||
return fmt.Sprintf("Error: %v\n", pluginErr), pluginErr
|
||||
} else if pluginPath == "" {
|
||||
fmt.Printf("Error: %v\nRun 'argocd --help' for usage.\n", err)
|
||||
return err
|
||||
return fmt.Sprintf("Error: %v\nRun 'argocd --help' for usage.\n", err), err
|
||||
}
|
||||
} else {
|
||||
// If it's any other error (not an unknown command), report it directly and exit
|
||||
fmt.Printf("Error: %v\n", err)
|
||||
return err
|
||||
return fmt.Sprintf("Error: %v\n", err), err
|
||||
}
|
||||
|
||||
return nil
|
||||
return "", nil
|
||||
}
|
||||
|
||||
// handlePluginCommand is responsible for finding and executing a plugin when a command isn't recognized as a built-in command
|
||||
|
||||
@@ -3,6 +3,7 @@ package commands
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -87,10 +88,11 @@ func TestPluginExecution(t *testing.T) {
|
||||
require.Error(t, err)
|
||||
|
||||
// since the command is not a valid argocd command, check for plugin execution
|
||||
pluginErr := pluginHandler.HandleCommandExecutionError(err, true, tt.args)
|
||||
errMsg, pluginErr := pluginHandler.HandleCommandExecutionError(err, true, tt.args)
|
||||
if tt.expectedPluginErr == "" {
|
||||
require.NoError(t, pluginErr)
|
||||
} else {
|
||||
assert.Equal(t, errMsg, fmt.Sprintf("Error: %s\nRun 'argocd --help' for usage.\n", tt.expectedPluginErr))
|
||||
require.EqualError(t, pluginErr, tt.expectedPluginErr)
|
||||
}
|
||||
})
|
||||
@@ -111,8 +113,10 @@ func TestNormalCommandError(t *testing.T) {
|
||||
err := cmd.Execute()
|
||||
require.Error(t, err)
|
||||
|
||||
pluginErr := pluginHandler.HandleCommandExecutionError(err, true, args)
|
||||
assert.EqualError(t, pluginErr, "unknown flag: --non-existent-flag")
|
||||
errMsg, pluginErr := pluginHandler.HandleCommandExecutionError(err, true, args)
|
||||
require.Error(t, pluginErr)
|
||||
assert.Equal(t, "Error: unknown flag: --non-existent-flag\n", errMsg)
|
||||
require.EqualError(t, pluginErr, "unknown flag: --non-existent-flag")
|
||||
}
|
||||
|
||||
// TestUnknownCommandNoPlugin tests the scenario when the command is neither a normal ArgoCD command
|
||||
@@ -128,9 +132,10 @@ func TestUnknownCommandNoPlugin(t *testing.T) {
|
||||
err := cmd.Execute()
|
||||
require.Error(t, err)
|
||||
|
||||
pluginErr := pluginHandler.HandleCommandExecutionError(err, true, args)
|
||||
errMsg, pluginErr := pluginHandler.HandleCommandExecutionError(err, true, args)
|
||||
require.Error(t, pluginErr)
|
||||
assert.Equal(t, err, pluginErr)
|
||||
assert.Equal(t, "Error: unknown command \"non-existent\" for \"argocd\"\nRun 'argocd --help' for usage.\n", errMsg)
|
||||
require.EqualError(t, pluginErr, "unknown command \"non-existent\" for \"argocd\"")
|
||||
}
|
||||
|
||||
// TestPluginNoExecutePermission verifies the behavior when a plugin doesn't have executable permissions
|
||||
@@ -147,9 +152,10 @@ func TestPluginNoExecutePermission(t *testing.T) {
|
||||
err := cmd.Execute()
|
||||
require.Error(t, err)
|
||||
|
||||
pluginErr := pluginHandler.HandleCommandExecutionError(err, true, args)
|
||||
errMsg, pluginErr := pluginHandler.HandleCommandExecutionError(err, true, args)
|
||||
require.Error(t, pluginErr)
|
||||
assert.EqualError(t, pluginErr, "unknown command \"no-permission\" for \"argocd\"")
|
||||
assert.Equal(t, "Error: unknown command \"no-permission\" for \"argocd\"\nRun 'argocd --help' for usage.\n", errMsg)
|
||||
require.EqualError(t, pluginErr, "unknown command \"no-permission\" for \"argocd\"")
|
||||
}
|
||||
|
||||
// TestPluginExecutionError checks for errors that occur during plugin execution
|
||||
@@ -166,9 +172,10 @@ func TestPluginExecutionError(t *testing.T) {
|
||||
err := cmd.Execute()
|
||||
require.Error(t, err)
|
||||
|
||||
pluginErr := pluginHandler.HandleCommandExecutionError(err, true, args)
|
||||
errMsg, pluginErr := pluginHandler.HandleCommandExecutionError(err, true, args)
|
||||
require.Error(t, pluginErr)
|
||||
assert.EqualError(t, pluginErr, "exit status 1")
|
||||
assert.Equal(t, "Error: exit status 1\n", errMsg)
|
||||
require.EqualError(t, pluginErr, "exit status 1")
|
||||
}
|
||||
|
||||
// TestPluginInRelativePathIgnored ensures that plugins in a relative path, even if the path is included in PATH,
|
||||
@@ -197,9 +204,10 @@ func TestPluginInRelativePathIgnored(t *testing.T) {
|
||||
err = cmd.Execute()
|
||||
require.Error(t, err)
|
||||
|
||||
pluginErr := pluginHandler.HandleCommandExecutionError(err, true, args)
|
||||
errMsg, pluginErr := pluginHandler.HandleCommandExecutionError(err, true, args)
|
||||
require.Error(t, pluginErr)
|
||||
assert.EqualError(t, pluginErr, "unknown command \"ignore-plugin\" for \"argocd\"")
|
||||
assert.Equal(t, "Error: unknown command \"ignore-plugin\" for \"argocd\"\nRun 'argocd --help' for usage.\n", errMsg)
|
||||
require.EqualError(t, pluginErr, "unknown command \"ignore-plugin\" for \"argocd\"")
|
||||
}
|
||||
|
||||
// TestPluginFlagParsing checks that the flags are parsed correctly by the plugin handler
|
||||
@@ -239,12 +247,14 @@ func TestPluginFlagParsing(t *testing.T) {
|
||||
err := cmd.Execute()
|
||||
require.Error(t, err)
|
||||
|
||||
pluginErr := pluginHandler.HandleCommandExecutionError(err, true, tt.args)
|
||||
errMsg, pluginErr := pluginHandler.HandleCommandExecutionError(err, true, tt.args)
|
||||
|
||||
if tt.shouldFail {
|
||||
require.Error(t, pluginErr)
|
||||
assert.Equal(t, tt.expectedErrMsg, pluginErr.Error(), "Unexpected error message")
|
||||
assert.Equal(t, errMsg, fmt.Sprintf("Error: %s\n", tt.expectedErrMsg))
|
||||
} else {
|
||||
assert.Empty(t, errMsg)
|
||||
require.NoError(t, pluginErr, "Expected no error for valid flags")
|
||||
}
|
||||
})
|
||||
@@ -294,9 +304,10 @@ func TestPluginStatusCode(t *testing.T) {
|
||||
err := cmd.Execute()
|
||||
require.Error(t, err)
|
||||
|
||||
pluginErr := pluginHandler.HandleCommandExecutionError(err, true, tt.args)
|
||||
errMsg, pluginErr := pluginHandler.HandleCommandExecutionError(err, true, tt.args)
|
||||
if !tt.throwErr {
|
||||
require.NoError(t, pluginErr)
|
||||
assert.Empty(t, errMsg)
|
||||
} else {
|
||||
require.Error(t, pluginErr)
|
||||
var exitErr *exec.ExitError
|
||||
@@ -305,6 +316,7 @@ func TestPluginStatusCode(t *testing.T) {
|
||||
} else {
|
||||
t.Fatalf("expected an exit error, got: %v", pluginErr)
|
||||
}
|
||||
assert.Equal(t, errMsg, fmt.Sprintf("Error: exit status %d\n", tt.wantStatus))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -86,6 +86,7 @@ func NewProjectCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
command.AddCommand(NewProjectRemoveSourceNamespace(clientOpts))
|
||||
command.AddCommand(NewProjectAddDestinationServiceAccountCommand(clientOpts))
|
||||
command.AddCommand(NewProjectRemoveDestinationServiceAccountCommand(clientOpts))
|
||||
command.AddCommand(NewProjectSourceIntegrityCommand(clientOpts))
|
||||
return command
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,567 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"maps"
|
||||
"os"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/tabwriter"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/cmd/argocd/commands/headless"
|
||||
argocdclient "github.com/argoproj/argo-cd/v3/pkg/apiclient"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apiclient/gpgkey"
|
||||
projectpkg "github.com/argoproj/argo-cd/v3/pkg/apiclient/project"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/v3/util/cli"
|
||||
utilio "github.com/argoproj/argo-cd/v3/util/io"
|
||||
"github.com/argoproj/argo-cd/v3/util/sourceintegrity"
|
||||
"github.com/argoproj/argo-cd/v3/util/templates"
|
||||
)
|
||||
|
||||
const (
|
||||
msgNoGitPolicies = "no source integrity git policies defined for project %q"
|
||||
msgExamples = `
|
||||
# List git policies
|
||||
argocd proj source-integrity git policies list PROJECT
|
||||
|
||||
# Add a new git policy
|
||||
argocd proj source-integrity git policies add PROJECT ...
|
||||
|
||||
# Update a git policy
|
||||
argocd proj source-integrity git policies update PROJECT POLICY_ID ...
|
||||
|
||||
# Delete a git policy
|
||||
argocd proj source-integrity git policies delete PROJECT POLICY_ID
|
||||
`
|
||||
)
|
||||
|
||||
var (
|
||||
// Indirections needed for a client lookup during tests. Mocks are injected here.
|
||||
newProjectClient = func(clientOpts *argocdclient.ClientOptions, c *cobra.Command) (io.Closer, projectpkg.ProjectServiceClient) {
|
||||
return headless.NewClientOrDie(clientOpts, c).NewProjectClientOrDie()
|
||||
}
|
||||
newGpgKeyClient = func(clientOpts *argocdclient.ClientOptions, c *cobra.Command) (io.Closer, gpgkey.GPGKeyServiceClient) {
|
||||
return headless.NewClientOrDie(clientOpts, c).NewGPGKeyClientOrDie()
|
||||
}
|
||||
)
|
||||
|
||||
// NewProjectSourceIntegrityCommand returns a new instance of an `argocd proj source-integrity` command
|
||||
func NewProjectSourceIntegrityCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
command := &cobra.Command{
|
||||
Use: "source-integrity",
|
||||
Short: "Manage criteria for source integrity",
|
||||
Example: templates.Examples(msgExamples),
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
c.HelpFunc()(c, args)
|
||||
os.Exit(1)
|
||||
},
|
||||
}
|
||||
command.AddCommand(NewProjectSourceIntegrityGitCommand(clientOpts))
|
||||
return command
|
||||
}
|
||||
|
||||
// NewProjectSourceIntegrityGitCommand returns a new instance of an `argocd proj source-integrity git` command
|
||||
func NewProjectSourceIntegrityGitCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
command := &cobra.Command{
|
||||
Use: "git",
|
||||
Short: "Manage policies for Git repositories",
|
||||
Example: templates.Examples(msgExamples),
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
c.HelpFunc()(c, args)
|
||||
os.Exit(1)
|
||||
},
|
||||
}
|
||||
command.AddCommand(NewProjectSourceIntegrityGitPoliciesCommand(clientOpts))
|
||||
return command
|
||||
}
|
||||
|
||||
// NewProjectSourceIntegrityGitPoliciesCommand returns a new instance of an `argocd proj source-integrity git policies` command
|
||||
func NewProjectSourceIntegrityGitPoliciesCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
command := &cobra.Command{
|
||||
Use: "policies",
|
||||
Short: "Manage git source integrity policies",
|
||||
Example: templates.Examples(msgExamples),
|
||||
Run: func(c *cobra.Command, args []string) {
|
||||
c.HelpFunc()(c, args)
|
||||
os.Exit(1)
|
||||
},
|
||||
}
|
||||
command.AddCommand(NewProjectSourceIntegrityGitPoliciesListCommand(clientOpts))
|
||||
command.AddCommand(NewProjectSourceIntegrityGitPoliciesAddCommand(clientOpts))
|
||||
command.AddCommand(NewProjectSourceIntegrityGitPoliciesDeleteCommand(clientOpts))
|
||||
command.AddCommand(NewProjectSourceIntegrityGitPoliciesUpdateCommand(clientOpts))
|
||||
return command
|
||||
}
|
||||
|
||||
// NewProjectSourceIntegrityGitPoliciesListCommand returns a new instance of an `argocd proj source-integrity git policies list` command
|
||||
func NewProjectSourceIntegrityGitPoliciesListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
command := &cobra.Command{
|
||||
Use: "list PROJECT",
|
||||
Short: "List git source integrity policies",
|
||||
Long: "List git source integrity policies.\n\nThe listed policy ID is used to identify given policy in delete and update commands.",
|
||||
Example: templates.Examples(`
|
||||
# List all git policies for project PROJECT.
|
||||
argocd proj source-integrity git policies list PROJECT
|
||||
`),
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
ctx := c.Context()
|
||||
|
||||
if len(args) != 1 {
|
||||
c.HelpFunc()(c, args)
|
||||
os.Exit(1)
|
||||
}
|
||||
projName := args[0]
|
||||
cleanup, projects := newProjectClient(clientOpts, c)
|
||||
defer utilio.Close(cleanup)
|
||||
|
||||
proj, err := projects.Get(ctx, &projectpkg.ProjectQuery{Name: projName})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed getting project %q: %w", projName, err)
|
||||
}
|
||||
|
||||
if proj.Spec.SourceIntegrity == nil || proj.Spec.SourceIntegrity.Git == nil || len(proj.Spec.SourceIntegrity.Git.Policies) == 0 {
|
||||
return fmt.Errorf(msgNoGitPolicies, projName)
|
||||
}
|
||||
|
||||
listGitGpgPolicies(c.OutOrStdout(), proj)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
return command
|
||||
}
|
||||
|
||||
func listGitGpgPolicies(out io.Writer, proj *v1alpha1.AppProject) {
|
||||
w := tabwriter.NewWriter(out, 0, 0, 2, ' ', 0)
|
||||
_, _ = fmt.Fprintln(w, "ID\tGPG-MODE\tGPG-KEYS\tREPO-URLS")
|
||||
for i, policy := range proj.Spec.SourceIntegrity.Git.Policies {
|
||||
gpgMode := "<none>"
|
||||
gpgKeys := "<none>"
|
||||
if policy.GPG != nil {
|
||||
gpgMode = string(policy.GPG.Mode)
|
||||
if len(policy.GPG.Keys) > 0 {
|
||||
gpgKeys = strings.Join(policy.GPG.Keys, ", ")
|
||||
}
|
||||
}
|
||||
|
||||
repoURLs := "<none>"
|
||||
if len(policy.Repos) > 0 {
|
||||
urls := make([]string, 0, len(policy.Repos))
|
||||
for _, repo := range policy.Repos {
|
||||
urls = append(urls, repo.URL)
|
||||
}
|
||||
repoURLs = strings.Join(urls, ", ")
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintf(w, "%d\t%s\t%s\t%s\n", i, gpgMode, gpgKeys, repoURLs)
|
||||
}
|
||||
_ = w.Flush()
|
||||
}
|
||||
|
||||
// NewProjectSourceIntegrityGitPoliciesDeleteCommand returns a new instance of an `argocd proj source-integrity git policies delete` command
|
||||
func NewProjectSourceIntegrityGitPoliciesDeleteCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var yes bool
|
||||
command := &cobra.Command{
|
||||
Use: "delete PROJECT POLICY_ID...",
|
||||
Short: "Delete a git source integrity policy",
|
||||
Example: templates.Examples(`
|
||||
# Delete git policy at index 1 and 3 from project named PROJECT
|
||||
argocd proj source-integrity git policies delete PROJECT 1 3
|
||||
`),
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
ctx := c.Context()
|
||||
|
||||
if len(args) < 2 {
|
||||
c.HelpFunc()(c, args)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
projName := args[0]
|
||||
cleanup, projects := newProjectClient(clientOpts, c)
|
||||
defer utilio.Close(cleanup)
|
||||
|
||||
proj, err := projects.Get(ctx, &projectpkg.ProjectQuery{Name: projName})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed getting project %q: %w", projName, err)
|
||||
}
|
||||
|
||||
if proj.Spec.SourceIntegrity == nil || proj.Spec.SourceIntegrity.Git == nil || len(proj.Spec.SourceIntegrity.Git.Policies) == 0 {
|
||||
return fmt.Errorf(msgNoGitPolicies, projName)
|
||||
}
|
||||
|
||||
originalPolicyCount := len(proj.Spec.SourceIntegrity.Git.Policies)
|
||||
idsToDelete := make(map[int]any)
|
||||
for _, policyId := range args[1:] {
|
||||
index, err := strconv.Atoi(policyId)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid POLICY_ID '%s'", policyId)
|
||||
}
|
||||
|
||||
if index < 0 || index >= originalPolicyCount {
|
||||
return fmt.Errorf("the POLICY_ID %d is out of range (0-%d)", index, originalPolicyCount-1)
|
||||
}
|
||||
|
||||
idsToDelete[index] = nil
|
||||
}
|
||||
|
||||
if !yes {
|
||||
idsStr := make([]string, 0, len(idsToDelete))
|
||||
for i := range maps.Keys(idsToDelete) {
|
||||
idsStr = append(idsStr, strconv.Itoa(i))
|
||||
}
|
||||
slices.Sort(idsStr)
|
||||
prompt := fmt.Sprintf("Are you sure you want to delete policies %s from project %q? [y/N] ", strings.Join(idsStr, ", "), projName)
|
||||
if cli.AskToProceedS(prompt) != "y" {
|
||||
fmt.Fprintln(c.OutOrStdout(), "Aborted by user.")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// Build a new slice with only policies whose indices are not in the set
|
||||
newPolicies := make([]*v1alpha1.SourceIntegrityGitPolicy, 0, originalPolicyCount-len(idsToDelete))
|
||||
for i, policy := range proj.Spec.SourceIntegrity.Git.Policies {
|
||||
if _, shouldDelete := idsToDelete[i]; !shouldDelete {
|
||||
newPolicies = append(newPolicies, policy)
|
||||
}
|
||||
}
|
||||
proj.Spec.SourceIntegrity.Git.Policies = newPolicies
|
||||
|
||||
cleanupSourceIntegrityIfEmpty(proj)
|
||||
|
||||
_, err = projects.Update(ctx, &projectpkg.ProjectUpdateRequest{Project: proj})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed updating project %q: %w", projName, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
command.Flags().BoolVarP(&yes, "yes", "y", false, "Skip explicit confirmation")
|
||||
return command
|
||||
}
|
||||
|
||||
// cleanupSourceIntegrityIfEmpty removes spec.sourceIntegrity from a project if policies are emptied
|
||||
func cleanupSourceIntegrityIfEmpty(proj *v1alpha1.AppProject) {
|
||||
if proj.Spec.SourceIntegrity != nil && proj.Spec.SourceIntegrity.Git != nil && len(proj.Spec.SourceIntegrity.Git.Policies) == 0 {
|
||||
proj.Spec.SourceIntegrity.Git = nil
|
||||
proj.Spec.SourceIntegrity = nil
|
||||
}
|
||||
}
|
||||
|
||||
// NewProjectSourceIntegrityGitPoliciesAddCommand returns a new instance of an `argocd proj source-integrity git policies add` command
|
||||
func NewProjectSourceIntegrityGitPoliciesAddCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
repoURLs []string
|
||||
gpgMode string
|
||||
gpgKeys []string
|
||||
)
|
||||
command := &cobra.Command{
|
||||
Use: "add PROJECT",
|
||||
Short: "Add a git source integrity policy",
|
||||
Example: templates.Examples(`
|
||||
# Add a new git policy with repo URLs and GPG settings
|
||||
argocd proj source-integrity git policies add PROJECT \
|
||||
--repo-url 'https://github.com/foo/*' \
|
||||
--gpg-mode strict \
|
||||
--gpg-key D56C4FCA57A46444
|
||||
`),
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
ctx := c.Context()
|
||||
|
||||
if len(args) != 1 {
|
||||
c.HelpFunc()(c, args)
|
||||
os.Exit(1)
|
||||
}
|
||||
cleanup, projects := newProjectClient(clientOpts, c)
|
||||
defer utilio.Close(cleanup)
|
||||
|
||||
projName := args[0]
|
||||
proj, err := projects.Get(ctx, &projectpkg.ProjectQuery{Name: projName})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed getting project %q: %w", projName, err)
|
||||
}
|
||||
|
||||
mode, err := validateGpgMode(gpgMode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
newPolicy := v1alpha1.SourceIntegrityGitPolicy{GPG: &v1alpha1.SourceIntegrityGitPolicyGPG{Mode: mode}}
|
||||
for _, url := range repoURLs {
|
||||
newPolicy.Repos = append(newPolicy.Repos, v1alpha1.SourceIntegrityGitPolicyRepo{URL: url})
|
||||
}
|
||||
for _, key := range gpgKeys {
|
||||
key, err := sourceintegrity.KeyID(key)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid GPG key ID '%s': %w", key, err)
|
||||
}
|
||||
newPolicy.GPG.Keys = append(newPolicy.GPG.Keys, key)
|
||||
}
|
||||
|
||||
closer, gpgKeyClient := newGpgKeyClient(clientOpts, c)
|
||||
defer utilio.Close(closer)
|
||||
if err := warnOnProblems(c, &newPolicy, gpgKeyClient); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if proj.Spec.SourceIntegrity == nil {
|
||||
proj.Spec.SourceIntegrity = &v1alpha1.SourceIntegrity{}
|
||||
}
|
||||
if proj.Spec.SourceIntegrity.Git == nil {
|
||||
proj.Spec.SourceIntegrity.Git = &v1alpha1.SourceIntegrityGit{}
|
||||
}
|
||||
proj.Spec.SourceIntegrity.Git.Policies = append(proj.Spec.SourceIntegrity.Git.Policies, &newPolicy)
|
||||
|
||||
_, err = projects.Update(ctx, &projectpkg.ProjectUpdateRequest{Project: proj})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed updating project %q: %w", projName, err)
|
||||
}
|
||||
|
||||
// Print resulting policies out of convenience
|
||||
listGitGpgPolicies(c.OutOrStdout(), proj)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
command.Flags().StringSliceVar(&repoURLs, "repo-url", []string{}, "Repository URL pattern (can be repeated)")
|
||||
command.Flags().StringVar(&gpgMode, "gpg-mode", "", "GPG verification mode (strict, head, or none)")
|
||||
command.Flags().StringSliceVar(&gpgKeys, "gpg-key", []string{}, "GPG key ID (can be repeated)")
|
||||
return command
|
||||
}
|
||||
|
||||
func validateGpgMode(gpgMode string) (v1alpha1.SourceIntegrityGitPolicyGPGMode, error) {
|
||||
out := v1alpha1.SourceIntegrityGitPolicyGPGMode(gpgMode)
|
||||
|
||||
switch gpgMode {
|
||||
case "strict", "head", "none":
|
||||
return out, nil
|
||||
case "":
|
||||
return out, errors.New("gpg-mode must be set")
|
||||
default:
|
||||
return out, errors.New("gpg-mode must be one of: strict, head, none")
|
||||
}
|
||||
}
|
||||
|
||||
// NewProjectSourceIntegrityGitPoliciesUpdateCommand returns a new instance of an `argocd proj source-integrity git policies update` command
|
||||
func NewProjectSourceIntegrityGitPoliciesUpdateCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
|
||||
var (
|
||||
repoURLs []string
|
||||
deleteRepoURLs []string
|
||||
addRepoURLs []string
|
||||
gpgMode string
|
||||
gpgKeys []string
|
||||
deleteGPGKeys []string
|
||||
addGPGKeys []string
|
||||
yes bool
|
||||
)
|
||||
command := &cobra.Command{
|
||||
Use: "update PROJECT POLICY_ID",
|
||||
Short: "Update a git source integrity policy",
|
||||
Example: templates.Examples(`
|
||||
# Update policy at index to set specific repo URLs, removing the old ones
|
||||
argocd proj source-integrity git policies update PROJECT POLICY_ID \
|
||||
--repo-url 'https://github.com/foo/*'
|
||||
|
||||
# Update policy at index to add and remove repo URLs
|
||||
argocd proj source-integrity git policies update PROJECT POLICY_ID \
|
||||
--add-repo-url 'https://github.com/bar/*' \
|
||||
--delete-repo-url 'https://github.com/foo/*'
|
||||
|
||||
# Update policy GPG mode and keys
|
||||
argocd proj source-integrity git policies update PROJECT POLICY_ID \
|
||||
--gpg-mode strict \
|
||||
--add-gpg-key D56C4FCA57A46444
|
||||
`),
|
||||
RunE: func(c *cobra.Command, args []string) error {
|
||||
ctx := c.Context()
|
||||
|
||||
if len(args) != 2 {
|
||||
c.HelpFunc()(c, args)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
cleanup, projects := newProjectClient(clientOpts, c)
|
||||
defer utilio.Close(cleanup)
|
||||
|
||||
projName := args[0]
|
||||
proj, err := projects.Get(ctx, &projectpkg.ProjectQuery{Name: projName})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed getting project %q: %w", projName, err)
|
||||
}
|
||||
|
||||
if proj.Spec.SourceIntegrity == nil || proj.Spec.SourceIntegrity.Git == nil || len(proj.Spec.SourceIntegrity.Git.Policies) == 0 {
|
||||
return fmt.Errorf(msgNoGitPolicies, projName)
|
||||
}
|
||||
|
||||
index, err := strconv.Atoi(args[1])
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid POLICY_ID '%s'", args[1])
|
||||
}
|
||||
originalPolicyCount := len(proj.Spec.SourceIntegrity.Git.Policies)
|
||||
if index < 0 || index >= originalPolicyCount {
|
||||
return fmt.Errorf("the POLICY_ID %d is out of range (0-%d)", index, originalPolicyCount-1)
|
||||
}
|
||||
policy := proj.Spec.SourceIntegrity.Git.Policies[index]
|
||||
|
||||
if len(gpgKeys) > 0 && (len(deleteGPGKeys) > 0 || len(addGPGKeys) > 0) {
|
||||
return errors.New("option --gpg-key, cannot be combined with --add-gpg-key or --delete-gpg-key")
|
||||
}
|
||||
|
||||
if len(repoURLs) > 0 && (len(deleteRepoURLs) > 0 || len(addRepoURLs) > 0) {
|
||||
return errors.New("option --repo-url, cannot be combined with --add-repo-url or --delete-repo-url")
|
||||
}
|
||||
|
||||
if len(repoURLs) > 0 {
|
||||
var repos []v1alpha1.SourceIntegrityGitPolicyRepo
|
||||
for _, url := range repoURLs {
|
||||
repos = append(repos, v1alpha1.SourceIntegrityGitPolicyRepo{URL: url})
|
||||
}
|
||||
policy.Repos = repos
|
||||
}
|
||||
for _, url := range deleteRepoURLs {
|
||||
for i := 0; i < len(policy.Repos); i++ {
|
||||
if policy.Repos[i].URL == url {
|
||||
policy.Repos = append(policy.Repos[:i], policy.Repos[i+1:]...)
|
||||
i--
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, url := range addRepoURLs {
|
||||
found := false
|
||||
for _, repo := range policy.Repos {
|
||||
if repo.URL == url {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
policy.Repos = append(policy.Repos, v1alpha1.SourceIntegrityGitPolicyRepo{URL: url})
|
||||
}
|
||||
}
|
||||
|
||||
// There are no other types for now, so turning GPG on is the only sensible thing
|
||||
if policy.GPG == nil {
|
||||
policy.GPG = &v1alpha1.SourceIntegrityGitPolicyGPG{}
|
||||
}
|
||||
|
||||
// Update gpg mode
|
||||
if gpgMode != "" {
|
||||
mode, err := validateGpgMode(gpgMode)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
policy.GPG.Mode = mode
|
||||
} else if policy.GPG.Mode == "" {
|
||||
// The policy is updated to a gpg one, but this mandatory field is unset
|
||||
return errors.New("gpg-mode must be set")
|
||||
}
|
||||
|
||||
// Reset keys to a new set
|
||||
if len(gpgKeys) > 0 {
|
||||
policy.GPG.Keys = make([]string, len(gpgKeys))
|
||||
for i, key := range gpgKeys {
|
||||
key, err := sourceintegrity.KeyID(key)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid GPG key ID '%s': %w", key, err)
|
||||
}
|
||||
policy.GPG.Keys[i] = key
|
||||
}
|
||||
}
|
||||
for _, key := range deleteGPGKeys {
|
||||
key, err := sourceintegrity.KeyID(key)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid GPG key ID '%s': %w", key, err)
|
||||
}
|
||||
policy.GPG.Keys = slices.DeleteFunc(policy.GPG.Keys, func(k string) bool {
|
||||
k, err := sourceintegrity.KeyID(k)
|
||||
return err == nil && k == key
|
||||
})
|
||||
}
|
||||
for _, key := range addGPGKeys {
|
||||
key, err := sourceintegrity.KeyID(key)
|
||||
if err != nil {
|
||||
return fmt.Errorf("invalid GPG key ID '%s': %w", key, err)
|
||||
}
|
||||
found := slices.ContainsFunc(policy.GPG.Keys, func(k string) bool {
|
||||
k, err := sourceintegrity.KeyID(k)
|
||||
return err == nil && k == key
|
||||
})
|
||||
if !found {
|
||||
policy.GPG.Keys = append(policy.GPG.Keys, key)
|
||||
}
|
||||
}
|
||||
|
||||
closer, gpgKeyClient := newGpgKeyClient(clientOpts, c)
|
||||
defer utilio.Close(closer)
|
||||
if err := warnOnProblems(c, policy, gpgKeyClient); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Print resulting policies out of convenience
|
||||
listGitGpgPolicies(c.OutOrStdout(), proj)
|
||||
|
||||
if !yes {
|
||||
prompt := fmt.Sprintf("Are you sure you want to update policy %d from project %q? [y/N] ", index, projName)
|
||||
if cli.AskToProceedS(prompt) != "y" {
|
||||
fmt.Fprintln(c.OutOrStdout(), "Aborted by user.")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
_, err = projects.Update(ctx, &projectpkg.ProjectUpdateRequest{Project: proj})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed updating project %q: %w", projName, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
command.Flags().StringVar(&gpgMode, "gpg-mode", "", "Set GPG verification mode (strict, head, or none)")
|
||||
command.Flags().StringSliceVar(&repoURLs, "repo-url", []string{}, "Set repository URL pattern (replaces existing)")
|
||||
command.Flags().StringSliceVar(&addRepoURLs, "add-repo-url", []string{}, "Add repository URL pattern")
|
||||
command.Flags().StringSliceVar(&deleteRepoURLs, "delete-repo-url", []string{}, "Delete repository URL pattern")
|
||||
command.Flags().StringSliceVar(&gpgKeys, "gpg-key", []string{}, "Set GPG key ID (replaces existing)")
|
||||
command.Flags().StringSliceVar(&addGPGKeys, "add-gpg-key", []string{}, "Add GPG key ID")
|
||||
command.Flags().StringSliceVar(&deleteGPGKeys, "delete-gpg-key", []string{}, "Delete GPG key ID")
|
||||
command.Flags().BoolVarP(&yes, "yes", "y", false, "Skip explicit confirmation")
|
||||
return command
|
||||
}
|
||||
|
||||
// warnOnProblems checks if a policy has empty repo URLs or GPG keys and prints warnings
|
||||
func warnOnProblems(c *cobra.Command, policy *v1alpha1.SourceIntegrityGitPolicy, gpgKeyClient gpgkey.GPGKeyServiceClient) error {
|
||||
stderr := c.ErrOrStderr()
|
||||
if len(policy.Repos) == 0 {
|
||||
_, _ = fmt.Fprintln(stderr, "Warning: Policy has no repository URLs and will never be used")
|
||||
}
|
||||
if policy.GPG != nil {
|
||||
if len(policy.GPG.Keys) == 0 {
|
||||
_, _ = fmt.Fprintln(stderr, "Warning: Policy has no GPG keys and will never validate any revision")
|
||||
} else {
|
||||
absent := make(map[string]any)
|
||||
for _, key := range policy.GPG.Keys {
|
||||
absent[key] = nil
|
||||
}
|
||||
|
||||
keyring, err := gpgKeyClient.List(c.Context(), &gpgkey.GnuPGPublicKeyQuery{})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed listing GPG keys: %w", err)
|
||||
}
|
||||
for _, keyringKey := range keyring.Items {
|
||||
delete(absent, keyringKey.KeyID)
|
||||
}
|
||||
|
||||
if len(absent) != 0 {
|
||||
absentKeys := slices.Collect(maps.Keys(absent))
|
||||
slices.Sort(absentKeys)
|
||||
_, _ = fmt.Fprintf(stderr,
|
||||
"Warning: Following GPG keys are not in repo-server keyring: %s\n",
|
||||
strings.Join(absentKeys, ", "),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
+623
@@ -0,0 +1,623 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"regexp"
|
||||
"testing"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/require"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
||||
argocdclient "github.com/argoproj/argo-cd/v3/pkg/apiclient"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apiclient/gpgkey"
|
||||
gpgkeymocks "github.com/argoproj/argo-cd/v3/pkg/apiclient/gpgkey/mocks"
|
||||
projectmocks "github.com/argoproj/argo-cd/v3/pkg/apiclient/project/mocks"
|
||||
|
||||
projectpkg "github.com/argoproj/argo-cd/v3/pkg/apiclient/project"
|
||||
appsv1 "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
)
|
||||
|
||||
func dummySourceIntegrity() *appsv1.SourceIntegrity {
|
||||
return &appsv1.SourceIntegrity{Git: &appsv1.SourceIntegrityGit{
|
||||
Policies: []*appsv1.SourceIntegrityGitPolicy{
|
||||
{
|
||||
Repos: []appsv1.SourceIntegrityGitPolicyRepo{{
|
||||
URL: "*",
|
||||
}, {
|
||||
URL: "!https://github.com/argoproj/argo-cd.git",
|
||||
}},
|
||||
GPG: &appsv1.SourceIntegrityGitPolicyGPG{
|
||||
Mode: appsv1.SourceIntegrityGitPolicyGPGModeHead,
|
||||
Keys: []string{"ABCD1234ABCD1234"},
|
||||
},
|
||||
},
|
||||
{
|
||||
Repos: []appsv1.SourceIntegrityGitPolicyRepo{{
|
||||
URL: "https://github.com/argoproj/argo-cd.git",
|
||||
}},
|
||||
GPG: &appsv1.SourceIntegrityGitPolicyGPG{
|
||||
Mode: appsv1.SourceIntegrityGitPolicyGPGModeStrict,
|
||||
Keys: []string{"1234ABCD1234ABCD"},
|
||||
},
|
||||
},
|
||||
},
|
||||
}}
|
||||
}
|
||||
|
||||
func dummyProject(projectName string, si *appsv1.SourceIntegrity) *appsv1.AppProject {
|
||||
return &appsv1.AppProject{
|
||||
ObjectMeta: metav1.ObjectMeta{Name: projectName},
|
||||
Spec: appsv1.AppProjectSpec{
|
||||
SourceIntegrity: si,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func mockProjectClient(t *testing.T) *projectmocks.ProjectServiceClient {
|
||||
t.Helper()
|
||||
mockClient := projectmocks.NewProjectServiceClient(t)
|
||||
newProjectClient = func(_ *argocdclient.ClientOptions, _ *cobra.Command) (io.Closer, projectpkg.ProjectServiceClient) {
|
||||
return io.NopCloser(nil), mockClient
|
||||
}
|
||||
return mockClient
|
||||
}
|
||||
|
||||
func mockProjectGet(mockClient *projectmocks.ProjectServiceClient, name string, retProj *appsv1.AppProject, retErr error) *mock.Call {
|
||||
return mockClient.On("Get", mock.Anything, mock.MatchedBy(func(q *projectpkg.ProjectQuery) bool {
|
||||
return q.Name == name
|
||||
})).Return(retProj, retErr)
|
||||
}
|
||||
|
||||
func mockGpgKeysClient(t *testing.T) *gpgkeymocks.GPGKeyServiceClient {
|
||||
t.Helper()
|
||||
mockClient := gpgkeymocks.NewGPGKeyServiceClient(t)
|
||||
newGpgKeyClient = func(_ *argocdclient.ClientOptions, _ *cobra.Command) (io.Closer, gpgkey.GPGKeyServiceClient) {
|
||||
return io.NopCloser(nil), mockClient
|
||||
}
|
||||
return mockClient
|
||||
}
|
||||
|
||||
// mockKeyring fakes that keys are added to a repo-server through `argocd gpg add`, so those do not show up in warnings.
|
||||
func mockKeyring(mockClient *gpgkeymocks.GPGKeyServiceClient, keys ...string) *mock.Call {
|
||||
items := make([]appsv1.GnuPGPublicKey, 0, len(keys))
|
||||
for _, key := range keys {
|
||||
items = append(items, appsv1.GnuPGPublicKey{KeyID: key})
|
||||
}
|
||||
keyring := &appsv1.GnuPGPublicKeyList{Items: items}
|
||||
return mockClient.On("List", mock.Anything, mock.Anything).Return(keyring, nil).Maybe()
|
||||
}
|
||||
|
||||
func runCmd(t *testing.T, cmd *cobra.Command, args ...string) (stdout string, stderr string, e error) {
|
||||
t.Helper()
|
||||
cmd.SilenceErrors = true
|
||||
cmd.SilenceUsage = true
|
||||
|
||||
cmd.SetArgs(args)
|
||||
|
||||
var outbuf bytes.Buffer
|
||||
cmd.SetOut(&outbuf)
|
||||
var errbuf bytes.Buffer
|
||||
cmd.SetErr(&errbuf)
|
||||
|
||||
err := cmd.ExecuteContext(t.Context())
|
||||
// Make sure the messare from the error reported by Command.RunE() is appended to the errbuf for verification (same as in main.go)
|
||||
if err != nil {
|
||||
errMsg, _ := NewDefaultPluginHandler().HandleCommandExecutionError(err, true, args)
|
||||
errbuf.WriteString(errMsg)
|
||||
}
|
||||
|
||||
return outbuf.String(), errbuf.String(), err
|
||||
}
|
||||
|
||||
func TestProjectSourceIntegrityAddCommand(t *testing.T) {
|
||||
projectName := "test-project"
|
||||
|
||||
mockKeyring(mockGpgKeysClient(t), "ABCD1234ABCD1234")
|
||||
|
||||
t.Run("Add source integrity verification policy to empty", func(t *testing.T) {
|
||||
projects := mockProjectClient(t)
|
||||
projects.On("Update", mock.Anything, mock.Anything).Return(nil, nil)
|
||||
mockProjectGet(projects, projectName, dummyProject(projectName, nil), nil).Maybe()
|
||||
|
||||
cmd := NewProjectSourceIntegrityGitPoliciesAddCommand(&argocdclient.ClientOptions{})
|
||||
out, _, err := runCmd(t, cmd,
|
||||
"--gpg-mode=strict",
|
||||
"--gpg-key=0123456789ABCDEF",
|
||||
"--repo-url=*",
|
||||
"--gpg-key", "ABCDEF0123456789",
|
||||
"--repo-url", "!*internal*",
|
||||
projectName,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedOut := `ID GPG-MODE GPG-KEYS REPO-URLS
|
||||
0 strict 0123456789ABCDEF, ABCDEF0123456789 *, !*internal*
|
||||
`
|
||||
tabbedOut := regexp.MustCompile(" {2,}").ReplaceAllString(out, "\t")
|
||||
assert.Equal(t, expectedOut, tabbedOut)
|
||||
|
||||
updatedProject := captureProjectUpdate(t, projects, projectName)
|
||||
require.NotNil(t, updatedProject)
|
||||
require.NotNil(t, updatedProject.Spec.SourceIntegrity)
|
||||
si := updatedProject.Spec.SourceIntegrity
|
||||
require.NotNil(t, si.Git)
|
||||
assert.Len(t, si.Git.Policies, 1)
|
||||
expected := []*appsv1.SourceIntegrityGitPolicy{{
|
||||
Repos: []appsv1.SourceIntegrityGitPolicyRepo{{
|
||||
URL: "*",
|
||||
}, {
|
||||
URL: "!*internal*",
|
||||
}},
|
||||
GPG: &appsv1.SourceIntegrityGitPolicyGPG{
|
||||
Mode: appsv1.SourceIntegrityGitPolicyGPGModeStrict,
|
||||
Keys: []string{"0123456789ABCDEF", "ABCDEF0123456789"},
|
||||
},
|
||||
}}
|
||||
assert.Equal(t, expected, si.Git.Policies)
|
||||
})
|
||||
|
||||
t.Run("Add source integrity verification policy to existing", func(t *testing.T) {
|
||||
projects := mockProjectClient(t)
|
||||
projects.On("Update", mock.Anything, mock.Anything).Return(nil, nil)
|
||||
mockProjectGet(projects, projectName, dummyProject(projectName, dummySourceIntegrity()), nil).Maybe()
|
||||
|
||||
cmd := NewProjectSourceIntegrityGitPoliciesAddCommand(&argocdclient.ClientOptions{})
|
||||
out, _, err := runCmd(t, cmd,
|
||||
"--gpg-mode=head",
|
||||
"--gpg-key=0123456789ABCDEF",
|
||||
"--repo-url=*",
|
||||
projectName,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedOut := `ID GPG-MODE GPG-KEYS REPO-URLS
|
||||
0 head ABCD1234ABCD1234 *, !https://github.com/argoproj/argo-cd.git
|
||||
1 strict 1234ABCD1234ABCD https://github.com/argoproj/argo-cd.git
|
||||
2 head 0123456789ABCDEF *
|
||||
`
|
||||
tabbedOut := regexp.MustCompile(" {2,}").ReplaceAllString(out, "\t")
|
||||
assert.Equal(t, expectedOut, tabbedOut)
|
||||
|
||||
updatedProject := captureProjectUpdate(t, projects, projectName)
|
||||
require.NotNil(t, updatedProject)
|
||||
require.NotNil(t, updatedProject.Spec.SourceIntegrity)
|
||||
si := updatedProject.Spec.SourceIntegrity
|
||||
require.NotNil(t, si.Git)
|
||||
assert.Len(t, si.Git.Policies, 3)
|
||||
expected := &appsv1.SourceIntegrityGitPolicy{
|
||||
Repos: []appsv1.SourceIntegrityGitPolicyRepo{{
|
||||
URL: "*",
|
||||
}},
|
||||
GPG: &appsv1.SourceIntegrityGitPolicyGPG{
|
||||
Mode: appsv1.SourceIntegrityGitPolicyGPGModeHead,
|
||||
Keys: []string{"0123456789ABCDEF"},
|
||||
},
|
||||
}
|
||||
assert.Equal(t, expected, si.Git.Policies[2])
|
||||
})
|
||||
|
||||
t.Run("Add source integrity verification policy - warn existing", func(t *testing.T) {
|
||||
projects := mockProjectClient(t)
|
||||
projects.On("Update", mock.Anything, mock.Anything).Return(nil, nil)
|
||||
mockProjectGet(projects, projectName, dummyProject(projectName, nil), nil).Maybe()
|
||||
|
||||
cmd := NewProjectSourceIntegrityGitPoliciesAddCommand(&argocdclient.ClientOptions{})
|
||||
out, stderr, err := runCmd(t, cmd, projectName, "--gpg-mode=head")
|
||||
require.NoError(t, err)
|
||||
|
||||
expectedOut := `ID GPG-MODE GPG-KEYS REPO-URLS
|
||||
0 head <none> <none>
|
||||
`
|
||||
tabbedOut := regexp.MustCompile(" {2,}").ReplaceAllString(out, "\t")
|
||||
assert.Equal(t, expectedOut, tabbedOut)
|
||||
assert.Equal(t, "Warning: Policy has no repository URLs and will never be used\nWarning: Policy has no GPG keys and will never validate any revision\n", stderr)
|
||||
})
|
||||
|
||||
t.Run("Add source integrity verification policy without gpg-mode", func(t *testing.T) {
|
||||
projects := mockProjectClient(t)
|
||||
mockProjectGet(projects, projectName, dummyProject(projectName, dummySourceIntegrity()), nil).Maybe()
|
||||
|
||||
cmd := NewProjectSourceIntegrityGitPoliciesAddCommand(&argocdclient.ClientOptions{})
|
||||
_, stderr, err := runCmd(t, cmd,
|
||||
"--gpg-key=0123456789ABCDEF",
|
||||
"--repo-url=*",
|
||||
projectName,
|
||||
)
|
||||
require.Error(t, err)
|
||||
assert.Equal(t, "Error: gpg-mode must be set\n", stderr)
|
||||
})
|
||||
}
|
||||
|
||||
func TestProjectSourceIntegrityListCommand(t *testing.T) {
|
||||
projectName := "test-project"
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
sourceIntegrity *appsv1.SourceIntegrity
|
||||
projectName string
|
||||
expectedStdout string
|
||||
expectedStderr string
|
||||
}{
|
||||
{
|
||||
name: "with policies",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
projectName: projectName,
|
||||
expectedStdout: `ID GPG-MODE GPG-KEYS REPO-URLS
|
||||
0 head ABCD1234ABCD1234 *, !https://github.com/argoproj/argo-cd.git
|
||||
1 strict 1234ABCD1234ABCD https://github.com/argoproj/argo-cd.git
|
||||
`,
|
||||
expectedStderr: "",
|
||||
},
|
||||
{
|
||||
name: "without policies",
|
||||
sourceIntegrity: nil,
|
||||
projectName: projectName,
|
||||
expectedStdout: "",
|
||||
expectedStderr: "Error: no source integrity git policies defined for project \"test-project\"\n",
|
||||
},
|
||||
{
|
||||
name: "no project",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
projectName: "not-a-project",
|
||||
expectedStdout: "",
|
||||
expectedStderr: "Error: failed getting project \"not-a-project\": rpc error: code = NotFound desc = appprojects.argoproj.io \"not-a-project\" not found\n",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
projects := mockProjectClient(t)
|
||||
mockProjectGet(projects, projectName, dummyProject(projectName, tc.sourceIntegrity), nil).Maybe()
|
||||
mockProjectGet(projects, "not-a-project", nil, errors.New(`rpc error: code = NotFound desc = appprojects.argoproj.io "not-a-project" not found`)).Maybe()
|
||||
|
||||
cmd := NewProjectSourceIntegrityGitPoliciesListCommand(&argocdclient.ClientOptions{})
|
||||
out, stderr, _ := runCmd(t, cmd, tc.projectName)
|
||||
|
||||
tabbedOut := regexp.MustCompile(" {2,}").ReplaceAllString(out, "\t")
|
||||
assert.Equal(t, tc.expectedStdout, tabbedOut)
|
||||
assert.Equal(t, tc.expectedStderr, stderr)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestProjectSourceIntegrityUpdateCommand(t *testing.T) {
|
||||
projectName := "test-project"
|
||||
|
||||
mockKeyring(mockGpgKeysClient(t), "ABCD1234ABCD1234")
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
sourceIntegrity *appsv1.SourceIntegrity
|
||||
args []string
|
||||
|
||||
expectedStdout string
|
||||
expectedStderr string
|
||||
expectedPolicy *appsv1.SourceIntegrityGitPolicy
|
||||
}{
|
||||
{
|
||||
name: "Set GPG mode",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "0", "--gpg-mode=strict", "--yes"},
|
||||
expectedStdout: `ID GPG-MODE GPG-KEYS REPO-URLS
|
||||
0 strict ABCD1234ABCD1234 *, !https://github.com/argoproj/argo-cd.git
|
||||
1 strict 1234ABCD1234ABCD https://github.com/argoproj/argo-cd.git
|
||||
`,
|
||||
expectedStderr: "",
|
||||
expectedPolicy: &appsv1.SourceIntegrityGitPolicy{
|
||||
Repos: []appsv1.SourceIntegrityGitPolicyRepo{{
|
||||
URL: "*",
|
||||
}, {
|
||||
URL: "!https://github.com/argoproj/argo-cd.git",
|
||||
}},
|
||||
GPG: &appsv1.SourceIntegrityGitPolicyGPG{
|
||||
Mode: appsv1.SourceIntegrityGitPolicyGPGModeStrict,
|
||||
Keys: []string{"ABCD1234ABCD1234"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Set GPG keys",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "1", "--gpg-key=FEDCBA9876543210", "--gpg-key=FEDCBA9876543219", "--yes"},
|
||||
expectedStdout: `ID GPG-MODE GPG-KEYS REPO-URLS
|
||||
0 head ABCD1234ABCD1234 *, !https://github.com/argoproj/argo-cd.git
|
||||
1 strict FEDCBA9876543210, FEDCBA9876543219 https://github.com/argoproj/argo-cd.git
|
||||
`,
|
||||
expectedStderr: "Warning: Following GPG keys are not in repo-server keyring: FEDCBA9876543210, FEDCBA9876543219\n",
|
||||
expectedPolicy: &appsv1.SourceIntegrityGitPolicy{
|
||||
Repos: []appsv1.SourceIntegrityGitPolicyRepo{{
|
||||
URL: "https://github.com/argoproj/argo-cd.git",
|
||||
}},
|
||||
GPG: &appsv1.SourceIntegrityGitPolicyGPG{
|
||||
Mode: appsv1.SourceIntegrityGitPolicyGPGModeStrict,
|
||||
Keys: []string{"FEDCBA9876543210", "FEDCBA9876543219"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Delete GPG key",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "0", "--delete-gpg-key=ABCD1234ABCD1234", "-y"},
|
||||
expectedStdout: `ID GPG-MODE GPG-KEYS REPO-URLS
|
||||
0 head <none> *, !https://github.com/argoproj/argo-cd.git
|
||||
1 strict 1234ABCD1234ABCD https://github.com/argoproj/argo-cd.git
|
||||
`,
|
||||
expectedStderr: "Warning: Policy has no GPG keys and will never validate any revision\n",
|
||||
expectedPolicy: &appsv1.SourceIntegrityGitPolicy{
|
||||
Repos: []appsv1.SourceIntegrityGitPolicyRepo{{
|
||||
URL: "*",
|
||||
}, {
|
||||
URL: "!https://github.com/argoproj/argo-cd.git",
|
||||
}},
|
||||
GPG: &appsv1.SourceIntegrityGitPolicyGPG{
|
||||
Mode: appsv1.SourceIntegrityGitPolicyGPGModeHead,
|
||||
Keys: []string{},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Set repo URLs",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "1", "--repo-url=https://github.com/example/repo.git", "--repo-url=https://github.com/example/other.git", "--yes"},
|
||||
expectedStdout: `ID GPG-MODE GPG-KEYS REPO-URLS
|
||||
0 head ABCD1234ABCD1234 *, !https://github.com/argoproj/argo-cd.git
|
||||
1 strict 1234ABCD1234ABCD https://github.com/example/repo.git, https://github.com/example/other.git
|
||||
`,
|
||||
expectedStderr: "Warning: Following GPG keys are not in repo-server keyring: 1234ABCD1234ABCD\n",
|
||||
expectedPolicy: &appsv1.SourceIntegrityGitPolicy{
|
||||
Repos: []appsv1.SourceIntegrityGitPolicyRepo{{
|
||||
URL: "https://github.com/example/repo.git",
|
||||
}, {
|
||||
URL: "https://github.com/example/other.git",
|
||||
}},
|
||||
GPG: &appsv1.SourceIntegrityGitPolicyGPG{
|
||||
Mode: appsv1.SourceIntegrityGitPolicyGPGModeStrict,
|
||||
Keys: []string{"1234ABCD1234ABCD"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Remove repo URL",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "0", "--delete-repo-url=*", "--delete-repo-url=not://present.is/ignored", "--yes"},
|
||||
expectedStdout: `ID GPG-MODE GPG-KEYS REPO-URLS
|
||||
0 head ABCD1234ABCD1234 !https://github.com/argoproj/argo-cd.git
|
||||
1 strict 1234ABCD1234ABCD https://github.com/argoproj/argo-cd.git
|
||||
`,
|
||||
expectedStderr: "",
|
||||
expectedPolicy: &appsv1.SourceIntegrityGitPolicy{
|
||||
Repos: []appsv1.SourceIntegrityGitPolicyRepo{{
|
||||
URL: "!https://github.com/argoproj/argo-cd.git",
|
||||
}},
|
||||
GPG: &appsv1.SourceIntegrityGitPolicyGPG{
|
||||
Mode: appsv1.SourceIntegrityGitPolicyGPGModeHead,
|
||||
Keys: []string{"ABCD1234ABCD1234"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Update multiple attributes at once",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{
|
||||
projectName, "0", "--gpg-mode=none",
|
||||
"--add-gpg-key=9876543210FEDCBA",
|
||||
"--add-repo-url=https://new-repo.com",
|
||||
"--delete-gpg-key=ABCD1234ABCD1234",
|
||||
"--delete-repo-url=!https://github.com/argoproj/argo-cd.git",
|
||||
"--yes",
|
||||
},
|
||||
expectedStdout: `ID GPG-MODE GPG-KEYS REPO-URLS
|
||||
0 none 9876543210FEDCBA *, https://new-repo.com
|
||||
1 strict 1234ABCD1234ABCD https://github.com/argoproj/argo-cd.git
|
||||
`,
|
||||
expectedStderr: "Warning: Following GPG keys are not in repo-server keyring: 9876543210FEDCBA\n",
|
||||
expectedPolicy: &appsv1.SourceIntegrityGitPolicy{
|
||||
Repos: []appsv1.SourceIntegrityGitPolicyRepo{{
|
||||
URL: "*",
|
||||
}, {
|
||||
URL: "https://new-repo.com",
|
||||
}},
|
||||
GPG: &appsv1.SourceIntegrityGitPolicyGPG{
|
||||
Mode: appsv1.SourceIntegrityGitPolicyGPGModeNone,
|
||||
Keys: []string{"9876543210FEDCBA"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Update policy with invalid project name",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{"not-a-project", "0", "--gpg-mode=strict", "--yes"},
|
||||
expectedStderr: "Error: failed getting project \"not-a-project\": rpc error: code = NotFound desc = appprojects.argoproj.io \"not-a-project\" not found\n",
|
||||
},
|
||||
{
|
||||
name: "Update policy with invalid ID",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "42", "--gpg-mode=strict", "--yes"},
|
||||
expectedStderr: "Error: the POLICY_ID 42 is out of range (0-1)\n",
|
||||
},
|
||||
{
|
||||
name: "Update policy with incorrect ID",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "the first one, bro", "--gpg-mode=strict", "--yes"},
|
||||
expectedStderr: "Error: invalid POLICY_ID 'the first one, bro'\n",
|
||||
},
|
||||
{
|
||||
name: "Update policy when no Source Integrity",
|
||||
sourceIntegrity: nil,
|
||||
args: []string{projectName, "0", "--gpg-mode=strict", "--yes"},
|
||||
expectedStderr: "Error: no source integrity git policies defined for project \"test-project\"\n",
|
||||
},
|
||||
{
|
||||
name: "Set and add key",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "0", "--gpg-key=FAKE", "--add-gpg-key=FAKE2", "--gpg-mode=strict", "--yes"},
|
||||
expectedStderr: "Error: option --gpg-key, cannot be combined with --add-gpg-key or --delete-gpg-key\n",
|
||||
},
|
||||
{
|
||||
name: "Set and add repo",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "0", "--repo-url=FAKE", "--delete-repo-url=FAKE2", "--gpg-mode=strict", "--yes"},
|
||||
expectedStderr: "Error: option --repo-url, cannot be combined with --add-repo-url or --delete-repo-url\n",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
projects := mockProjectClient(t)
|
||||
mockProjectGet(projects, projectName, dummyProject(projectName, tc.sourceIntegrity), nil).Maybe()
|
||||
mockProjectGet(projects, "not-a-project", nil, errors.New(`rpc error: code = NotFound desc = appprojects.argoproj.io "not-a-project" not found`)).Maybe()
|
||||
projects.On("Update", mock.Anything, mock.Anything).Return(nil, nil).Maybe()
|
||||
|
||||
cmd := NewProjectSourceIntegrityGitPoliciesUpdateCommand(&argocdclient.ClientOptions{})
|
||||
out, stderr, _ := runCmd(t, cmd, tc.args...)
|
||||
|
||||
tabbedOut := regexp.MustCompile(" {2,}").ReplaceAllString(out, "\t")
|
||||
assert.Equal(t, tc.expectedStdout, tabbedOut)
|
||||
assert.Equal(t, tc.expectedStderr, stderr)
|
||||
|
||||
if tc.expectedPolicy != nil {
|
||||
updatedProject := captureProjectUpdate(t, projects, projectName)
|
||||
require.NotNil(t, updatedProject)
|
||||
require.NotNil(t, updatedProject.Spec.SourceIntegrity)
|
||||
si := updatedProject.Spec.SourceIntegrity
|
||||
require.NotNil(t, si.Git)
|
||||
|
||||
// Extract the policy ID from args to verify the correct policy was updated
|
||||
policyID := tc.args[1]
|
||||
var idx int
|
||||
if policyID == "0" {
|
||||
idx = 0
|
||||
} else {
|
||||
idx = 1
|
||||
}
|
||||
|
||||
assert.Equal(t, tc.expectedPolicy, si.Git.Policies[idx])
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestProjectSourceIntegrityDeleteCommand(t *testing.T) {
|
||||
projectName := "test-project"
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
sourceIntegrity *appsv1.SourceIntegrity
|
||||
args []string
|
||||
|
||||
expectedSI *appsv1.SourceIntegrity
|
||||
expectedStderr string
|
||||
}{
|
||||
{
|
||||
name: "Delete source integrity verification policy 0",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "0", "--yes"},
|
||||
expectedSI: &appsv1.SourceIntegrity{
|
||||
Git: &appsv1.SourceIntegrityGit{
|
||||
Policies: []*appsv1.SourceIntegrityGitPolicy{{
|
||||
Repos: []appsv1.SourceIntegrityGitPolicyRepo{{
|
||||
URL: "https://github.com/argoproj/argo-cd.git",
|
||||
}},
|
||||
GPG: &appsv1.SourceIntegrityGitPolicyGPG{
|
||||
Mode: appsv1.SourceIntegrityGitPolicyGPGModeStrict,
|
||||
Keys: []string{"1234ABCD1234ABCD"},
|
||||
},
|
||||
}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Delete source integrity verification policy 1",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "--yes", "1"},
|
||||
expectedSI: &appsv1.SourceIntegrity{
|
||||
Git: &appsv1.SourceIntegrityGit{
|
||||
Policies: []*appsv1.SourceIntegrityGitPolicy{{
|
||||
Repos: []appsv1.SourceIntegrityGitPolicyRepo{{
|
||||
URL: "*",
|
||||
}, {
|
||||
URL: "!https://github.com/argoproj/argo-cd.git",
|
||||
}},
|
||||
GPG: &appsv1.SourceIntegrityGitPolicyGPG{
|
||||
Mode: appsv1.SourceIntegrityGitPolicyGPGModeHead,
|
||||
Keys: []string{"ABCD1234ABCD1234"},
|
||||
},
|
||||
}},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "Delete source integrity verification policies (asc)",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "--yes", "0", "1"},
|
||||
expectedSI: nil,
|
||||
},
|
||||
{
|
||||
name: "Delete source integrity verification policies (desc)",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "--yes", "1", "0"},
|
||||
expectedSI: nil,
|
||||
},
|
||||
{
|
||||
name: "Delete policy with invalid project name",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{"not-a-project", "--yes", "0"},
|
||||
expectedStderr: "Error: failed getting project \"not-a-project\": rpc error: code = NotFound desc = appprojects.argoproj.io \"not-a-project\" not found\n",
|
||||
},
|
||||
{
|
||||
name: "Delete policy with invalid ID",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "--yes", "42"},
|
||||
expectedStderr: "Error: the POLICY_ID 42 is out of range (0-1)\n",
|
||||
},
|
||||
{
|
||||
name: "Delete policy with incorrect ID",
|
||||
sourceIntegrity: dummySourceIntegrity(),
|
||||
args: []string{projectName, "--yes", "the first one, bro"},
|
||||
expectedStderr: "Error: invalid POLICY_ID 'the first one, bro'\n",
|
||||
},
|
||||
{
|
||||
name: "Delete policy when there is no Source Integrity",
|
||||
sourceIntegrity: nil,
|
||||
args: []string{projectName, "--yes", "0"},
|
||||
expectedStderr: "Error: no source integrity git policies defined for project \"test-project\"\n",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
projects := mockProjectClient(t)
|
||||
mockProjectGet(projects, projectName, dummyProject(projectName, tc.sourceIntegrity), nil).Maybe()
|
||||
mockProjectGet(projects, "not-a-project", nil, errors.New(`rpc error: code = NotFound desc = appprojects.argoproj.io "not-a-project" not found`)).Maybe()
|
||||
projects.On("Update", mock.Anything, mock.Anything).Return(nil, nil).Maybe()
|
||||
|
||||
cmd := NewProjectSourceIntegrityGitPoliciesDeleteCommand(&argocdclient.ClientOptions{})
|
||||
stdout, stderr, err := runCmd(t, cmd, tc.args...)
|
||||
assert.Equal(t, tc.expectedStderr, stderr, "Err: %w, Out: %s", err, stdout)
|
||||
|
||||
if tc.expectedSI != nil {
|
||||
updatedProject := captureProjectUpdate(t, projects, projectName)
|
||||
assert.Equal(t, tc.expectedSI, updatedProject.Spec.SourceIntegrity)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func captureProjectUpdate(t *testing.T, projects *projectmocks.ProjectServiceClient, name string) (updatedProject *appsv1.AppProject) {
|
||||
t.Helper()
|
||||
capture := mock.MatchedBy(func(q *projectpkg.ProjectUpdateRequest) bool {
|
||||
if q.Project.Name != name {
|
||||
return false
|
||||
}
|
||||
updatedProject = q.Project
|
||||
return true
|
||||
})
|
||||
|
||||
projects.AssertCalled(t, "Update", mock.Anything, capture)
|
||||
return updatedProject
|
||||
}
|
||||
+2
-1
@@ -89,8 +89,9 @@ func main() {
|
||||
// such as if the error is from the execution of a normal argocd command,
|
||||
// unknown command error or any other.
|
||||
if err != nil {
|
||||
pluginErr := cli.NewDefaultPluginHandler().HandleCommandExecutionError(err, isArgocdCLI, os.Args)
|
||||
errMsg, pluginErr := cli.NewDefaultPluginHandler().HandleCommandExecutionError(err, isArgocdCLI, os.Args)
|
||||
if pluginErr != nil {
|
||||
os.Stdout.WriteString(errMsg)
|
||||
var exitErr *exec.ExitError
|
||||
if errors.As(pluginErr, &exitErr) {
|
||||
// Return the actual plugin exit code
|
||||
|
||||
Generated
+1
@@ -96,5 +96,6 @@ argocd proj [flags]
|
||||
* [argocd proj remove-source-namespace](argocd_proj_remove-source-namespace.md) - Removes the source namespace from the AppProject
|
||||
* [argocd proj role](argocd_proj_role.md) - Manage a project's roles
|
||||
* [argocd proj set](argocd_proj_set.md) - Set project parameters
|
||||
* [argocd proj source-integrity](argocd_proj_source-integrity.md) - Manage criteria for source integrity
|
||||
* [argocd proj windows](argocd_proj_windows.md) - Manage a project's sync windows
|
||||
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
# `argocd proj source-integrity` Command Reference
|
||||
|
||||
## argocd proj source-integrity
|
||||
|
||||
Manage criteria for source integrity
|
||||
|
||||
```
|
||||
argocd proj source-integrity [flags]
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```
|
||||
# List git policies
|
||||
argocd proj source-integrity git policies list PROJECT
|
||||
|
||||
# Add a new git policy
|
||||
argocd proj source-integrity git policies add PROJECT ...
|
||||
|
||||
# Update a git policy
|
||||
argocd proj source-integrity git policies update PROJECT POLICY_ID ...
|
||||
|
||||
# Delete a git policy
|
||||
argocd proj source-integrity git policies delete PROJECT POLICY_ID
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for source-integrity
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--argocd-context string The name of the Argo-CD server context to use
|
||||
--auth-token string Authentication token; set this or the ARGOCD_AUTH_TOKEN environment variable
|
||||
--client-crt string Client certificate file
|
||||
--client-crt-key string Client certificate key file
|
||||
--config string Path to Argo CD config (default "/home/user/.config/argocd/config")
|
||||
--controller-name string Name of the Argo CD Application controller; set this or the ARGOCD_APPLICATION_CONTROLLER_NAME environment variable when the controller's name label differs from the default, for example when installing via the Helm chart (default "argocd-application-controller")
|
||||
--core If set to true then CLI talks directly to Kubernetes instead of talking to Argo CD API server
|
||||
--grpc-web Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2.
|
||||
--grpc-web-root-path string Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2. Set web root.
|
||||
-H, --header strings Sets additional header to all requests made by Argo CD CLI. (Can be repeated multiple times to add multiple headers, also supports comma separated headers)
|
||||
--http-retry-max int Maximum number of retries to establish http connection to Argo CD server
|
||||
--insecure Skip server certificate and domain verification
|
||||
--kube-context string Directs the command to the given kube-context
|
||||
--logformat string Set the logging format. One of: json|text (default "json")
|
||||
--loglevel string Set the logging level. One of: debug|info|warn|error (default "info")
|
||||
--plaintext Disable TLS
|
||||
--port-forward Connect to a random argocd-server port using port forwarding
|
||||
--port-forward-namespace string Namespace name which should be used for port forwarding
|
||||
--prompts-enabled Force optional interactive prompts to be enabled or disabled, overriding local configuration. If not specified, the local configuration value will be used, which is false by default.
|
||||
--redis-compress string Enable this if the application controller is configured with redis compression enabled. (possible values: gzip, none) (default "gzip")
|
||||
--redis-haproxy-name string Name of the Redis HA Proxy; set this or the ARGOCD_REDIS_HAPROXY_NAME environment variable when the HA Proxy's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis-ha-haproxy")
|
||||
--redis-name string Name of the Redis deployment; set this or the ARGOCD_REDIS_NAME environment variable when the Redis's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis")
|
||||
--repo-server-name string Name of the Argo CD Repo server; set this or the ARGOCD_REPO_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-repo-server")
|
||||
--server string Argo CD server address
|
||||
--server-crt string Server certificate file
|
||||
--server-name string Name of the Argo CD API server; set this or the ARGOCD_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-server")
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [argocd proj](argocd_proj.md) - Manage projects
|
||||
* [argocd proj source-integrity git](argocd_proj_source-integrity_git.md) - Manage policies for Git repositories
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
# `argocd proj source-integrity git` Command Reference
|
||||
|
||||
## argocd proj source-integrity git
|
||||
|
||||
Manage policies for Git repositories
|
||||
|
||||
```
|
||||
argocd proj source-integrity git [flags]
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```
|
||||
# List git policies
|
||||
argocd proj source-integrity git policies list PROJECT
|
||||
|
||||
# Add a new git policy
|
||||
argocd proj source-integrity git policies add PROJECT ...
|
||||
|
||||
# Update a git policy
|
||||
argocd proj source-integrity git policies update PROJECT POLICY_ID ...
|
||||
|
||||
# Delete a git policy
|
||||
argocd proj source-integrity git policies delete PROJECT POLICY_ID
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for git
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--argocd-context string The name of the Argo-CD server context to use
|
||||
--auth-token string Authentication token; set this or the ARGOCD_AUTH_TOKEN environment variable
|
||||
--client-crt string Client certificate file
|
||||
--client-crt-key string Client certificate key file
|
||||
--config string Path to Argo CD config (default "/home/user/.config/argocd/config")
|
||||
--controller-name string Name of the Argo CD Application controller; set this or the ARGOCD_APPLICATION_CONTROLLER_NAME environment variable when the controller's name label differs from the default, for example when installing via the Helm chart (default "argocd-application-controller")
|
||||
--core If set to true then CLI talks directly to Kubernetes instead of talking to Argo CD API server
|
||||
--grpc-web Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2.
|
||||
--grpc-web-root-path string Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2. Set web root.
|
||||
-H, --header strings Sets additional header to all requests made by Argo CD CLI. (Can be repeated multiple times to add multiple headers, also supports comma separated headers)
|
||||
--http-retry-max int Maximum number of retries to establish http connection to Argo CD server
|
||||
--insecure Skip server certificate and domain verification
|
||||
--kube-context string Directs the command to the given kube-context
|
||||
--logformat string Set the logging format. One of: json|text (default "json")
|
||||
--loglevel string Set the logging level. One of: debug|info|warn|error (default "info")
|
||||
--plaintext Disable TLS
|
||||
--port-forward Connect to a random argocd-server port using port forwarding
|
||||
--port-forward-namespace string Namespace name which should be used for port forwarding
|
||||
--prompts-enabled Force optional interactive prompts to be enabled or disabled, overriding local configuration. If not specified, the local configuration value will be used, which is false by default.
|
||||
--redis-compress string Enable this if the application controller is configured with redis compression enabled. (possible values: gzip, none) (default "gzip")
|
||||
--redis-haproxy-name string Name of the Redis HA Proxy; set this or the ARGOCD_REDIS_HAPROXY_NAME environment variable when the HA Proxy's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis-ha-haproxy")
|
||||
--redis-name string Name of the Redis deployment; set this or the ARGOCD_REDIS_NAME environment variable when the Redis's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis")
|
||||
--repo-server-name string Name of the Argo CD Repo server; set this or the ARGOCD_REPO_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-repo-server")
|
||||
--server string Argo CD server address
|
||||
--server-crt string Server certificate file
|
||||
--server-name string Name of the Argo CD API server; set this or the ARGOCD_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-server")
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [argocd proj source-integrity](argocd_proj_source-integrity.md) - Manage criteria for source integrity
|
||||
* [argocd proj source-integrity git policies](argocd_proj_source-integrity_git_policies.md) - Manage git source integrity policies
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
# `argocd proj source-integrity git policies` Command Reference
|
||||
|
||||
## argocd proj source-integrity git policies
|
||||
|
||||
Manage git source integrity policies
|
||||
|
||||
```
|
||||
argocd proj source-integrity git policies [flags]
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```
|
||||
# List git policies
|
||||
argocd proj source-integrity git policies list PROJECT
|
||||
|
||||
# Add a new git policy
|
||||
argocd proj source-integrity git policies add PROJECT ...
|
||||
|
||||
# Update a git policy
|
||||
argocd proj source-integrity git policies update PROJECT POLICY_ID ...
|
||||
|
||||
# Delete a git policy
|
||||
argocd proj source-integrity git policies delete PROJECT POLICY_ID
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for policies
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--argocd-context string The name of the Argo-CD server context to use
|
||||
--auth-token string Authentication token; set this or the ARGOCD_AUTH_TOKEN environment variable
|
||||
--client-crt string Client certificate file
|
||||
--client-crt-key string Client certificate key file
|
||||
--config string Path to Argo CD config (default "/home/user/.config/argocd/config")
|
||||
--controller-name string Name of the Argo CD Application controller; set this or the ARGOCD_APPLICATION_CONTROLLER_NAME environment variable when the controller's name label differs from the default, for example when installing via the Helm chart (default "argocd-application-controller")
|
||||
--core If set to true then CLI talks directly to Kubernetes instead of talking to Argo CD API server
|
||||
--grpc-web Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2.
|
||||
--grpc-web-root-path string Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2. Set web root.
|
||||
-H, --header strings Sets additional header to all requests made by Argo CD CLI. (Can be repeated multiple times to add multiple headers, also supports comma separated headers)
|
||||
--http-retry-max int Maximum number of retries to establish http connection to Argo CD server
|
||||
--insecure Skip server certificate and domain verification
|
||||
--kube-context string Directs the command to the given kube-context
|
||||
--logformat string Set the logging format. One of: json|text (default "json")
|
||||
--loglevel string Set the logging level. One of: debug|info|warn|error (default "info")
|
||||
--plaintext Disable TLS
|
||||
--port-forward Connect to a random argocd-server port using port forwarding
|
||||
--port-forward-namespace string Namespace name which should be used for port forwarding
|
||||
--prompts-enabled Force optional interactive prompts to be enabled or disabled, overriding local configuration. If not specified, the local configuration value will be used, which is false by default.
|
||||
--redis-compress string Enable this if the application controller is configured with redis compression enabled. (possible values: gzip, none) (default "gzip")
|
||||
--redis-haproxy-name string Name of the Redis HA Proxy; set this or the ARGOCD_REDIS_HAPROXY_NAME environment variable when the HA Proxy's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis-ha-haproxy")
|
||||
--redis-name string Name of the Redis deployment; set this or the ARGOCD_REDIS_NAME environment variable when the Redis's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis")
|
||||
--repo-server-name string Name of the Argo CD Repo server; set this or the ARGOCD_REPO_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-repo-server")
|
||||
--server string Argo CD server address
|
||||
--server-crt string Server certificate file
|
||||
--server-name string Name of the Argo CD API server; set this or the ARGOCD_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-server")
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [argocd proj source-integrity git](argocd_proj_source-integrity_git.md) - Manage policies for Git repositories
|
||||
* [argocd proj source-integrity git policies add](argocd_proj_source-integrity_git_policies_add.md) - Add a git source integrity policy
|
||||
* [argocd proj source-integrity git policies delete](argocd_proj_source-integrity_git_policies_delete.md) - Delete a git source integrity policy
|
||||
* [argocd proj source-integrity git policies list](argocd_proj_source-integrity_git_policies_list.md) - List git source integrity policies
|
||||
* [argocd proj source-integrity git policies update](argocd_proj_source-integrity_git_policies_update.md) - Update a git source integrity policy
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# `argocd proj source-integrity git policies add` Command Reference
|
||||
|
||||
## argocd proj source-integrity git policies add
|
||||
|
||||
Add a git source integrity policy
|
||||
|
||||
```
|
||||
argocd proj source-integrity git policies add PROJECT [flags]
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```
|
||||
# Add a new git policy with repo URLs and GPG settings
|
||||
argocd proj source-integrity git policies add PROJECT \
|
||||
--repo-url 'https://github.com/foo/*' \
|
||||
--gpg-mode strict \
|
||||
--gpg-key D56C4FCA57A46444
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
--gpg-key strings GPG key ID (can be repeated)
|
||||
--gpg-mode string GPG verification mode (strict, head, or none)
|
||||
-h, --help help for add
|
||||
--repo-url strings Repository URL pattern (can be repeated)
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--argocd-context string The name of the Argo-CD server context to use
|
||||
--auth-token string Authentication token; set this or the ARGOCD_AUTH_TOKEN environment variable
|
||||
--client-crt string Client certificate file
|
||||
--client-crt-key string Client certificate key file
|
||||
--config string Path to Argo CD config (default "/home/user/.config/argocd/config")
|
||||
--controller-name string Name of the Argo CD Application controller; set this or the ARGOCD_APPLICATION_CONTROLLER_NAME environment variable when the controller's name label differs from the default, for example when installing via the Helm chart (default "argocd-application-controller")
|
||||
--core If set to true then CLI talks directly to Kubernetes instead of talking to Argo CD API server
|
||||
--grpc-web Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2.
|
||||
--grpc-web-root-path string Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2. Set web root.
|
||||
-H, --header strings Sets additional header to all requests made by Argo CD CLI. (Can be repeated multiple times to add multiple headers, also supports comma separated headers)
|
||||
--http-retry-max int Maximum number of retries to establish http connection to Argo CD server
|
||||
--insecure Skip server certificate and domain verification
|
||||
--kube-context string Directs the command to the given kube-context
|
||||
--logformat string Set the logging format. One of: json|text (default "json")
|
||||
--loglevel string Set the logging level. One of: debug|info|warn|error (default "info")
|
||||
--plaintext Disable TLS
|
||||
--port-forward Connect to a random argocd-server port using port forwarding
|
||||
--port-forward-namespace string Namespace name which should be used for port forwarding
|
||||
--prompts-enabled Force optional interactive prompts to be enabled or disabled, overriding local configuration. If not specified, the local configuration value will be used, which is false by default.
|
||||
--redis-compress string Enable this if the application controller is configured with redis compression enabled. (possible values: gzip, none) (default "gzip")
|
||||
--redis-haproxy-name string Name of the Redis HA Proxy; set this or the ARGOCD_REDIS_HAPROXY_NAME environment variable when the HA Proxy's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis-ha-haproxy")
|
||||
--redis-name string Name of the Redis deployment; set this or the ARGOCD_REDIS_NAME environment variable when the Redis's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis")
|
||||
--repo-server-name string Name of the Argo CD Repo server; set this or the ARGOCD_REPO_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-repo-server")
|
||||
--server string Argo CD server address
|
||||
--server-crt string Server certificate file
|
||||
--server-name string Name of the Argo CD API server; set this or the ARGOCD_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-server")
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [argocd proj source-integrity git policies](argocd_proj_source-integrity_git_policies.md) - Manage git source integrity policies
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
# `argocd proj source-integrity git policies delete` Command Reference
|
||||
|
||||
## argocd proj source-integrity git policies delete
|
||||
|
||||
Delete a git source integrity policy
|
||||
|
||||
```
|
||||
argocd proj source-integrity git policies delete PROJECT POLICY_ID... [flags]
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```
|
||||
# Delete git policy at index 1 and 3 from project named PROJECT
|
||||
argocd proj source-integrity git policies delete PROJECT 1 3
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for delete
|
||||
-y, --yes Skip explicit confirmation
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--argocd-context string The name of the Argo-CD server context to use
|
||||
--auth-token string Authentication token; set this or the ARGOCD_AUTH_TOKEN environment variable
|
||||
--client-crt string Client certificate file
|
||||
--client-crt-key string Client certificate key file
|
||||
--config string Path to Argo CD config (default "/home/user/.config/argocd/config")
|
||||
--controller-name string Name of the Argo CD Application controller; set this or the ARGOCD_APPLICATION_CONTROLLER_NAME environment variable when the controller's name label differs from the default, for example when installing via the Helm chart (default "argocd-application-controller")
|
||||
--core If set to true then CLI talks directly to Kubernetes instead of talking to Argo CD API server
|
||||
--grpc-web Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2.
|
||||
--grpc-web-root-path string Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2. Set web root.
|
||||
-H, --header strings Sets additional header to all requests made by Argo CD CLI. (Can be repeated multiple times to add multiple headers, also supports comma separated headers)
|
||||
--http-retry-max int Maximum number of retries to establish http connection to Argo CD server
|
||||
--insecure Skip server certificate and domain verification
|
||||
--kube-context string Directs the command to the given kube-context
|
||||
--logformat string Set the logging format. One of: json|text (default "json")
|
||||
--loglevel string Set the logging level. One of: debug|info|warn|error (default "info")
|
||||
--plaintext Disable TLS
|
||||
--port-forward Connect to a random argocd-server port using port forwarding
|
||||
--port-forward-namespace string Namespace name which should be used for port forwarding
|
||||
--prompts-enabled Force optional interactive prompts to be enabled or disabled, overriding local configuration. If not specified, the local configuration value will be used, which is false by default.
|
||||
--redis-compress string Enable this if the application controller is configured with redis compression enabled. (possible values: gzip, none) (default "gzip")
|
||||
--redis-haproxy-name string Name of the Redis HA Proxy; set this or the ARGOCD_REDIS_HAPROXY_NAME environment variable when the HA Proxy's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis-ha-haproxy")
|
||||
--redis-name string Name of the Redis deployment; set this or the ARGOCD_REDIS_NAME environment variable when the Redis's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis")
|
||||
--repo-server-name string Name of the Argo CD Repo server; set this or the ARGOCD_REPO_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-repo-server")
|
||||
--server string Argo CD server address
|
||||
--server-crt string Server certificate file
|
||||
--server-name string Name of the Argo CD API server; set this or the ARGOCD_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-server")
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [argocd proj source-integrity git policies](argocd_proj_source-integrity_git_policies.md) - Manage git source integrity policies
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
# `argocd proj source-integrity git policies list` Command Reference
|
||||
|
||||
## argocd proj source-integrity git policies list
|
||||
|
||||
List git source integrity policies
|
||||
|
||||
### Synopsis
|
||||
|
||||
List git source integrity policies.
|
||||
|
||||
The listed policy ID is used to identify given policy in delete and update commands.
|
||||
|
||||
```
|
||||
argocd proj source-integrity git policies list PROJECT [flags]
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```
|
||||
# List all git policies for project PROJECT.
|
||||
argocd proj source-integrity git policies list PROJECT
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
-h, --help help for list
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--argocd-context string The name of the Argo-CD server context to use
|
||||
--auth-token string Authentication token; set this or the ARGOCD_AUTH_TOKEN environment variable
|
||||
--client-crt string Client certificate file
|
||||
--client-crt-key string Client certificate key file
|
||||
--config string Path to Argo CD config (default "/home/user/.config/argocd/config")
|
||||
--controller-name string Name of the Argo CD Application controller; set this or the ARGOCD_APPLICATION_CONTROLLER_NAME environment variable when the controller's name label differs from the default, for example when installing via the Helm chart (default "argocd-application-controller")
|
||||
--core If set to true then CLI talks directly to Kubernetes instead of talking to Argo CD API server
|
||||
--grpc-web Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2.
|
||||
--grpc-web-root-path string Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2. Set web root.
|
||||
-H, --header strings Sets additional header to all requests made by Argo CD CLI. (Can be repeated multiple times to add multiple headers, also supports comma separated headers)
|
||||
--http-retry-max int Maximum number of retries to establish http connection to Argo CD server
|
||||
--insecure Skip server certificate and domain verification
|
||||
--kube-context string Directs the command to the given kube-context
|
||||
--logformat string Set the logging format. One of: json|text (default "json")
|
||||
--loglevel string Set the logging level. One of: debug|info|warn|error (default "info")
|
||||
--plaintext Disable TLS
|
||||
--port-forward Connect to a random argocd-server port using port forwarding
|
||||
--port-forward-namespace string Namespace name which should be used for port forwarding
|
||||
--prompts-enabled Force optional interactive prompts to be enabled or disabled, overriding local configuration. If not specified, the local configuration value will be used, which is false by default.
|
||||
--redis-compress string Enable this if the application controller is configured with redis compression enabled. (possible values: gzip, none) (default "gzip")
|
||||
--redis-haproxy-name string Name of the Redis HA Proxy; set this or the ARGOCD_REDIS_HAPROXY_NAME environment variable when the HA Proxy's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis-ha-haproxy")
|
||||
--redis-name string Name of the Redis deployment; set this or the ARGOCD_REDIS_NAME environment variable when the Redis's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis")
|
||||
--repo-server-name string Name of the Argo CD Repo server; set this or the ARGOCD_REPO_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-repo-server")
|
||||
--server string Argo CD server address
|
||||
--server-crt string Server certificate file
|
||||
--server-name string Name of the Argo CD API server; set this or the ARGOCD_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-server")
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [argocd proj source-integrity git policies](argocd_proj_source-integrity_git_policies.md) - Manage git source integrity policies
|
||||
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
# `argocd proj source-integrity git policies update` Command Reference
|
||||
|
||||
## argocd proj source-integrity git policies update
|
||||
|
||||
Update a git source integrity policy
|
||||
|
||||
```
|
||||
argocd proj source-integrity git policies update PROJECT POLICY_ID [flags]
|
||||
```
|
||||
|
||||
### Examples
|
||||
|
||||
```
|
||||
# Update policy at index to set specific repo URLs, removing the old ones
|
||||
argocd proj source-integrity git policies update PROJECT POLICY_ID \
|
||||
--repo-url 'https://github.com/foo/*'
|
||||
|
||||
# Update policy at index to add and remove repo URLs
|
||||
argocd proj source-integrity git policies update PROJECT POLICY_ID \
|
||||
--add-repo-url 'https://github.com/bar/*' \
|
||||
--delete-repo-url 'https://github.com/foo/*'
|
||||
|
||||
# Update policy GPG mode and keys
|
||||
argocd proj source-integrity git policies update PROJECT POLICY_ID \
|
||||
--gpg-mode strict \
|
||||
--add-gpg-key D56C4FCA57A46444
|
||||
```
|
||||
|
||||
### Options
|
||||
|
||||
```
|
||||
--add-gpg-key strings Add GPG key ID
|
||||
--add-repo-url strings Add repository URL pattern
|
||||
--delete-gpg-key strings Delete GPG key ID
|
||||
--delete-repo-url strings Delete repository URL pattern
|
||||
--gpg-key strings Set GPG key ID (replaces existing)
|
||||
--gpg-mode string Set GPG verification mode (strict, head, or none)
|
||||
-h, --help help for update
|
||||
--repo-url strings Set repository URL pattern (replaces existing)
|
||||
-y, --yes Skip explicit confirmation
|
||||
```
|
||||
|
||||
### Options inherited from parent commands
|
||||
|
||||
```
|
||||
--argocd-context string The name of the Argo-CD server context to use
|
||||
--auth-token string Authentication token; set this or the ARGOCD_AUTH_TOKEN environment variable
|
||||
--client-crt string Client certificate file
|
||||
--client-crt-key string Client certificate key file
|
||||
--config string Path to Argo CD config (default "/home/user/.config/argocd/config")
|
||||
--controller-name string Name of the Argo CD Application controller; set this or the ARGOCD_APPLICATION_CONTROLLER_NAME environment variable when the controller's name label differs from the default, for example when installing via the Helm chart (default "argocd-application-controller")
|
||||
--core If set to true then CLI talks directly to Kubernetes instead of talking to Argo CD API server
|
||||
--grpc-web Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2.
|
||||
--grpc-web-root-path string Enables gRPC-web protocol. Useful if Argo CD server is behind proxy which does not support HTTP2. Set web root.
|
||||
-H, --header strings Sets additional header to all requests made by Argo CD CLI. (Can be repeated multiple times to add multiple headers, also supports comma separated headers)
|
||||
--http-retry-max int Maximum number of retries to establish http connection to Argo CD server
|
||||
--insecure Skip server certificate and domain verification
|
||||
--kube-context string Directs the command to the given kube-context
|
||||
--logformat string Set the logging format. One of: json|text (default "json")
|
||||
--loglevel string Set the logging level. One of: debug|info|warn|error (default "info")
|
||||
--plaintext Disable TLS
|
||||
--port-forward Connect to a random argocd-server port using port forwarding
|
||||
--port-forward-namespace string Namespace name which should be used for port forwarding
|
||||
--prompts-enabled Force optional interactive prompts to be enabled or disabled, overriding local configuration. If not specified, the local configuration value will be used, which is false by default.
|
||||
--redis-compress string Enable this if the application controller is configured with redis compression enabled. (possible values: gzip, none) (default "gzip")
|
||||
--redis-haproxy-name string Name of the Redis HA Proxy; set this or the ARGOCD_REDIS_HAPROXY_NAME environment variable when the HA Proxy's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis-ha-haproxy")
|
||||
--redis-name string Name of the Redis deployment; set this or the ARGOCD_REDIS_NAME environment variable when the Redis's name label differs from the default, for example when installing via the Helm chart (default "argocd-redis")
|
||||
--repo-server-name string Name of the Argo CD Repo server; set this or the ARGOCD_REPO_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-repo-server")
|
||||
--server string Argo CD server address
|
||||
--server-crt string Server certificate file
|
||||
--server-name string Name of the Argo CD API server; set this or the ARGOCD_SERVER_NAME environment variable when the server's name label differs from the default, for example when installing via the Helm chart (default "argocd-server")
|
||||
```
|
||||
|
||||
### SEE ALSO
|
||||
|
||||
* [argocd proj source-integrity git policies](argocd_proj_source-integrity_git_policies.md) - Manage git source integrity policies
|
||||
|
||||
@@ -9,7 +9,7 @@ The criteria distinguish a type of verification they perform, and to which sourc
|
||||
Each application can be a subject of multiple checks, and the sync will be enabled only when all criteria are met.
|
||||
|
||||
> [!NOTE]
|
||||
> Source Integrity Verification is only configured through `AppProject` manifests at this point. CLI and UI are not supported.
|
||||
> Source Integrity Verification is only configured through `AppProject` manifests or CLI. UI is not supported yet.
|
||||
|
||||
> [!NOTE]
|
||||
> Signature verification is not supported for the Application Sets populated by the git generator when they have the `project` field templated.
|
||||
|
||||
+389
@@ -0,0 +1,389 @@
|
||||
// Code generated by mockery; DO NOT EDIT.
|
||||
// github.com/vektra/mockery
|
||||
// template: testify
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apiclient/gpgkey"
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
// NewGPGKeyServiceClient creates a new instance of GPGKeyServiceClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewGPGKeyServiceClient(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *GPGKeyServiceClient {
|
||||
mock := &GPGKeyServiceClient{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
||||
|
||||
// GPGKeyServiceClient is an autogenerated mock type for the GPGKeyServiceClient type
|
||||
type GPGKeyServiceClient struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type GPGKeyServiceClient_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *GPGKeyServiceClient) EXPECT() *GPGKeyServiceClient_Expecter {
|
||||
return &GPGKeyServiceClient_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Create provides a mock function for the type GPGKeyServiceClient
|
||||
func (_mock *GPGKeyServiceClient) Create(ctx context.Context, in *gpgkey.GnuPGPublicKeyCreateRequest, opts ...grpc.CallOption) (*gpgkey.GnuPGPublicKeyCreateResponse, error) {
|
||||
// grpc.CallOption
|
||||
_va := make([]interface{}, len(opts))
|
||||
for _i := range opts {
|
||||
_va[_i] = opts[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, in)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _mock.Called(_ca...)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Create")
|
||||
}
|
||||
|
||||
var r0 *gpgkey.GnuPGPublicKeyCreateResponse
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, *gpgkey.GnuPGPublicKeyCreateRequest, ...grpc.CallOption) (*gpgkey.GnuPGPublicKeyCreateResponse, error)); ok {
|
||||
return returnFunc(ctx, in, opts...)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, *gpgkey.GnuPGPublicKeyCreateRequest, ...grpc.CallOption) *gpgkey.GnuPGPublicKeyCreateResponse); ok {
|
||||
r0 = returnFunc(ctx, in, opts...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*gpgkey.GnuPGPublicKeyCreateResponse)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, *gpgkey.GnuPGPublicKeyCreateRequest, ...grpc.CallOption) error); ok {
|
||||
r1 = returnFunc(ctx, in, opts...)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GPGKeyServiceClient_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create'
|
||||
type GPGKeyServiceClient_Create_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Create is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in *gpgkey.GnuPGPublicKeyCreateRequest
|
||||
// - opts ...grpc.CallOption
|
||||
func (_e *GPGKeyServiceClient_Expecter) Create(ctx interface{}, in interface{}, opts ...interface{}) *GPGKeyServiceClient_Create_Call {
|
||||
return &GPGKeyServiceClient_Create_Call{Call: _e.mock.On("Create",
|
||||
append([]interface{}{ctx, in}, opts...)...)}
|
||||
}
|
||||
|
||||
func (_c *GPGKeyServiceClient_Create_Call) Run(run func(ctx context.Context, in *gpgkey.GnuPGPublicKeyCreateRequest, opts ...grpc.CallOption)) *GPGKeyServiceClient_Create_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 *gpgkey.GnuPGPublicKeyCreateRequest
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(*gpgkey.GnuPGPublicKeyCreateRequest)
|
||||
}
|
||||
var arg2 []grpc.CallOption
|
||||
variadicArgs := make([]grpc.CallOption, len(args)-2)
|
||||
for i, a := range args[2:] {
|
||||
if a != nil {
|
||||
variadicArgs[i] = a.(grpc.CallOption)
|
||||
}
|
||||
}
|
||||
arg2 = variadicArgs
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2...,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *GPGKeyServiceClient_Create_Call) Return(gnuPGPublicKeyCreateResponse *gpgkey.GnuPGPublicKeyCreateResponse, err error) *GPGKeyServiceClient_Create_Call {
|
||||
_c.Call.Return(gnuPGPublicKeyCreateResponse, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *GPGKeyServiceClient_Create_Call) RunAndReturn(run func(ctx context.Context, in *gpgkey.GnuPGPublicKeyCreateRequest, opts ...grpc.CallOption) (*gpgkey.GnuPGPublicKeyCreateResponse, error)) *GPGKeyServiceClient_Create_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Delete provides a mock function for the type GPGKeyServiceClient
|
||||
func (_mock *GPGKeyServiceClient) Delete(ctx context.Context, in *gpgkey.GnuPGPublicKeyQuery, opts ...grpc.CallOption) (*gpgkey.GnuPGPublicKeyResponse, error) {
|
||||
// grpc.CallOption
|
||||
_va := make([]interface{}, len(opts))
|
||||
for _i := range opts {
|
||||
_va[_i] = opts[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, in)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _mock.Called(_ca...)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Delete")
|
||||
}
|
||||
|
||||
var r0 *gpgkey.GnuPGPublicKeyResponse
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, *gpgkey.GnuPGPublicKeyQuery, ...grpc.CallOption) (*gpgkey.GnuPGPublicKeyResponse, error)); ok {
|
||||
return returnFunc(ctx, in, opts...)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, *gpgkey.GnuPGPublicKeyQuery, ...grpc.CallOption) *gpgkey.GnuPGPublicKeyResponse); ok {
|
||||
r0 = returnFunc(ctx, in, opts...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*gpgkey.GnuPGPublicKeyResponse)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, *gpgkey.GnuPGPublicKeyQuery, ...grpc.CallOption) error); ok {
|
||||
r1 = returnFunc(ctx, in, opts...)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GPGKeyServiceClient_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete'
|
||||
type GPGKeyServiceClient_Delete_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Delete is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in *gpgkey.GnuPGPublicKeyQuery
|
||||
// - opts ...grpc.CallOption
|
||||
func (_e *GPGKeyServiceClient_Expecter) Delete(ctx interface{}, in interface{}, opts ...interface{}) *GPGKeyServiceClient_Delete_Call {
|
||||
return &GPGKeyServiceClient_Delete_Call{Call: _e.mock.On("Delete",
|
||||
append([]interface{}{ctx, in}, opts...)...)}
|
||||
}
|
||||
|
||||
func (_c *GPGKeyServiceClient_Delete_Call) Run(run func(ctx context.Context, in *gpgkey.GnuPGPublicKeyQuery, opts ...grpc.CallOption)) *GPGKeyServiceClient_Delete_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 *gpgkey.GnuPGPublicKeyQuery
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(*gpgkey.GnuPGPublicKeyQuery)
|
||||
}
|
||||
var arg2 []grpc.CallOption
|
||||
variadicArgs := make([]grpc.CallOption, len(args)-2)
|
||||
for i, a := range args[2:] {
|
||||
if a != nil {
|
||||
variadicArgs[i] = a.(grpc.CallOption)
|
||||
}
|
||||
}
|
||||
arg2 = variadicArgs
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2...,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *GPGKeyServiceClient_Delete_Call) Return(gnuPGPublicKeyResponse *gpgkey.GnuPGPublicKeyResponse, err error) *GPGKeyServiceClient_Delete_Call {
|
||||
_c.Call.Return(gnuPGPublicKeyResponse, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *GPGKeyServiceClient_Delete_Call) RunAndReturn(run func(ctx context.Context, in *gpgkey.GnuPGPublicKeyQuery, opts ...grpc.CallOption) (*gpgkey.GnuPGPublicKeyResponse, error)) *GPGKeyServiceClient_Delete_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Get provides a mock function for the type GPGKeyServiceClient
|
||||
func (_mock *GPGKeyServiceClient) Get(ctx context.Context, in *gpgkey.GnuPGPublicKeyQuery, opts ...grpc.CallOption) (*v1alpha1.GnuPGPublicKey, error) {
|
||||
// grpc.CallOption
|
||||
_va := make([]interface{}, len(opts))
|
||||
for _i := range opts {
|
||||
_va[_i] = opts[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, in)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _mock.Called(_ca...)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for Get")
|
||||
}
|
||||
|
||||
var r0 *v1alpha1.GnuPGPublicKey
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, *gpgkey.GnuPGPublicKeyQuery, ...grpc.CallOption) (*v1alpha1.GnuPGPublicKey, error)); ok {
|
||||
return returnFunc(ctx, in, opts...)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, *gpgkey.GnuPGPublicKeyQuery, ...grpc.CallOption) *v1alpha1.GnuPGPublicKey); ok {
|
||||
r0 = returnFunc(ctx, in, opts...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*v1alpha1.GnuPGPublicKey)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, *gpgkey.GnuPGPublicKeyQuery, ...grpc.CallOption) error); ok {
|
||||
r1 = returnFunc(ctx, in, opts...)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GPGKeyServiceClient_Get_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Get'
|
||||
type GPGKeyServiceClient_Get_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Get is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in *gpgkey.GnuPGPublicKeyQuery
|
||||
// - opts ...grpc.CallOption
|
||||
func (_e *GPGKeyServiceClient_Expecter) Get(ctx interface{}, in interface{}, opts ...interface{}) *GPGKeyServiceClient_Get_Call {
|
||||
return &GPGKeyServiceClient_Get_Call{Call: _e.mock.On("Get",
|
||||
append([]interface{}{ctx, in}, opts...)...)}
|
||||
}
|
||||
|
||||
func (_c *GPGKeyServiceClient_Get_Call) Run(run func(ctx context.Context, in *gpgkey.GnuPGPublicKeyQuery, opts ...grpc.CallOption)) *GPGKeyServiceClient_Get_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 *gpgkey.GnuPGPublicKeyQuery
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(*gpgkey.GnuPGPublicKeyQuery)
|
||||
}
|
||||
var arg2 []grpc.CallOption
|
||||
variadicArgs := make([]grpc.CallOption, len(args)-2)
|
||||
for i, a := range args[2:] {
|
||||
if a != nil {
|
||||
variadicArgs[i] = a.(grpc.CallOption)
|
||||
}
|
||||
}
|
||||
arg2 = variadicArgs
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2...,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *GPGKeyServiceClient_Get_Call) Return(gnuPGPublicKey *v1alpha1.GnuPGPublicKey, err error) *GPGKeyServiceClient_Get_Call {
|
||||
_c.Call.Return(gnuPGPublicKey, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *GPGKeyServiceClient_Get_Call) RunAndReturn(run func(ctx context.Context, in *gpgkey.GnuPGPublicKeyQuery, opts ...grpc.CallOption) (*v1alpha1.GnuPGPublicKey, error)) *GPGKeyServiceClient_Get_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// List provides a mock function for the type GPGKeyServiceClient
|
||||
func (_mock *GPGKeyServiceClient) List(ctx context.Context, in *gpgkey.GnuPGPublicKeyQuery, opts ...grpc.CallOption) (*v1alpha1.GnuPGPublicKeyList, error) {
|
||||
// grpc.CallOption
|
||||
_va := make([]interface{}, len(opts))
|
||||
for _i := range opts {
|
||||
_va[_i] = opts[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, ctx, in)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _mock.Called(_ca...)
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for List")
|
||||
}
|
||||
|
||||
var r0 *v1alpha1.GnuPGPublicKeyList
|
||||
var r1 error
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, *gpgkey.GnuPGPublicKeyQuery, ...grpc.CallOption) (*v1alpha1.GnuPGPublicKeyList, error)); ok {
|
||||
return returnFunc(ctx, in, opts...)
|
||||
}
|
||||
if returnFunc, ok := ret.Get(0).(func(context.Context, *gpgkey.GnuPGPublicKeyQuery, ...grpc.CallOption) *v1alpha1.GnuPGPublicKeyList); ok {
|
||||
r0 = returnFunc(ctx, in, opts...)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(*v1alpha1.GnuPGPublicKeyList)
|
||||
}
|
||||
}
|
||||
if returnFunc, ok := ret.Get(1).(func(context.Context, *gpgkey.GnuPGPublicKeyQuery, ...grpc.CallOption) error); ok {
|
||||
r1 = returnFunc(ctx, in, opts...)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// GPGKeyServiceClient_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List'
|
||||
type GPGKeyServiceClient_List_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// List is a helper method to define mock.On call
|
||||
// - ctx context.Context
|
||||
// - in *gpgkey.GnuPGPublicKeyQuery
|
||||
// - opts ...grpc.CallOption
|
||||
func (_e *GPGKeyServiceClient_Expecter) List(ctx interface{}, in interface{}, opts ...interface{}) *GPGKeyServiceClient_List_Call {
|
||||
return &GPGKeyServiceClient_List_Call{Call: _e.mock.On("List",
|
||||
append([]interface{}{ctx, in}, opts...)...)}
|
||||
}
|
||||
|
||||
func (_c *GPGKeyServiceClient_List_Call) Run(run func(ctx context.Context, in *gpgkey.GnuPGPublicKeyQuery, opts ...grpc.CallOption)) *GPGKeyServiceClient_List_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
var arg0 context.Context
|
||||
if args[0] != nil {
|
||||
arg0 = args[0].(context.Context)
|
||||
}
|
||||
var arg1 *gpgkey.GnuPGPublicKeyQuery
|
||||
if args[1] != nil {
|
||||
arg1 = args[1].(*gpgkey.GnuPGPublicKeyQuery)
|
||||
}
|
||||
var arg2 []grpc.CallOption
|
||||
variadicArgs := make([]grpc.CallOption, len(args)-2)
|
||||
for i, a := range args[2:] {
|
||||
if a != nil {
|
||||
variadicArgs[i] = a.(grpc.CallOption)
|
||||
}
|
||||
}
|
||||
arg2 = variadicArgs
|
||||
run(
|
||||
arg0,
|
||||
arg1,
|
||||
arg2...,
|
||||
)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *GPGKeyServiceClient_List_Call) Return(gnuPGPublicKeyList *v1alpha1.GnuPGPublicKeyList, err error) *GPGKeyServiceClient_List_Call {
|
||||
_c.Call.Return(gnuPGPublicKeyList, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *GPGKeyServiceClient_List_Call) RunAndReturn(run func(ctx context.Context, in *gpgkey.GnuPGPublicKeyQuery, opts ...grpc.CallOption) (*v1alpha1.GnuPGPublicKeyList, error)) *GPGKeyServiceClient_List_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
Reference in New Issue
Block a user