Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jswoods committed Jun 21, 2024
1 parent 3da9a49 commit af924a3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
15 changes: 6 additions & 9 deletions controllers/humiobootstraptoken_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import (

"k8s.io/apimachinery/pkg/api/resource"

corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"

"github.com/humio/humio-operator/api/v1alpha1"
humiov1alpha1 "github.com/humio/humio-operator/api/v1alpha1"
corev1 "k8s.io/api/core/v1"
)

const (
Expand All @@ -18,11 +15,11 @@ const (
)

type HumioBootstrapTokenConfig struct {
BootstrapToken *v1alpha1.HumioBootstrapToken
ManagedHumioCluster *v1alpha1.HumioCluster
BootstrapToken *humiov1alpha1.HumioBootstrapToken
ManagedHumioCluster *humiov1alpha1.HumioCluster
}

func NewHumioBootstrapTokenConfig(bootstrapToken *humiov1alpha1.HumioBootstrapToken, managedHumioCluster *v1alpha1.HumioCluster) HumioBootstrapTokenConfig {
func NewHumioBootstrapTokenConfig(bootstrapToken *humiov1alpha1.HumioBootstrapToken, managedHumioCluster *humiov1alpha1.HumioCluster) HumioBootstrapTokenConfig {
return HumioBootstrapTokenConfig{BootstrapToken: bootstrapToken, ManagedHumioCluster: managedHumioCluster}
}

Expand Down Expand Up @@ -68,7 +65,7 @@ func (b *HumioBootstrapTokenConfig) image() string {
return Image
}

func (b *HumioBootstrapTokenConfig) imagePullSecrets() []v1.LocalObjectReference {
func (b *HumioBootstrapTokenConfig) imagePullSecrets() []corev1.LocalObjectReference {
if len(b.BootstrapToken.Spec.ImagePullSecrets) > 0 {
return b.BootstrapToken.Spec.ImagePullSecrets
}
Expand All @@ -82,7 +79,7 @@ func (b *HumioBootstrapTokenConfig) imagePullSecrets() []v1.LocalObjectReference
}
}
}
return []v1.LocalObjectReference{}
return []corev1.LocalObjectReference{}
}

func (b *HumioBootstrapTokenConfig) resources() corev1.ResourceRequirements {
Expand Down
4 changes: 2 additions & 2 deletions controllers/humiocluster_permission_tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (r *HumioClusterReconciler) validateAdminSecretContent(ctx context.Context,
// We could successfully get information about the cluster, so the token must be valid
return nil
}
return fmt.Errorf("Unable to validate if kubernetes secret %s holds a valid humio API token", adminSecretName)
return fmt.Errorf("unable to validate if kubernetes secret %s holds a valid humio API token", adminSecretName)
}

// ensureAdminSecretContent ensures the target Kubernetes secret contains the desired API token
Expand Down Expand Up @@ -185,7 +185,7 @@ func (r *HumioClusterReconciler) createPermissionToken(ctx context.Context, conf
// Get user ID of admin account
userID, err := r.createAndGetAdminAccountUserID(ctx, config, req, organizationMode, username, organization)
if err != nil {
return fmt.Errorf("Got err trying to obtain user ID of admin user: %s\n", err)
return fmt.Errorf("got err trying to obtain user ID of admin user: %s", err)
}

if err := r.validateAdminSecretContent(ctx, hc, req); err == nil {
Expand Down
14 changes: 0 additions & 14 deletions controllers/humiocluster_pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -908,20 +908,6 @@ func (r *HumioClusterReconciler) getDesiredBootstrapTokenHash(ctx context.Contex
return "", r.logErrorAndReturn(err, fmt.Sprintf("could not find bootstrap token secret matching labels %+v", kubernetes.LabelsForHumioBootstrapToken(hc.GetName())))
}

func (r *HumioClusterReconciler) bootstrapTokenReady(ctx context.Context, hc *humiov1alpha1.HumioCluster) (bool, error) {
humioBootstrapTokens, err := kubernetes.ListHumioBootstrapTokens(ctx, r.Client, hc.GetNamespace(), kubernetes.LabelsForHumioBootstrapToken(hc.GetName()))
if err != nil {
return false, r.logErrorAndReturn(err, "failed to get bootstrap token")
}

if len(humioBootstrapTokens) > 0 {
if humioBootstrapTokens[0].Status.State == humiov1alpha1.HumioBootstrapTokenStateReady {
return true, nil
}
}
return false, nil
}

// findHumioNodeNameAndCertHash looks up the name of a free node certificate to use and the hash of the certificate specification
func findHumioNodeNameAndCertHash(ctx context.Context, c client.Client, hnp *HumioNodePool, newlyCreatedPods []corev1.Pod) (podNameAndCertificateHash, error) {
// if we do not have TLS enabled, append a random suffix
Expand Down

0 comments on commit af924a3

Please sign in to comment.