Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default value to TektonConfig object #415

Merged
merged 1 commit into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions pkg/reconciler/shared/tektonconfig/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (tc tektonConfig) ensureInstance(ctx context.Context) {
logger.Errorf("error getting Tektonconfig, Name: ", instance.GetName())
return false, nil
}
err = tc.createInstance()
err = tc.createInstance(ctx)
if err != nil {
//log error and retry
logger.Errorf("error creating Tektonconfig instance, Name: ", instance.GetName())
Expand All @@ -108,7 +108,7 @@ func (tc tektonConfig) ensureInstance(ctx context.Context) {
}
}

func (tc tektonConfig) createInstance() error {
func (tc tektonConfig) createInstance(ctx context.Context) error {
tcCR := &v1alpha1.TektonConfig{
ObjectMeta: metav1.ObjectMeta{
Name: common.ConfigResourceName,
Expand All @@ -120,7 +120,8 @@ func (tc tektonConfig) createInstance() error {
},
},
}
tcCR.SetDefaults(ctx)
_, err := tc.operatorClientSet.OperatorV1alpha1().
TektonConfigs().Create(context.TODO(), tcCR, metav1.CreateOptions{})
TektonConfigs().Create(ctx, tcCR, metav1.CreateOptions{})
return err
}
2 changes: 2 additions & 0 deletions pkg/reconciler/shared/tektonconfig/tektonconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ func (r *Reconciler) ReconcileKind(ctx context.Context, tc *v1alpha1.TektonConfi
return nil
}

tc.SetDefaults(ctx)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vdemeester when we pass the object through defaulting in reconciler, do we also update the object in etcd?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the defaulter won't do it. however, the next update action down in the code/reconciler will get it into etcd.
so your concern is right.

The change in this patch should be moved to here

Copy link
Member

@nikhil-thomas nikhil-thomas Sep 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact, we can do it in both places, it should have the same effect functionaly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

im fine with merging this as it is.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed the comment btw

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the same in tektoncd/pipeline, as @nikhil-thomas said, it won't be stored in etcd but ain't such a big deal.


if err := r.extension.PreReconcile(ctx, tc); err != nil {
// If prereconcile updates the TektonConfig CR, it returns an error
// to reconcile
Expand Down