Skip to content

Commit

Permalink
refactor: rename fields
Browse files Browse the repository at this point in the history
  • Loading branch information
unchama committed Sep 17, 2023
1 parent c58bfbb commit f4e63f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions api/v1alpha1/bungeeconfigtemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ type BungeeConfigTemplateSpec struct {
type BungeeConfigTemplateStatus string

const (
MarkdownViewApplying = BungeeConfigTemplateStatus("Applying")
MarkdownViewApplied = BungeeConfigTemplateStatus("Applied")
MarkdownViewError = BungeeConfigTemplateStatus("Error")
BungeeConfigApplying = BungeeConfigTemplateStatus("Applying")
BungeeConfigApplied = BungeeConfigTemplateStatus("Applied")
BungeeConfigError = BungeeConfigTemplateStatus("Error")
)

//+kubebuilder:object:root=true
Expand Down
12 changes: 6 additions & 6 deletions internal/controller/bungeeconfigtemplate_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,21 +86,21 @@ func (r *BungeeConfigTemplateReconciler) Reconcile(ctx context.Context, req ctrl
bungeeConfigTemplate := BungeeConfigTemplate.Spec.BungeeConfigTemplate

// BungeeConfigTemplate.Status を更新する
BungeeConfigTemplate.Status = seichiclickv1alpha1.MarkdownViewApplying
BungeeConfigTemplate.Status = seichiclickv1alpha1.BungeeConfigApplying

// bungeeConfigTemplate に格納されているテンプレートをもとに、
// go template を作成する
tmp, err := template.New("template").Parse(bungeeConfigTemplate)
if err != nil {
BungeeConfigTemplate.Status = seichiclickv1alpha1.MarkdownViewError
BungeeConfigTemplate.Status = seichiclickv1alpha1.BungeeConfigError
panic(err)
}

// go template に reviewPullRequestNumberList を適用して、
// bungeeConfig に格納する
var bungeeConfig bytes.Buffer
if err := tmp.Execute(&bungeeConfig, reviewPullRequestNumberList); err != nil {
BungeeConfigTemplate.Status = seichiclickv1alpha1.MarkdownViewError
BungeeConfigTemplate.Status = seichiclickv1alpha1.BungeeConfigError
panic(err)
}

Expand All @@ -118,15 +118,15 @@ func (r *BungeeConfigTemplateReconciler) Reconcile(ctx context.Context, req ctrl
if err := r.Client.Update(ctx, &configMap); err != nil {
// Handle error
logger.Error(err, "unable to apply the ConfigMap to the cluster", "name", req.NamespacedName)
BungeeConfigTemplate.Status = seichiclickv1alpha1.MarkdownViewError
BungeeConfigTemplate.Status = seichiclickv1alpha1.BungeeConfigError
return ctrl.Result{}, err
}

// BungeeConfigTemplate.Status を更新する
BungeeConfigTemplate.Status = seichiclickv1alpha1.MarkdownViewApplied
BungeeConfigTemplate.Status = seichiclickv1alpha1.BungeeConfigApplied
if err := r.Client.Status().Update(ctx, &BungeeConfigTemplate); err != nil {
// Handle error
BungeeConfigTemplate.Status = seichiclickv1alpha1.MarkdownViewError
BungeeConfigTemplate.Status = seichiclickv1alpha1.BungeeConfigError
return ctrl.Result{}, err
}

Expand Down

0 comments on commit f4e63f1

Please sign in to comment.