github.com/kyma-project/kyma-environment-broker@v0.0.1/internal/process/steps/lifecycle_manager.go (about)

     1  package steps
     2  
     3  import (
     4  	"fmt"
     5  	"strings"
     6  
     7  	"github.com/kyma-project/kyma-environment-broker/internal/broker"
     8  
     9  	"github.com/kyma-project/kyma-environment-broker/internal"
    10  	"sigs.k8s.io/controller-runtime/pkg/client"
    11  )
    12  
    13  // ApplyLabelsAndAnnotationsForLM Set common labels and annotations for kyma lifecycle manager
    14  func ApplyLabelsAndAnnotationsForLM(object client.Object, operation internal.Operation) {
    15  	l := object.GetLabels()
    16  	if l == nil {
    17  		l = make(map[string]string)
    18  	}
    19  	l["kyma-project.io/instance-id"] = operation.InstanceID
    20  	l["kyma-project.io/runtime-id"] = operation.RuntimeID
    21  	l["kyma-project.io/broker-plan-id"] = operation.ProvisioningParameters.PlanID
    22  	l["kyma-project.io/broker-plan-name"] = broker.PlanNamesMapping[operation.ProvisioningParameters.PlanID]
    23  	l["kyma-project.io/global-account-id"] = operation.GlobalAccountID
    24  	l["kyma-project.io/subaccount-id"] = operation.SubAccountID
    25  	l["kyma-project.io/shoot-name"] = operation.ShootName
    26  	l["kyma-project.io/region"] = operation.Region
    27  	if operation.ProvisioningParameters.PlatformRegion != "" {
    28  		l["kyma-project.io/platform-region"] = operation.ProvisioningParameters.PlatformRegion
    29  	}
    30  	l["operator.kyma-project.io/kyma-name"] = KymaName(operation)
    31  	l["operator.kyma-project.io/managed-by"] = "lifecycle-manager"
    32  	if isKymaResourceInternal(operation) {
    33  		l["operator.kyma-project.io/internal"] = "true"
    34  	}
    35  
    36  	object.SetLabels(l)
    37  
    38  	a := object.GetAnnotations()
    39  	if a == nil {
    40  		a = make(map[string]string)
    41  	}
    42  	a["skr-domain"] = operation.ShootDomain
    43  	object.SetAnnotations(a)
    44  }
    45  
    46  func KymaKubeconfigName(operation internal.Operation) string {
    47  	return fmt.Sprintf("kubeconfig-%v", KymaName(operation))
    48  }
    49  
    50  func KymaName(operation internal.Operation) string {
    51  	if operation.KymaResourceName != "" {
    52  		return operation.KymaResourceName
    53  	}
    54  	return strings.ToLower(operation.RuntimeID)
    55  }
    56  
    57  func isKymaResourceInternal(operation internal.Operation) bool {
    58  	return !*operation.ProvisioningParameters.ErsContext.DisableEnterprisePolicyFilter()
    59  }