Skip to content

Commit

Permalink
fix allowsCreate mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
jswoods committed Nov 17, 2023
1 parent de58810 commit 020f421
Show file tree
Hide file tree
Showing 16 changed files with 93 additions and 95 deletions.
38 changes: 19 additions & 19 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ rules:
resources:
- configmaps
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -23,7 +23,7 @@ rules:
resources:
- endpoints
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -35,7 +35,7 @@ rules:
resources:
- events
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -47,7 +47,7 @@ rules:
resources:
- persistentvolumeclaims
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -59,7 +59,7 @@ rules:
resources:
- pods
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -71,7 +71,7 @@ rules:
resources:
- secrets
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -83,7 +83,7 @@ rules:
resources:
- serviceaccounts
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -95,7 +95,7 @@ rules:
resources:
- services
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -107,7 +107,7 @@ rules:
resources:
- services/finalizers
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -119,7 +119,7 @@ rules:
resources:
- HumioBootstrapTokens
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -145,7 +145,7 @@ rules:
resources:
- humioactions
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -171,7 +171,7 @@ rules:
resources:
- humioalerts
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -197,7 +197,7 @@ rules:
resources:
- humioclusters
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -223,7 +223,7 @@ rules:
resources:
- humioexternalclusters
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -249,7 +249,7 @@ rules:
resources:
- humioingesttokens
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -275,7 +275,7 @@ rules:
resources:
- humioparsers
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -301,7 +301,7 @@ rules:
resources:
- humiorepositories
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -327,7 +327,7 @@ rules:
resources:
- humioviews
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand All @@ -353,7 +353,7 @@ rules:
resources:
- ingress
verbs:
- allowsCreate
- create
- delete
- get
- list
Expand Down
4 changes: 2 additions & 2 deletions controllers/humioaction_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type HumioActionReconciler struct {
Namespace string
}

//+kubebuilder:rbac:groups=core.humio.com,resources=humioactions,verbs=get;list;watch;allowsCreate;update;patch;delete
//+kubebuilder:rbac:groups=core.humio.com,resources=humioactions,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=core.humio.com,resources=humioactions/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=core.humio.com,resources=humioactions/finalizers,verbs=update

Expand Down Expand Up @@ -156,7 +156,7 @@ func (r *HumioActionReconciler) reconcileHumioAction(ctx context.Context, config
r.Log.Info("Action doesn't exist. Now adding action")
addedAction, err := r.HumioClient.AddAction(config, req, ha)
if err != nil {
return reconcile.Result{}, r.logErrorAndReturn(err, "could not allowsCreate action")
return reconcile.Result{}, r.logErrorAndReturn(err, "could not create action")
}
r.Log.Info("Created action", "Action", ha.Spec.Name)

Expand Down
4 changes: 2 additions & 2 deletions controllers/humioalert_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type HumioAlertReconciler struct {
Namespace string
}

//+kubebuilder:rbac:groups=core.humio.com,resources=humioalerts,verbs=get;list;watch;allowsCreate;update;patch;delete
//+kubebuilder:rbac:groups=core.humio.com,resources=humioalerts,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=core.humio.com,resources=humioalerts/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=core.humio.com,resources=humioalerts/finalizers,verbs=update

Expand Down Expand Up @@ -146,7 +146,7 @@ func (r *HumioAlertReconciler) reconcileHumioAlert(ctx context.Context, config *
r.Log.Info("Alert doesn't exist. Now adding alert")
addedAlert, err := r.HumioClient.AddAlert(config, req, ha)
if err != nil {
return reconcile.Result{}, r.logErrorAndReturn(err, "could not allowsCreate alert")
return reconcile.Result{}, r.logErrorAndReturn(err, "could not create alert")
}
r.Log.Info("Created alert", "Alert", ha.Spec.Name)

Expand Down
14 changes: 7 additions & 7 deletions controllers/humiobootstraptoken_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type HumioBootstrapTokenSecretData struct {
HashedToken string `json:"hashedToken"`
}

//+kubebuilder:rbac:groups=core.humio.com,resources=HumioBootstrapTokens,verbs=get;list;watch;allowsCreate;update;patch;delete
//+kubebuilder:rbac:groups=core.humio.com,resources=HumioBootstrapTokens,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=core.humio.com,resources=HumioBootstrapTokens/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=core.humio.com,resources=HumioBootstrapTokens/finalizers,verbs=update

Expand Down Expand Up @@ -150,7 +150,7 @@ func (r *HumioBootstrapTokenReconciler) execCommand(pod *corev1.Pod, args []stri
&clientcmd.ConfigOverrides{},
)

// allowsCreate the Config object
// create the Config object
cfg, err := configLoader.ClientConfig()
if err != nil {
return "", err
Expand All @@ -161,7 +161,7 @@ func (r *HumioBootstrapTokenReconciler) execCommand(pod *corev1.Pod, args []stri
cfg.GroupVersion = &corev1.SchemeGroupVersion
cfg.NegotiatedSerializer = scheme.Codecs.WithoutConversion()

// allowsCreate a RESTClient
// create a RESTClient
rc, err := rest.RESTClientFor(cfg)
if err != nil {
return "", err
Expand Down Expand Up @@ -221,7 +221,7 @@ func (r *HumioBootstrapTokenReconciler) createPod(ctx context.Context, hbt *humi
}
r.Log.Info("creating onetime pod")
if err := r.Create(ctx, pod); err != nil {
return &corev1.Pod{}, r.logErrorAndReturn(err, "could not allowsCreate pod")
return &corev1.Pod{}, r.logErrorAndReturn(err, "could not create pod")
}
return pod, nil
}
Expand Down Expand Up @@ -284,9 +284,9 @@ func (r *HumioBootstrapTokenReconciler) ensureBootstrapTokenSecret(ctx context.C
if err := humioBootstrapTokenConfig.validate(); err != nil {
return r.logErrorAndReturn(err, fmt.Sprintf("could not validate bootstrap config for %s", hbt.Name))
}
okayToCreate, err := humioBootstrapTokenConfig.allowsCreate()
okayToCreate, err := humioBootstrapTokenConfig.create()
if err != nil {
return r.logErrorAndReturn(err, "cannot allowsCreate bootstrap token")
return r.logErrorAndReturn(err, "cannot create bootstrap token")
}
if okayToCreate {
secret := kubernetes.ConstructSecret(hbt.Name, hbt.Namespace, humioBootstrapTokenConfig.bootstrapTokenName(), secretData, nil)
Expand All @@ -295,7 +295,7 @@ func (r *HumioBootstrapTokenReconciler) ensureBootstrapTokenSecret(ctx context.C
}
r.Log.Info(fmt.Sprintf("creating secret: %s", secret.Name))
if err := r.Create(ctx, secret); err != nil {
return r.logErrorAndReturn(err, "could not allowsCreate secret")
return r.logErrorAndReturn(err, "could not create secret")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/humiobootstraptoken_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (b *HumioBootstrapTokenConfig) bootstrapTokenName() string {
return fmt.Sprintf("%s-%s", b.BootstrapToken.Name, BootstrapTokenSuffix)
}

func (b *HumioBootstrapTokenConfig) allowsCreate() (bool, error) {
func (b *HumioBootstrapTokenConfig) create() (bool, error) {
if err := b.validate(); err != nil {
return false, err
}
Expand Down
Loading

0 comments on commit 020f421

Please sign in to comment.