client

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Name         string         `json:"name"`
	Enabled      bool           `json:"enabled"`
	Capabilities []string       `json:"capabilities"`
	Tokens       []AccountToken `json:"tokens,omitempty"`
}

Account represents an account from the ArgoCD CLI.

type AccountToken

type AccountToken struct {
	ID       string `json:"id"`
	IssuedAt int64  `json:"issuedAt"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client provides methods to interact with Argo CD via its REST API.

func NewClient

func NewClient(ctx context.Context, apiUrl string, username string, password string,
	kubeconfigFile []byte, insecureSkipVerify bool, caCertData []byte) (*Client, error)

NewClient creates a new API Client instance.

func (*Client) CreateAccount

func (c *Client) CreateAccount(ctx context.Context, username string, password string) (*Account, annotations.Annotations, error)

func (*Client) GetAccounts

func (c *Client) GetAccounts(ctx context.Context) ([]*Account, error)

GetAccounts fetches a list of accounts from ArgoCD using the API. Endpoint: GET /api/v1/account.

func (*Client) GetDefaultRole

func (c *Client) GetDefaultRole(ctx context.Context) (string, error)

func (*Client) GetRBACConfigMap added in v0.1.0

func (c *Client) GetRBACConfigMap(ctx context.Context) (*corev1.ConfigMap, error)

GetRBACConfigMap fetches the argocd-rbac-cm ConfigMap from the Kubernetes cluster using the K8s SDK.

func (*Client) GetRoleSubjects

func (c *Client) GetRoleSubjects(ctx context.Context, roleName string) ([]string, error)

GetRoleSubjects returns a list of subjects (users/groups) that have a given role. It parses the 'policy.csv' data and filters for grants matching the roleName.

func (*Client) GetRoles

func (c *Client) GetRoles(ctx context.Context) ([]*Role, annotations.Annotations, error)

GetRoles fetches a list of roles from the ArgoCD RBAC config map using the Kubernetes SDK. It parses role definitions and grants from the 'policy.csv' key. It also includes the two basic built-in roles: 'readonly' and 'admin' which are not in the ConfigMap.

func (*Client) RemoveUserRole

func (c *Client) RemoveUserRole(ctx context.Context, userID string, roleID string) (annotations.Annotations, error)

RemoveUserRole removes a role grant from a user in the `argocd-rbac-cm` ConfigMap. It reads the existing `policy.csv`, removes the grant, and patches the ConfigMap using the Kubernetes SDK.

func (*Client) UpdateUserPassword added in v0.1.0

func (c *Client) UpdateUserPassword(ctx context.Context, username string, password string) error

UpdateUserPassword updates a user's password using the ArgoCD API. Endpoint: PUT /api/v1/account/password.

func (*Client) UpdateUserRole

func (c *Client) UpdateUserRole(ctx context.Context, userID string, roleID string) (annotations.Annotations, error)

type ConfigMap

type ConfigMap struct {
	Data map[string]string `json:"data"`
}

ConfigMap is used to unmarshal the data from kubectl.

type Group

type Group struct {
	Name string
}

Group represents a group from the ArgoCD RBAC config map.

type GroupBinding

type GroupBinding struct {
	Group string
	Role  string
}

GroupBinding represents a 'g' line in the policy, binding a group to a role.

type PolicyBinding

type PolicyBinding struct {
	Subject string
	Role    string
}

PolicyBinding represents a 'g' line in the policy, binding a subject to a role.

type PolicyDefinition

type PolicyDefinition struct {
	Role     string
	Resource string
	Action   string
}

PolicyDefinition represents a 'p' line, defining a permission for a role.

type PolicyGrant

type PolicyGrant struct {
	Subject string
	Role    string
}

PolicyGrant represents a 'g' policy from the ArgoCD RBAC config map.

type Role

type Role struct {
	Name string
}

Role represents a role from the ArgoCD RBAC config map.

type UpdateUserPasswordRequest added in v0.1.0

type UpdateUserPasswordRequest struct {
	CurrentPassword string `json:"currentPassword"`
	Name            string `json:"name"`
	NewPassword     string `json:"newPassword"`
}

UpdateUserPasswordRequest represents the request body for updating a user's password.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL