Skip to content

Commit cd3d2b0

Browse files
author
Anand Kumar
committed
fix(godot): end TODO comments with a period
Resolve godot lint: comments should end in a period. - pkg/controller/trustmanager/constants.go - pkg/operator/setup_manager.go Made-with: Cursor
1 parent 01a5d28 commit cd3d2b0

2 files changed

Lines changed: 11 additions & 121 deletions

File tree

pkg/controller/trustmanager/constants.go

Lines changed: 5 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ package trustmanager
33
import (
44
"os"
55
"time"
6-
7-
"k8s.io/apimachinery/pkg/util/validation/field"
86
)
97

108
const (
@@ -14,6 +12,10 @@ const (
1412
// ControllerName is the name of the controller used in logs and events.
1513
ControllerName = trustManagerCommonName + "-controller"
1614

15+
// controllerProcessedAnnotation is the annotation added to trustmanager resource once after
16+
// successful reconciliation by the controller.
17+
controllerProcessedAnnotation = "operator.openshift.io/trust-manager-processed"
18+
1719
// finalizer name for trustmanager.openshift.operator.io resource.
1820
finalizer = "trustmanager.openshift.operator.io/" + ControllerName
1921

@@ -41,70 +43,9 @@ const (
4143
// fieldOwner is the field manager name used for Server-Side Apply operations.
4244
// All resource reconcilers should use this to identify ownership of fields.
4345
fieldOwner = "trust-manager-controller"
44-
45-
// trustManagerContainerName is the name of the trust-manager container in the deployment.
46-
trustManagerContainerName = "trust-manager"
47-
48-
// roleBindingSubjectKind is the kind used in RBAC binding subjects.
49-
roleBindingSubjectKind = "ServiceAccount"
50-
)
51-
52-
// DefaultCAPackage constants.
53-
const (
54-
// defaultCAPackageConfigMapName is the ConfigMap in the operand namespace that
55-
// contains the formatted JSON CA package for trust-manager.
56-
defaultCAPackageConfigMapName = "trust-manager-default-ca-package"
57-
58-
// defaultCAPackageName is the package name used in the JSON CA package.
59-
defaultCAPackageName = "cert-manager-package-openshift"
60-
61-
// defaultCAPackageFilename is the filename used for the JSON package inside the ConfigMap.
62-
defaultCAPackageFilename = defaultCAPackageName + ".json"
63-
64-
// defaultCAPackageVolumeName is the volume name used in the deployment.
65-
defaultCAPackageVolumeName = "packages"
66-
67-
// defaultCAPackageMountPath is where the package volume is mounted in the container.
68-
defaultCAPackageMountPath = "/packages"
69-
70-
// defaultCAPackageLocation is the full path to the JSON package file inside the container.
71-
defaultCAPackageLocation = defaultCAPackageMountPath + "/" + defaultCAPackageFilename
72-
73-
// defaultCAPackageHashAnnotation is the pod template annotation that tracks the CA bundle hash.
74-
defaultCAPackageHashAnnotation = "operator.openshift.io/default-ca-package-hash"
75-
)
76-
77-
// Resource names used for creating resources and cross-referencing between them.
78-
// These must be set explicitly on each resource's .metadata.name and on every
79-
// field in other resources that references them.
80-
const (
81-
trustManagerCommonResourceName = "trust-manager"
82-
83-
trustManagerServiceAccountName = trustManagerCommonResourceName
84-
trustManagerDeploymentName = trustManagerCommonResourceName
85-
86-
trustManagerServiceName = trustManagerCommonResourceName
87-
trustManagerMetricsServiceName = trustManagerCommonResourceName + "-metrics"
88-
89-
trustManagerClusterRoleName = trustManagerCommonResourceName
90-
trustManagerClusterRoleBindingName = trustManagerCommonResourceName
91-
92-
trustManagerRoleName = trustManagerCommonResourceName
93-
trustManagerRoleBindingName = trustManagerCommonResourceName
94-
95-
trustManagerLeaderElectionRoleName = trustManagerCommonResourceName + ":leaderelection"
96-
trustManagerLeaderElectionRoleBindingName = trustManagerCommonResourceName + ":leaderelection"
97-
98-
trustManagerIssuerName = trustManagerCommonResourceName
99-
trustManagerCertificateName = trustManagerCommonResourceName
100-
trustManagerTLSSecretName = trustManagerCommonResourceName + "-tls"
101-
102-
trustManagerWebhookConfigName = trustManagerCommonResourceName
10346
)
10447

10548
var (
106-
trustManagerConfigFieldPath = field.NewPath("spec", "trustManagerConfig")
107-
controllerConfigFieldPath = field.NewPath("spec", "controllerConfig")
10849
controllerDefaultResourceLabels = map[string]string{
10950
"app": trustManagerCommonName,
11051
"app.kubernetes.io/name": trustManagerCommonName,
@@ -117,25 +58,7 @@ var (
11758

11859
// asset names are the files present in the root bindata/ dir. Which are then loaded
11960
// and made available by the pkg/operator/assets package.
61+
// TODO: Add more asset names as resources are implemented.
12062
const (
12163
serviceAccountAssetName = "trust-manager/resources/serviceaccount_trust-manager.yml"
122-
123-
deploymentAssetName = "trust-manager/resources/deployment_trust-manager.yml"
124-
125-
serviceAssetName = "trust-manager/resources/service_trust-manager.yml"
126-
metricsServiceAssetName = "trust-manager/resources/service_trust-manager-metrics.yml"
127-
128-
clusterRoleAssetName = "trust-manager/resources/clusterrole_trust-manager.yml"
129-
clusterRoleBindingAssetName = "trust-manager/resources/clusterrolebinding_trust-manager.yml"
130-
131-
roleAssetName = "trust-manager/resources/role_trust-manager.yml"
132-
roleBindingAssetName = "trust-manager/resources/rolebinding_trust-manager.yml"
133-
134-
roleLeaderElectionAssetName = "trust-manager/resources/role_trust-manager:leaderelection.yml"
135-
roleBindingLeaderElectionAssetName = "trust-manager/resources/rolebinding_trust-manager:leaderelection.yml"
136-
137-
issuerAssetName = "trust-manager/resources/issuer_trust-manager.yml"
138-
certificateAssetName = "trust-manager/resources/certificate_trust-manager.yml"
139-
140-
validatingWebhookConfigAssetName = "trust-manager/resources/validatingwebhookconfiguration_trust-manager.yml"
14164
)

pkg/operator/setup_manager.go

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"fmt"
66
"reflect"
77

8-
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
98
appsv1 "k8s.io/api/apps/v1"
109
corev1 "k8s.io/api/core/v1"
1110
networkingv1 "k8s.io/api/networking/v1"
@@ -16,9 +15,12 @@ import (
1615
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
1716
clientscheme "k8s.io/client-go/kubernetes/scheme"
1817
"k8s.io/client-go/rest"
18+
"k8s.io/klog/v2"
19+
1920
ctrl "sigs.k8s.io/controller-runtime"
2021
"sigs.k8s.io/controller-runtime/pkg/cache"
2122
"sigs.k8s.io/controller-runtime/pkg/client"
23+
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
2224
"sigs.k8s.io/controller-runtime/pkg/manager"
2325

2426
certmanagerv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
@@ -35,30 +37,6 @@ var (
3537
setupLog = ctrl.Log.WithName("setup-manager")
3638
)
3739

38-
// ConfigMap is intentionally excluded from both istioCSRManagedResources and
39-
// trustManagerManagedResources. Multiple controllers need to watch ConfigMaps
40-
// that do not carry the managed-resource label:
41-
//
42-
// 1. TrustManager watches both its managed ConfigMaps (e.g., the default CA
43-
// package ConfigMap, which carries the managed-resource label) and the
44-
// cert-manager-operator-trusted-ca-bundle ConfigMap (added in the OLM bundle manifest).
45-
// The latter does not carry the managed-resource label.
46-
//
47-
// 2. IstioCSR watches both its managed ConfigMaps (with the managed-resource
48-
// label) and user-created ConfigMaps identified by the
49-
// istiocsr.openshift.operator.io/watched-by label — a different label key
50-
// entirely from the managed-resource label (app).
51-
//
52-
// The cache uses a single labels.Selector per GVK. The In operator can match
53-
// multiple values for the same key (e.g., app in (value1, value2)), but
54-
// requirements on different keys are always ANDed. There is no way to express
55-
// "app in (...) OR watched-by exists" in a single selector. A shared app label
56-
// value could solve case 1, but case 2 requires matching across different label
57-
// keys, which the Kubernetes label selector spec does not support.
58-
//
59-
// ConfigMaps therefore use the default unfiltered informer, and each controller
60-
// applies predicate-level filtering to select only the events it cares about.
61-
6240
// istioCSRManagedResources defines the resources managed by the IstioCSR controller.
6341
// These resources will be watched with a label selector filter.
6442
var istioCSRManagedResources = []client.Object{
@@ -75,30 +53,19 @@ var istioCSRManagedResources = []client.Object{
7553

7654
// trustManagerManagedResources defines the resources managed by the TrustManager controller.
7755
// These resources will be watched with a label selector filter.
78-
//
79-
// cert-manager Issuer (and ClusterIssuer, which is never listed here) must not use a
80-
// managed-resource label selector: IstioCSR reconciles user-created Issuers referenced
81-
// from the spec, which are not labeled by the operator. Those types are left out of
82-
// ByObject so they use the manager cache’s default unfiltered informer per GVK.
56+
// TODO: Add more resources as they are implemented.
8357
var trustManagerManagedResources = []client.Object{
84-
&certmanagerv1.Certificate{},
85-
&appsv1.Deployment{},
86-
&rbacv1.ClusterRole{},
87-
&rbacv1.ClusterRoleBinding{},
88-
&rbacv1.Role{},
89-
&rbacv1.RoleBinding{},
90-
&corev1.Service{},
9158
&corev1.ServiceAccount{},
92-
&admissionregistrationv1.ValidatingWebhookConfiguration{},
9359
}
9460

9561
func init() {
62+
ctrllog.SetLogger(klog.NewKlogr())
63+
9664
utilruntime.Must(clientscheme.AddToScheme(scheme))
9765
utilruntime.Must(appsv1.AddToScheme(scheme))
9866
utilruntime.Must(corev1.AddToScheme(scheme))
9967
utilruntime.Must(networkingv1.AddToScheme(scheme))
10068
utilruntime.Must(rbacv1.AddToScheme(scheme))
101-
utilruntime.Must(admissionregistrationv1.AddToScheme(scheme))
10269
utilruntime.Must(certmanagerv1.AddToScheme(scheme))
10370
utilruntime.Must(v1alpha1.AddToScheme(scheme))
10471
// +kubebuilder:scaffold:scheme

0 commit comments

Comments
 (0)