Documentation
¶
Index ¶
- Variables
- func DeleteCredentialSecrets(ctx context.Context, managedClient client.Client, in io.Reader, out io.Writer) error
- func RenderCredRequestTable(report *DiagnosticReport, out io.Writer)
- func RenderReport(report *DiagnosticReport, out io.Writer)
- func RotateSecret(ctx context.Context, input *RotateSecretInput) error
- func VerifyRotationPermissions(out io.Writer, awsClient awsprovider.Client, accountID string, username string) error
- type AWSCredsInput
- type CredRequestStatus
- type DiagnosticReport
- type Finding
- type InsufficientPermissionsError
- type KeyStatus
- type PermissionResult
- type RotateSecretInput
- type SecretStatus
Constants ¶
This section is empty.
Variables ¶
var CRSecretPollInterval = 5 * time.Second
CRSecretPollInterval is the delay between CR health checks after deleting a secret.
var CRSecretPollTimeout = 60 * time.Second
CRSecretPollTimeout is the maximum time to wait for CCO to recreate a secret.
var RotationRequiredActions = []string{
"iam:CreateAccessKey",
"iam:CreateUser",
"iam:DeleteAccessKey",
"iam:DeleteUser",
"iam:DeleteUserPolicy",
"iam:GetUser",
"iam:GetUserPolicy",
"iam:ListAccessKeys",
"iam:PutUserPolicy",
"iam:TagUser",
}
RotationRequiredActions are the IAM actions needed by the rotation tooling to create/delete access keys and manage IAM users.
var SyncMaxRetries = 6
SyncMaxRetries is the maximum number of ClusterSync poll attempts.
var SyncPollInterval = 5 * time.Second
SyncPollInterval is the delay between ClusterSync status checks.
Functions ¶
func DeleteCredentialSecrets ¶ added in v0.62.0
func DeleteCredentialSecrets(ctx context.Context, managedClient client.Client, in io.Reader, out io.Writer) error
DeleteCredentialSecrets sequentially deletes each credential secret and waits for CCO to recreate it before proceeding to the next one.
func RenderCredRequestTable ¶ added in v0.62.0
func RenderCredRequestTable(report *DiagnosticReport, out io.Writer)
RenderCredRequestTable outputs the CredentialRequest secrets table.
func RenderReport ¶ added in v0.62.0
func RenderReport(report *DiagnosticReport, out io.Writer)
RenderReport formats the diagnostic report as a human-readable table.
func RotateSecret ¶
func RotateSecret(ctx context.Context, input *RotateSecretInput) error
RotateSecret performs the IAM credential rotation workflow:
- Validates the Account CR (not STS, has iamUserId label)
- Resolves the osdManagedAdmin username
- Verifies rotation permissions via SimulatePrincipalPolicy
- Creates a new IAM access key
- Updates k8s secrets on hive
- Creates a SyncSet to push credentials to the cluster
- Polls ClusterSync for completion and cleans up the SyncSet
- Optionally rotates osdCcsAdmin credentials
func VerifyRotationPermissions ¶
func VerifyRotationPermissions(out io.Writer, awsClient awsprovider.Client, accountID string, username string) error
VerifyRotationPermissions checks if the assumed role has the necessary IAM permissions to perform secret rotation by simulating the required actions. Uses simulateActions internally for consistency with the diagnostic path.
Types ¶
type AWSCredsInput ¶ added in v0.62.0
type AWSCredsInput struct {
ClusterID string
ClusterName string
ClusterExternalID string
IsCCS bool
AWSAccountID string
AccountCRName string
Account *awsv1alpha1.Account
AdminUsername string
AwsClient awsprovider.Client
HiveKubeClient client.Client
ManagedClient client.Client
Log *logrus.Logger
Out io.Writer
}
AWSCredsInput holds all resolved dependencies needed for both diagnostics and rotation. The CLI layer resolves AWS and k8s clients before calling DiagnoseCredentials or RotateCredentials.
type CredRequestStatus ¶ added in v0.62.0
type DiagnosticReport ¶ added in v0.62.0
type DiagnosticReport struct {
ClusterID string
ClusterName string
ClusterExternalID string
IsCCS bool
AWSAccountID string
AccountCRName string
ManagedAdminUser string
CcsAdminUser string
CallerARN string
CallerAccount string
Keys []KeyStatus
Secrets []SecretStatus
CredRequests []CredRequestStatus
Permissions []PermissionResult
Findings []Finding
AllPermissionsOK bool
AllSecretsInSync bool
RootKeyInSync bool
ClusterRootKeyID string
HiveAccountKeyID string
}
func DiagnoseCRSecrets ¶ added in v0.62.0
func DiagnoseCRSecrets(ctx context.Context, hiveClient client.Client, managedClient client.Client, accountCRName string, account *awsv1alpha1.Account, out io.Writer) (*DiagnosticReport, error)
DiagnoseCRSecrets produces a lightweight report of just the CredentialRequest secrets, comparing the cluster's root credential (kube-system/aws-creds) against the Hive account secret to detect staleness.
func DiagnoseCredentials ¶ added in v0.62.0
func DiagnoseCredentials(ctx context.Context, input *AWSCredsInput) (*DiagnosticReport, error)
DiagnoseCredentials runs a full read-only diagnostic of IAM keys, Hive secrets, CredentialRequests, and IAM permissions, returning a structured report.
type InsufficientPermissionsError ¶
type InsufficientPermissionsError struct {
DeniedActions []string
}
InsufficientPermissionsError is returned when SimulatePrincipalPolicy reports that one or more required IAM actions are denied.
func (*InsufficientPermissionsError) Error ¶
func (e *InsufficientPermissionsError) Error() string
Error returns a human-readable message listing the denied IAM actions.
type PermissionResult ¶ added in v0.62.0
type RotateSecretInput ¶
type RotateSecretInput struct {
// AccountCRName is the name of the Account CR.
AccountCRName string
// Account is the pre-fetched Account CR.
Account *awsv1alpha1.Account
// OsdManagedAdminUsername is an explicit admin username override.
// If empty, it is derived from the Account CR's iamUserId label.
OsdManagedAdminUsername string
// UpdateManagedAdminCreds controls whether osdManagedAdmin credentials are rotated.
UpdateManagedAdminCreds bool
// UpdateCcsCreds controls whether osdCcsAdmin credentials are also rotated.
UpdateCcsCreds bool
// AwsClient is the fully-authenticated AWS client with permissions in the
// target AWS account (after all role chaining has been completed).
AwsClient awsprovider.Client
// HiveKubeClient is the k8s client connected to the hive cluster.
HiveKubeClient client.Client
// ManagedClusterClient is the k8s client connected to the managed cluster
// (via backplane using the target OCM environment). Used to delete
// CredentialRequests so CCO recreates them with the new credentials.
ManagedClusterClient client.Client
// DryRun, when true, prints what actions would be taken without performing
// any mutating operations (no AWS key creation/deletion, no k8s resource
// creation/deletion/updates).
DryRun bool
// Report is the pre-computed diagnostic report from the snapshot phase.
// Used to display key/secret context during interactive key deletion.
Report *DiagnosticReport
// Log is the logger for operational messages (writes to stderr).
Log *logrus.Logger
// SkipPermissionCheck skips the managed-admin permission verification when
// the caller has already run diagnostics and the user confirmed despite failures.
SkipPermissionCheck bool
// In is the reader for interactive prompts (defaults to os.Stdin).
In io.Reader
// Out is the writer for structured report output (writes to stdout).
Out io.Writer
}
RotateSecretInput holds all resolved dependencies for secret rotation. The CLI layer is responsible for resolving AWS and k8s clients before calling RotateSecret.