Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jswoods committed Nov 17, 2023
1 parent 020f421 commit 66aace4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 5 additions & 4 deletions controllers/humiobootstraptoken_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
)

const (
BootstrapTokenSuffix = "bootstrap-token"
bootstrapTokenSuffix = "bootstrap-token"
bootstrapTokenPodNameSuffix = "bootstrap-token-onetime"
)

type HumioBootstrapTokenConfig struct {
Expand All @@ -29,7 +30,7 @@ func (b *HumioBootstrapTokenConfig) bootstrapTokenName() string {
if b.BootstrapToken.Spec.TokenSecret.SecretKeyRef != nil {
return b.BootstrapToken.Spec.TokenSecret.SecretKeyRef.Name
}
return fmt.Sprintf("%s-%s", b.BootstrapToken.Name, BootstrapTokenSuffix)
return fmt.Sprintf("%s-%s", b.BootstrapToken.Name, bootstrapTokenSuffix)
}

func (b *HumioBootstrapTokenConfig) create() (bool, error) {
Expand Down Expand Up @@ -100,8 +101,8 @@ func (b *HumioBootstrapTokenConfig) resources() corev1.ResourceRequirements {
}
}

func (b *HumioBootstrapTokenConfig) name() string {
return b.BootstrapToken.Name
func (b *HumioBootstrapTokenConfig) podName() string {
return fmt.Sprintf("%s-%s", b.BootstrapToken.Name, bootstrapTokenPodNameSuffix)
}

func (b *HumioBootstrapTokenConfig) namespace() string {
Expand Down
4 changes: 1 addition & 3 deletions controllers/humiobootstraptoken_pods.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package controllers

import (
"fmt"

"github.com/humio/humio-operator/pkg/helpers"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -12,7 +10,7 @@ func ConstructBootstrapPod(bootstrapConfig *HumioBootstrapTokenConfig) *corev1.P
userID := int64(65534)
return &corev1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: fmt.Sprintf("%s-bootstrap-token-onetime", bootstrapConfig.name()),
Name: bootstrapConfig.podName(),
Namespace: bootstrapConfig.namespace(),
},
Spec: corev1.PodSpec{
Expand Down

0 comments on commit 66aace4

Please sign in to comment.