Documentation
¶
Index ¶
- type Account
- type AccountToken
- type Client
- func (c *Client) CreateAccount(ctx context.Context, username string, password string) (*Account, annotations.Annotations, error)
- func (c *Client) GetAccounts(ctx context.Context) ([]*Account, error)
- func (c *Client) GetDefaultRole(ctx context.Context) (string, error)
- func (c *Client) GetRBACConfigMap(ctx context.Context) (*corev1.ConfigMap, error)
- func (c *Client) GetRoleSubjects(ctx context.Context, roleName string) ([]string, error)
- func (c *Client) GetRoles(ctx context.Context) ([]*Role, annotations.Annotations, error)
- func (c *Client) RemoveUserRole(ctx context.Context, userID string, roleID string) (annotations.Annotations, error)
- func (c *Client) UpdateUserPassword(ctx context.Context, username string, password string) error
- func (c *Client) UpdateUserRole(ctx context.Context, userID string, roleID string) (annotations.Annotations, error)
- type ConfigMap
- type Group
- type GroupBinding
- type PolicyBinding
- type PolicyDefinition
- type PolicyGrant
- type Role
- type UpdateUserPasswordRequest
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 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 ¶
GetAccounts fetches a list of accounts from ArgoCD using the API. Endpoint: GET /api/v1/account.
func (*Client) GetDefaultRole ¶
func (*Client) GetRBACConfigMap ¶ added in v0.1.0
GetRBACConfigMap fetches the argocd-rbac-cm ConfigMap from the Kubernetes cluster using the K8s SDK.
func (*Client) GetRoleSubjects ¶
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
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 Group ¶
type Group struct {
Name string
}
Group represents a group from the ArgoCD RBAC config map.
type GroupBinding ¶
GroupBinding represents a 'g' line in the policy, binding a group to a role.
type PolicyBinding ¶
PolicyBinding represents a 'g' line in the policy, binding a subject to a role.
type PolicyDefinition ¶
PolicyDefinition represents a 'p' line, defining a permission for a role.
type PolicyGrant ¶
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.