...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package k8s
16
17 import (
18 "fmt"
19 "time"
20
21 "k8s.io/apimachinery/pkg/types"
22 )
23
24 type ManagementConflictPreventionPolicy string
25
26
27 const (
28 CNRMGroup = "cnrm.cloud.google.com"
29 ApiDomainSuffix = ".cnrm.cloud.google.com"
30 SystemNamespace = "cnrm-system"
31 ControllerManagerNamePrefix = "cnrm-controller-manager"
32 ControllerMaxConcurrentReconciles = 20
33 ReconcileDeadline = 59 * time.Minute
34 TimeToLeaseExpiration = 40 * time.Minute
35 TimeToLeaseRenewal = 20 * time.Minute
36 MeanReconcileReenqueuePeriod = 10 * time.Minute
37 JitterFactor = 2.0
38 UpToDate = "UpToDate"
39 UpToDateMessage = "The resource is up to date"
40 Created = "Created"
41 CreatedMessage = "Successfully created"
42 CreateFailed = "CreateFailed"
43 CreateFailedMessageTmpl = "Create call failed: %v"
44 Updating = "Updating"
45 UpdatingMessage = "Update in progress"
46 UpdateFailed = "UpdateFailed"
47 Deleting = "Deleting"
48 DeletingMessage = "Deletion in progress"
49 Deleted = "Deleted"
50 DeletedMessage = "Successfully deleted"
51 DeleteFailed = "DeleteFailed"
52 NoCondition = "NoCondition"
53 DeleteFailedMessageTmpl = "Delete call failed: %v"
54 Unmanaged = "Unmanaged"
55 UnmanagedMessageTmpl = "No controller is managing this resource. Check if a ConfigConnectorContext exists for resource's namespace, '%v'"
56 ControllerFinalizerName = "cnrm.cloud.google.com/finalizer"
57 DeletionDefenderFinalizerName = "cnrm.cloud.google.com/deletion-defender"
58 DependencyNotReady = "DependencyNotReady"
59 DependencyNotFound = "DependencyNotFound"
60 DependencyInvalid = "DependencyInvalid"
61 ManagementConflict = "ManagementConflict"
62 PreActuationTransformFailed = "PreActuationTransformFailed"
63 PostActuationTransformFailed = "PostActuationTransformFailed"
64 DeletionPolicyDelete = "delete"
65 DeletionPolicyAbandon = "abandon"
66 AnnotationPrefix = CNRMGroup
67 NamespaceEnvVar = "NAMESPACE"
68 ImmediateReconcileRequestsBufferSize = 10000
69 MaxNumResourceWatcherRoutines = 10000
70
71 ControllerManagedFieldManager = "cnrm-controller-manager"
72 UnmanagedDetectorFieldManager = "cnrm-unmanaged-detector"
73 SupportsSSAManager = "supports-ssa"
74
75
76 ManagementConflictPreventionPolicyNone = "none"
77 ManagementConflictPreventionPolicyResource = "resource"
78
79
80 StateMergeIntoSpec = "merge"
81 StateAbsentInSpec = "absent"
82
83
84 LastAppliedConfigurationAnnotation = "kubectl.kubernetes.io/last-applied-configuration"
85 ManagedFieldsTypeFieldsV1 = "FieldsV1"
86
87 ResourceIDFieldName = "resourceID"
88 ResourceIDFieldPath = "spec." + ResourceIDFieldName
89
90
91 SelfLinkFieldName = "selfLink"
92
93 StabilityLevelStable = "stable"
94 StabilityLevelAlpha = "alpha"
95
96 KCCAPIVersion = "v1beta1"
97 KCCAPIVersionV1Alpha1 = "v1alpha1"
98 )
99
100 var (
101 DeletionPolicyAnnotation = FormatAnnotation("deletion-policy")
102 ReconcileIntervalInSecondsAnnotation = FormatAnnotation("reconcile-interval-in-seconds")
103
104
105 ProjectIDAnnotation = FormatAnnotation("project-id")
106 FolderIDAnnotation = FormatAnnotation("folder-id")
107 OrgIDAnnotation = FormatAnnotation("organization-id")
108 ContainerAnnotations = []string{
109 ProjectIDAnnotation,
110 FolderIDAnnotation,
111 OrgIDAnnotation,
112 }
113
114 ManagementConflictPreventionPolicyAnnotation = "management-conflict-prevention-policy"
115 ManagementConflictPreventionPolicyFullyQualifiedAnnotation = FormatAnnotation(ManagementConflictPreventionPolicyAnnotation)
116 ManagementConflictPreventionPolicyValues = []string{
117 ManagementConflictPreventionPolicyNone,
118 ManagementConflictPreventionPolicyResource,
119 }
120
121 KCCComponentLabel = FormatAnnotation("component")
122 KCCSystemLabel = FormatAnnotation("system")
123 KCCVersionLabel = FormatAnnotation("version")
124 ScopedNamespaceLabel = FormatAnnotation("scoped-namespace")
125 DCL2CRDLabel = FormatAnnotation("dcl2crd")
126 KCCStabilityLabel = FormatAnnotation("stability-level")
127
128 MutableButUnreadableFieldsAnnotation = FormatAnnotation("mutable-but-unreadable-fields")
129 ObservedSecretVersionsAnnotation = FormatAnnotation("observed-secret-versions")
130
131 SupportsSSAAnnotation = FormatAnnotation("supports-ssa")
132
133 BlueprintAttributionAnnotation = FormatAnnotation("blueprint")
134
135 StateIntoSpecAnnotation = FormatAnnotation("state-into-spec")
136 StateIntoSpecAnnotationValues = []string{
137 StateMergeIntoSpec,
138 StateAbsentInSpec,
139 }
140
141 WebhookTimeoutSeconds = int32(10)
142
143 ReservedStatusFieldNamesForFutureUse = []string{"generation"}
144
145 NamespaceIDConfigMapNN = types.NamespacedName{
146 Namespace: SystemNamespace,
147 Name: "namespace-id",
148 }
149
150
151
152 IgnoredKindList = map[string]bool{
153
154
155
156 "ServiceMapping": true,
157
158 "GameServicesRealm": true,
159 }
160 )
161
162 func FormatAnnotation(annotationName string) string {
163 return fmt.Sprintf("%v/%v", AnnotationPrefix, annotationName)
164 }
165
View as plain text