Documentation ¶
Index ¶
- Constants
- Variables
- func AccountCRHasIAMUserIDLabel(accountCR *awsv1alpha1.Account) bool
- func AddControllerMetricsTransportWrapper(cfg *rest.Config, controllerName string)
- func AddFinalizer(object metav1.Object, finalizer string)
- func AddLabels(object metav1.Object, labels map[string]string)
- func Contains(list []string, s string) bool
- func CreationConditionOlderThan(account awsv1alpha1.Account, duration time.Duration) bool
- func DoNotRequeue() (reconcile.Result, error)
- func FindAWSFederatedAccountAccessCondition(conditions []awsv1alpha1.AWSFederatedAccountAccessCondition, ...) *awsv1alpha1.AWSFederatedAccountAccessCondition
- func FindAWSFederatedRoleCondition(conditions []awsv1alpha1.AWSFederatedRoleCondition, ...) *awsv1alpha1.AWSFederatedRoleCondition
- func FindAccountClaimCondition(conditions []awsv1alpha1.AccountClaimCondition, ...) *awsv1alpha1.AccountClaimCondition
- func FindAccountCondition(conditions []awsv1alpha1.AccountCondition, ...) *awsv1alpha1.AccountCondition
- func GenerateLabel(key, value string) map[string]string
- func GenerateShortUID() string
- func GetControllerMaxReconciles(controllerName string) (int, error)
- func GetEnvironmentBool(key string, fallback bool) bool
- func GetOperatorConfigMap(kubeClient client.Client) (*corev1.ConfigMap, error)
- func GetOperatorStartTime() *metav1.Time
- func InitControllerMaxReconciles(kubeClient client.Client) []error
- func InitOperatorStartTime() error
- func JoinLabelMaps(m1, m2 map[string]string) map[string]string
- func LogAwsError(logger logr.Logger, errMsg string, customError error, err error)
- func MarshalIAMPolicy(role awsv1alpha1.AWSFederatedRole) (string, error)
- func NewClientWithMetricsOrDie(log logr.Logger, mgr manager.Manager, controller string) (client.Client, error)
- func NewReconcilerWithMetrics(wrapped reconcile.Reconciler, controllerName string) reconcile.Reconciler
- func Remove(list []string, s string) []string
- func RequeueAfter(after time.Duration) (reconcile.Result, error)
- func RequeueWithError(err error) (reconcile.Result, error)
- func SetAWSFederatedAccountAccessCondition(conditions []awsv1alpha1.AWSFederatedAccountAccessCondition, ...) []awsv1alpha1.AWSFederatedAccountAccessCondition
- func SetAWSFederatedRoleCondition(conditions []awsv1alpha1.AWSFederatedRoleCondition, ...) []awsv1alpha1.AWSFederatedRoleCondition
- func SetAccountClaimCondition(conditions []awsv1alpha1.AccountClaimCondition, ...) []awsv1alpha1.AccountClaimCondition
- func SetAccountClaimStatus(awsAccountClaim *awsv1alpha1.AccountClaim, message string, reason string, ...)
- func SetAccountCondition(conditions []awsv1alpha1.AccountCondition, ...) []awsv1alpha1.AccountCondition
- func SetAccountStatus(awsAccount *awsv1alpha1.Account, message string, ...)
- func UpdateConditionAlways(_, _, _, _ string) bool
- func UpdateConditionIfReasonOrMessageChange(oldReason, oldMessage, newReason, newMessage string) bool
- func UpdateConditionNever(_, _, _, _ string) bool
- type ControllerMetricsTripper
- type UpdateConditionCheck
Constants ¶
const ( // Finalizer is a constant containing the Kubernetes finalizer used by the AWS Account Operator Finalizer = "finalizer.aws.managed.openshift.io" // WaitTime is the default wait time for an account to become ready, before erroring WaitTime = 25 // SREAssumeRole is the name of the role that SREs need to use to role-chain to get temporary // credentials for a CCS account SREAssumeRole = "RH-SREP-CCS-Access" // AwsSecretName is a constant for the name of the Kubernetes secret that holds the AWS Credentials AwsSecretName = "aws-account-operator-credentials" // #nosec G101 -- This is a false positive )
const ( // DevModeProduction (aka non-development mode) is the default running mode. Metrics are // served from the operator at the /metrics path under the route it creates. AWS support cases // are managed for real. DevModeProduction devMode = "" // DevModeLocal should be used when running via operator-sdk in "local" mode. Metrics are // served up at http://localhost:${metricsPort}/${metricsPath} (metricsP* defined in main.go). // All AWS support case interactions are skipped. DevModeLocal devMode = "local" // DevModeCluster should be used when doing development in a "real" cluster via a Deployment // such as the one in deploy/operator.yaml. Metrics are served as normal (see // DevModeProduction), but AWS support case interactions are skipped (see DevModeLocal). DevModeCluster devMode = "cluster" )
Variables ¶
var ControllerMaxReconciles map[string]int = map[string]int{}
var DetectDevMode devMode = devMode(strings.ToLower(os.Getenv(envDevMode)))
DetectDevMode gets the envDevMode environment variable to detect if we are running in production or a development environment.
Functions ¶
func AccountCRHasIAMUserIDLabel ¶
func AccountCRHasIAMUserIDLabel(accountCR *awsv1alpha1.Account) bool
AccountCRHasIAMUserIDLabel check for label
func AddControllerMetricsTransportWrapper ¶
AddControllerMetricsTransportWrapper adds a transport wrapper to the given rest config which exposes metrics based on the requests being made.
func AddFinalizer ¶
AddFinalizer adds a finalizer to an object
func CreationConditionOlderThan ¶
func CreationConditionOlderThan(account awsv1alpha1.Account, duration time.Duration) bool
creationOlderThan returns true if the given account has been in a creation state for longer than the given time, else false
func DoNotRequeue ¶
func FindAWSFederatedAccountAccessCondition ¶
func FindAWSFederatedAccountAccessCondition(conditions []awsv1alpha1.AWSFederatedAccountAccessCondition, conditionType awsv1alpha1.AWSFederatedAccountAccessConditionType) *awsv1alpha1.AWSFederatedAccountAccessCondition
FindAWSFederatedAccountAccessCondition Condition finds in the condition that has the specified condition type in the given list. If none exists, then returns nil. TODO: This should be moved to the AccountAccess struct
func FindAWSFederatedRoleCondition ¶
func FindAWSFederatedRoleCondition(conditions []awsv1alpha1.AWSFederatedRoleCondition, conditionType awsv1alpha1.AWSFederatedRoleConditionType) *awsv1alpha1.AWSFederatedRoleCondition
FindAWSFederatedRoleCondition Condition finds in the condition that has the specified condition type in the given list. If none exists, then returns nil. TODO: this should be moved to the FederatedRole struct
func FindAccountClaimCondition ¶
func FindAccountClaimCondition(conditions []awsv1alpha1.AccountClaimCondition, conditionType awsv1alpha1.AccountClaimConditionType) *awsv1alpha1.AccountClaimCondition
FindAccountClaimCondition finds in the condition that has the specified condition type in the given list. If none exists, then returns nil. TODO: this should probably be handled within the AccountClaim struct
func FindAccountCondition ¶
func FindAccountCondition(conditions []awsv1alpha1.AccountCondition, conditionType awsv1alpha1.AccountConditionType) *awsv1alpha1.AccountCondition
FindAccountCondition finds in the condition that has the specified condition type in the given list. If none exists, then returns nil. TODO: this should be moved to the account struct
func GenerateLabel ¶
GenerateLabel returns a ObjectMeta Labels
func GetControllerMaxReconciles ¶
GetControllerMaxReconciles gets the default configMap and then gets the amount of concurrent reconciles to run from it
func GetEnvironmentBool ¶
func GetOperatorConfigMap ¶
GetOperatorConfigMap retrieves the default configMap data for the AWS Account Operator from Kubernetes
func GetOperatorStartTime ¶
GetOperatorStartTime returns the time at which the operator was brought up, assuming said bringup was well-behaved and invoked InitOperatorStartTime(). If not, this will return the zero time.
func InitOperatorStartTime ¶
func InitOperatorStartTime() error
InitOperatorStartTime should be invoked exactly once, early in operator bringup, before controllers are started. The value can subsequently be retrieved via GetOperatorStartTime(). Returns an error if the time was already initialized.
func JoinLabelMaps ¶
JoinLabelMaps adds a label to CR
func LogAwsError ¶
LogAwsError formats and logs aws error and returns if err was an awserr
func MarshalIAMPolicy ¶
func MarshalIAMPolicy(role awsv1alpha1.AWSFederatedRole) (string, error)
MarshalIAMPolicy converts a role CR into a JSON policy that is acceptable to AWS
func NewClientWithMetricsOrDie ¶
func NewClientWithMetricsOrDie(log logr.Logger, mgr manager.Manager, controller string) (client.Client, error)
NewClientWithMetricsOrDie creates a new controller-runtime client with a wrapper which increments metrics for requests by controller name, HTTP method, URL path, and HTTP status. The client will re-use the manager's cache. This should be used in all controllers.
func NewReconcilerWithMetrics ¶
func NewReconcilerWithMetrics(wrapped reconcile.Reconciler, controllerName string) reconcile.Reconciler
NewReconcilerWithMetrics wraps an existing Reconciler such that calls to Reconcile report the reconcileDuration metric.
func SetAWSFederatedAccountAccessCondition ¶
func SetAWSFederatedAccountAccessCondition( conditions []awsv1alpha1.AWSFederatedAccountAccessCondition, conditionType awsv1alpha1.AWSFederatedAccountAccessConditionType, status corev1.ConditionStatus, reason string, message string, updateConditionCheck UpdateConditionCheck, ) []awsv1alpha1.AWSFederatedAccountAccessCondition
SetAWSFederatedAccountAccessCondition sets a condition on a Account resource's status TODO: this should be moved to the FederatedAccountAccess struct
func SetAWSFederatedRoleCondition ¶
func SetAWSFederatedRoleCondition( conditions []awsv1alpha1.AWSFederatedRoleCondition, conditionType awsv1alpha1.AWSFederatedRoleConditionType, status corev1.ConditionStatus, reason string, message string, updateConditionCheck UpdateConditionCheck, ) []awsv1alpha1.AWSFederatedRoleCondition
SetAWSFederatedRoleCondition sets a condition on a AWSFederatedRole resource's status TODO: This should be moved to the FederatedRole CR
func SetAccountClaimCondition ¶
func SetAccountClaimCondition( conditions []awsv1alpha1.AccountClaimCondition, conditionType awsv1alpha1.AccountClaimConditionType, status corev1.ConditionStatus, reason string, message string, updateConditionCheck UpdateConditionCheck, ccs bool, ) []awsv1alpha1.AccountClaimCondition
SetAccountClaimCondition sets a condition on a AccountClaim resource's status TODO: this should probably be handled within the AccountClaim struct
func SetAccountClaimStatus ¶
func SetAccountClaimStatus(awsAccountClaim *awsv1alpha1.AccountClaim, message string, reason string, ctype awsv1alpha1.AccountClaimConditionType, state awsv1alpha1.ClaimStatus)
SetAccountClaimStatus sets the condition and state of an accountClaim
func SetAccountCondition ¶
func SetAccountCondition( conditions []awsv1alpha1.AccountCondition, conditionType awsv1alpha1.AccountConditionType, status corev1.ConditionStatus, reason string, message string, updateConditionCheck UpdateConditionCheck, ccs bool, ) []awsv1alpha1.AccountCondition
SetAccountCondition sets a condition on a Account resource's status TODO: This should probably be handled within the Account Struct
func SetAccountStatus ¶
func SetAccountStatus(awsAccount *awsv1alpha1.Account, message string, ctype awsv1alpha1.AccountConditionType, state string)
SetAccountStatus sets the condition and state of an account
func UpdateConditionAlways ¶
UpdateConditionAlways returns true. The condition will always be updated.
func UpdateConditionIfReasonOrMessageChange ¶
func UpdateConditionIfReasonOrMessageChange(oldReason, oldMessage, newReason, newMessage string) bool
UpdateConditionIfReasonOrMessageChange returns true if there is a change in the reason or the message of the condition.
func UpdateConditionNever ¶
UpdateConditionNever return false. The condition will never be updated, unless there is a change in the status of the condition.
Types ¶
type ControllerMetricsTripper ¶
type ControllerMetricsTripper struct { http.RoundTripper Controller string }
ControllerMetricsTripper is a RoundTripper implementation which tracks our metrics for client requests.
type UpdateConditionCheck ¶
UpdateConditionCheck tests whether a condition should be updated from the old condition to the new condition. Returns true if the condition should be updated.