func AddLabels(object metav1.Object, labels map[string]string) {
	existingLabels := object.GetLabels()
	object.SetLabels(JoinLabelMaps(labels, existingLabels))
}
AddLabels adds a map of labels to an object
package utils
import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"os"
	"strings"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"sigs.k8s.io/controller-runtime/pkg/client"
	"github.com/go-logr/logr"
	awsv1alpha1 "github.com/openshift/aws-account-operator/pkg/apis/aws/v1alpha1"
	corev1 "k8s.io/api/core/v1"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/apimachinery/pkg/types"
	"k8s.io/apimachinery/pkg/util/rand"
	"k8s.io/apimachinery/pkg/util/sets"
)
const (
	Finalizer = "finalizer.aws.managed.openshift.io"
	WaitTime = 25
	envDevMode = "FORCE_DEV_MODE"
	SREAssumeRole = "RH-SREP-CCS-Access"
	AwsSecretName = "aws-account-operator-credentials"
)
var operatorStartTime metav1.Time
func InitOperatorStartTime() error {
	if !operatorStartTime.IsZero() {
		return errors.New("Attempt to initialize start time twice")
	}
	operatorStartTime = metav1.Now()
	return nil
}
func GetOperatorStartTime() *metav1.Time {
	return &operatorStartTime
}
type awsStatement struct {
	Effect    string                 `json:"Effect"`
	Action    []string               `json:"Action"`
	Resource  []string               `json:"Resource,omitempty"`
	Condition *awsv1alpha1.Condition `json:"Condition,omitempty"`
	Principal *awsv1alpha1.Principal `json:"Principal,omitempty"`
}
type devMode string
const (
	DevModeProduction devMode = ""
	DevModeLocal devMode = "local"
	DevModeCluster devMode = "cluster"
)
var DetectDevMode devMode = devMode(strings.ToLower(os.Getenv(envDevMode)))
type awsPolicy struct {
	Version   string
	Statement []awsStatement
}
func MarshalIAMPolicy(role awsv1alpha1.AWSFederatedRole) (string, error) {
	statements := []awsStatement{}
	for _, statement := range role.Spec.AWSCustomPolicy.Statements {
		statements = append(statements, awsStatement(statement))
	}
	policyDoc := awsPolicy{
		Version:   "2012-10-17",
		Statement: statements,
	}
	jsonPolicyDoc, err := json.Marshal(&policyDoc)
	if err != nil {
		return "", err
	}
	return string(jsonPolicyDoc), nil
}
func AddFinalizer(object metav1.Object, finalizer string) {
	finalizers := sets.NewString(object.GetFinalizers()...)
	finalizers.Insert(finalizer)
	object.SetFinalizers(finalizers.List())
}