Skip to content

Commit

Permalink
operator: fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
joejulian committed Oct 31, 2023
1 parent 2a4b490 commit 4187a54
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import (
const (
NoneConstantString = "none"
FinalizerKey = "operator.redpanda.com/finalizer"
revisionPath = "/revision"
)

// These are for convenience when doing log.V(...) to log at a particular level. They correspond to the logr
Expand Down Expand Up @@ -229,7 +230,7 @@ func (r *TopicReconciler) reconcile(ctx context.Context, topic *v1alpha1.Topic,
func (r *TopicReconciler) successfulTopicReconciliation(topic *v1alpha1.Topic) *v1alpha1.Topic {
if r.EventRecorder != nil {
r.EventRecorder.AnnotatedEventf(topic,
map[string]string{v2.GroupVersion.Group + "/revision": topic.ResourceVersion},
map[string]string{v2.GroupVersion.Group + revisionPath: topic.ResourceVersion},
corev1.EventTypeNormal, v1alpha1.EventTopicSynced, "configuration synced")
}
return v1alpha1.TopicReady(topic)
Expand Down Expand Up @@ -358,7 +359,7 @@ func (r *TopicReconciler) alterTopicConfiguration(ctx context.Context, topic *v1
if len(configs) == 0 {
if r.EventRecorder != nil {
r.EventRecorder.AnnotatedEventf(topic,
map[string]string{v2.GroupVersion.Group + "/revision": topic.ResourceVersion},
map[string]string{v2.GroupVersion.Group + revisionPath: topic.ResourceVersion},
corev1.EventTypeNormal, v1alpha1.EventTopicAlreadySynced, "configuration not changed")
}
return nil
Expand Down Expand Up @@ -575,7 +576,7 @@ func (r *TopicReconciler) recordErrorEvent(err error, topic *v1alpha1.Topic, eve
copy(eventArgs, args)
eventArgs = append(eventArgs, err.Error())
r.EventRecorder.AnnotatedEventf(topic,
map[string]string{v2.GroupVersion.Group + "/revision": topic.ResourceVersion},
map[string]string{v2.GroupVersion.Group + revisionPath: topic.ResourceVersion},
corev1.EventTypeWarning, eventType, fmt.Sprintf(message+": %s", eventArgs))
}
args = append(args, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ func isRedpandaClusterManaged(
l logr.Logger, redpandaCluster *vectorizedv1alpha1.Cluster,
) bool {
log := l.WithName("isRedpandaClusterManaged")
managedAnnotationKey := vectorizedv1alpha1.GroupVersion.Group + "/managed"
managedAnnotationKey := vectorizedv1alpha1.GroupVersion.Group + managedPath
if managed, exists := redpandaCluster.Annotations[managedAnnotationKey]; exists && managed == NotManaged {
log.Info(fmt.Sprintf("management is disabled; to enable it, change the '%s' annotation to true or remove it",
managedAnnotationKey))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const (

resourceTypeHelmRepository = "HelmRepository"
resourceTypeHelmRelease = "HelmRelease"

managedPath = "/managed"
)

// RedpandaReconciler reconciles a Redpanda object
Expand Down Expand Up @@ -524,7 +526,7 @@ func helmChartRequiresUpdate(template, chart *helmv2beta1.HelmChartTemplate) boo
func isRedpandaManaged(ctx context.Context, redpandaCluster *v1alpha1.Redpanda) bool {
log := ctrl.LoggerFrom(ctx).WithName("RedpandaReconciler.isRedpandaManaged")

managedAnnotationKey := v1alpha1.GroupVersion.Group + "/managed"
managedAnnotationKey := v1alpha1.GroupVersion.Group + managedPath
if managed, exists := redpandaCluster.Annotations[managedAnnotationKey]; exists && managed == NotManaged {
log.Info(fmt.Sprintf("management is disabled; to enable it, change the '%s' annotation to true or remove it", managedAnnotationKey))
return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import (
const (
versionWithCentralizedConfiguration = "v22.1.1-dev"
versionWithoutCentralizedConfiguration = "v21.11.1-dev" // no centralized config, shadow index enabled

baseSuffix = "-base"
)

var _ = Describe("RedpandaCluster configuration controller", func() {
Expand Down Expand Up @@ -902,7 +904,7 @@ func getInitialTestCluster(
Namespace: ns,
}
baseKey = types.NamespacedName{
Name: name + "-base",
Name: name + baseSuffix,
Namespace: ns,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ var _ = Describe("RedPandaCluster controller", func() {
clusterNameWithLicense = "test-cluster-with-license"
licenseName = "test-cluster-with-license"
licenseNamespace = "default"

externalSuffix = "-external"
)

Context("When creating RedpandaCluster", func() {
Expand All @@ -77,7 +79,7 @@ var _ = Describe("RedPandaCluster controller", func() {
Namespace: "default",
}
baseKey := types.NamespacedName{
Name: key.Name + "-base",
Name: key.Name + baseSuffix,
Namespace: "default",
}
clusterRoleKey := types.NamespacedName{
Expand Down Expand Up @@ -188,7 +190,7 @@ var _ = Describe("RedPandaCluster controller", func() {
By("Creating NodePort Service")
Eventually(func() bool {
err := k8sClient.Get(context.Background(), types.NamespacedName{
Name: key.Name + "-external",
Name: key.Name + externalSuffix,
Namespace: key.Namespace,
}, &svc)
return err == nil &&
Expand Down Expand Up @@ -601,7 +603,7 @@ var _ = Describe("RedPandaCluster controller", func() {
var svc corev1.Service
Eventually(func() bool {
err := k8sClient.Get(context.Background(), types.NamespacedName{
Name: key.Name + "-external",
Name: key.Name + externalSuffix,
Namespace: key.Namespace,
}, &svc)
return err == nil &&
Expand Down

0 comments on commit 4187a54

Please sign in to comment.