diff --git a/api/v1alpha1/terraformpullrequest_types.go b/api/v1alpha1/terraformpullrequest_types.go index 601085f1..419d8368 100644 --- a/api/v1alpha1/terraformpullrequest_types.go +++ b/api/v1alpha1/terraformpullrequest_types.go @@ -34,8 +34,10 @@ type TerraformPullRequestSpec struct { // TerraformPullRequestStatus defines the observed state of TerraformPullRequest type TerraformPullRequestStatus struct { - Conditions []metav1.Condition `json:"conditions,omitempty"` - State string `json:"state,omitempty"` + Conditions []metav1.Condition `json:"conditions,omitempty"` + State string `json:"state,omitempty"` + LastDiscoveredCommit string `json:"lastDiscoveredCommit,omitempty"` + LastCommentedCommit string `json:"lastCommentedCommit,omitempty"` } // +kubebuilder:object:root=true diff --git a/internal/annotations/annotations.go b/internal/annotations/annotations.go index 61ce1001..98c42f66 100644 --- a/internal/annotations/annotations.go +++ b/internal/annotations/annotations.go @@ -18,11 +18,7 @@ const ( LastBranchCommit string = "webhook.terraform.padok.cloud/branch-commit" LastRelevantCommit string = "webhook.terraform.padok.cloud/relevant-commit" - ForceApply string = "notifications.terraform.padok.cloud/force-apply" - - LastDiscoveredCommit string = "pullrequest.terraform.padok.cloud/last-discovered-commit" - LastCommentedCommit string = "pullrequest.terraform.padok.cloud/last-commented-commit" - + ForceApply string = "notifications.terraform.padok.cloud/force-apply" AdditionnalTriggerPaths string = "config.terraform.padok.cloud/additionnal-trigger-paths" ) diff --git a/internal/controllers/terraformpullrequest/conditions.go b/internal/controllers/terraformpullrequest/conditions.go index c5234eeb..a88c2708 100644 --- a/internal/controllers/terraformpullrequest/conditions.go +++ b/internal/controllers/terraformpullrequest/conditions.go @@ -15,8 +15,8 @@ func (r *Reconciler) IsLastCommitDiscovered(pr *configv1alpha1.TerraformPullRequ Status: metav1.ConditionUnknown, LastTransitionTime: metav1.NewTime(time.Now()), } - lastDiscoveredCommit, ok := pr.Annotations[annotations.LastDiscoveredCommit] - if !ok { + lastDiscoveredCommit := pr.Status.LastDiscoveredCommit + if lastDiscoveredCommit == "" { condition.Reason = "NoCommitDiscovered" condition.Message = "Controller hasn't discovered any commit yet." condition.Status = metav1.ConditionFalse @@ -50,7 +50,7 @@ func (r *Reconciler) AreLayersStillPlanning(pr *configv1alpha1.TerraformPullRequ } layers, err := GetLinkedLayers(r.Client, pr) - lastDiscoveredCommit, okDiscoveredCommit := pr.Annotations[annotations.LastDiscoveredCommit] + lastDiscoveredCommit := pr.Status.LastDiscoveredCommit prLastBranchCommit, okPRBranchCommit := pr.Annotations[annotations.LastBranchCommit] if !okPRBranchCommit { @@ -60,7 +60,7 @@ func (r *Reconciler) AreLayersStillPlanning(pr *configv1alpha1.TerraformPullRequ return condition, true } - if !okDiscoveredCommit { + if lastDiscoveredCommit == "" { condition.Reason = "NoCommitDiscovered" condition.Message = "Controller hasn't discovered any commit yet." condition.Status = metav1.ConditionTrue @@ -114,15 +114,15 @@ func (r *Reconciler) IsCommentUpToDate(pr *configv1alpha1.TerraformPullRequest) Status: metav1.ConditionUnknown, LastTransitionTime: metav1.NewTime(time.Now()), } - lastDiscoveredCommit, ok := pr.Annotations[annotations.LastDiscoveredCommit] - if !ok { - condition.Reason = "Unknown" - condition.Message = "This should not have happened" + lastDiscoveredCommit := pr.Status.LastDiscoveredCommit + if lastDiscoveredCommit == "" { + condition.Reason = "UnDiscovered" + condition.Message = "Pull request has not been discovered yet." condition.Status = metav1.ConditionUnknown return condition, true } - lastCommentedCommit, ok := pr.Annotations[annotations.LastCommentedCommit] - if !ok { + lastCommentedCommit := pr.Status.LastCommentedCommit + if lastCommentedCommit == "" { condition.Reason = "NoCommentSent" condition.Message = "No comment has ever been sent" condition.Status = metav1.ConditionFalse diff --git a/internal/controllers/terraformpullrequest/controller.go b/internal/controllers/terraformpullrequest/controller.go index a6f34e32..387948dc 100644 --- a/internal/controllers/terraformpullrequest/controller.go +++ b/internal/controllers/terraformpullrequest/controller.go @@ -81,10 +81,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu log.Errorf("failed to get TerraformRepository: %s", err) return ctrl.Result{}, err } - state, conditions := r.GetState(ctx, pr) - result := state.getHandler()(ctx, r, repository, pr) - - pr.Status = configv1alpha1.TerraformPullRequestStatus{Conditions: conditions, State: getStateString(state)} + state := r.GetState(ctx, pr) + result := state.Handler(ctx, r, repository, pr) + pr.Status = state.Status err = r.Client.Status().Update(ctx, pr) if err != nil { log.Errorf("could not update pull request %s status: %s", pr.Name, err) diff --git a/internal/controllers/terraformpullrequest/controller_test.go b/internal/controllers/terraformpullrequest/controller_test.go index 34adcaf9..92aa5c1d 100644 --- a/internal/controllers/terraformpullrequest/controller_test.go +++ b/internal/controllers/terraformpullrequest/controller_test.go @@ -79,7 +79,27 @@ var _ = BeforeSuite(func() { //+kubebuilder:scaffold:scheme k8sClient, err = client.New(cfg, client.Options{Scheme: scheme.Scheme}) + Expect(err).NotTo(HaveOccurred()) utils.LoadResources(k8sClient, "testdata") + statuses := []StatusUpdate{ + { + Name: "pr-nominal-case-3", + Namespace: "default", + Status: configv1alpha1.TerraformPullRequestStatus{ + LastDiscoveredCommit: "04410b5b7d90b82ad658b86564a9aa4bce411ac9", + LastCommentedCommit: "04410b5b7d90b82ad658b86564a9aa4bce411ac9", + }, + }, + { + Name: "pr-nominal-case-2", + Namespace: "default", + Status: configv1alpha1.TerraformPullRequestStatus{ + LastDiscoveredCommit: "04410b5b7d90b82ad658b86564a9aa4bce411ac9", + }, + }, + } + err = initStatus(k8sClient, statuses) + Expect(err).NotTo(HaveOccurred()) reconciler = &controller.Reconciler{ Client: k8sClient, Config: config.TestConfig(), @@ -93,6 +113,39 @@ var _ = BeforeSuite(func() { Expect(k8sClient).NotTo(BeNil()) }) +type StatusUpdate struct { + Name string + Namespace string + Status configv1alpha1.TerraformPullRequestStatus +} + +func updateStatus(c client.Client, name string, namespace string, status configv1alpha1.TerraformPullRequestStatus) error { + pr := &configv1alpha1.TerraformPullRequest{} + err := c.Get(context.Background(), types.NamespacedName{ + Name: name, + Namespace: namespace, + }, pr) + if err != nil { + return err + } + pr.Status = status + err = c.Status().Update(context.Background(), pr) + if err != nil { + return err + } + return nil +} + +func initStatus(c client.Client, statuses []StatusUpdate) error { + for _, status := range statuses { + err := updateStatus(c, status.Name, status.Namespace, status.Status) + if err != nil { + return err + } + } + return nil +} + func getResult(name types.NamespacedName) (reconcile.Result, *configv1alpha1.TerraformPullRequest, error, error) { result, reconcileError := reconciler.Reconcile(context.TODO(), reconcile.Request{ NamespacedName: name, @@ -138,7 +191,7 @@ var _ = Describe("TerraformPullRequest controller", func() { }) Context("Has discovered commit annotation", func() { It("Should return true", func() { - pr.Annotations[annotations.LastDiscoveredCommit] = "04410b5b7d90b82ad658b86564a9aa4bce411ac9" + pr.Status.LastDiscoveredCommit = "04410b5b7d90b82ad658b86564a9aa4bce411ac9" _, value := reconciler.IsLastCommitDiscovered(pr) Expect(value).To(BeTrue()) }) @@ -161,7 +214,7 @@ var _ = Describe("TerraformPullRequest controller", func() { }) Context("Has discovered annotation", func() { It("Should return false", func() { - pr.Annotations[annotations.LastDiscoveredCommit] = "04410b5b7d90b82ad658b86564a9aa4bce411ac9" + pr.Status.LastDiscoveredCommit = "04410b5b7d90b82ad658b86564a9aa4bce411ac9" _, value := reconciler.IsCommentUpToDate(pr) Expect(value).To(BeFalse()) }) @@ -169,16 +222,16 @@ var _ = Describe("TerraformPullRequest controller", func() { }) Context("Has discovered annotation and commented annotation equals", func() { It("Should return true", func() { - pr.Annotations[annotations.LastDiscoveredCommit] = "04410b5b7d90b82ad658b86564a9aa4bce411ac9" - pr.Annotations[annotations.LastCommentedCommit] = "04410b5b7d90b82ad658b86564a9aa4bce411ac9" + pr.Status.LastDiscoveredCommit = "04410b5b7d90b82ad658b86564a9aa4bce411ac9" + pr.Status.LastCommentedCommit = "04410b5b7d90b82ad658b86564a9aa4bce411ac9" _, value := reconciler.IsCommentUpToDate(pr) Expect(value).To(BeTrue()) }) }) Context("Has discovered annotation and commented annotation different", func() { It("Should return false", func() { - pr.Annotations[annotations.LastDiscoveredCommit] = "04410b5b7d90b82ad658b86564a9aa4bce411ac9" - pr.Annotations[annotations.LastCommentedCommit] = "old" + pr.Status.LastDiscoveredCommit = "04410b5b7d90b82ad658b86564a9aa4bce411ac9" + pr.Status.LastCommentedCommit = "old" _, value := reconciler.IsCommentUpToDate(pr) Expect(value).To(BeFalse()) }) @@ -187,7 +240,7 @@ var _ = Describe("TerraformPullRequest controller", func() { Describe("AreLayersStillPlanning", func() { var layer *configv1alpha1.TerraformLayer BeforeEach(func() { - pr.Annotations[annotations.LastDiscoveredCommit] = "04410b5b7d90b82ad658b86564a9aa4bce411ac9" + pr.Status.LastDiscoveredCommit = "04410b5b7d90b82ad658b86564a9aa4bce411ac9" layer = &configv1alpha1.TerraformLayer{ ObjectMeta: metav1.ObjectMeta{ Name: "test-layer", @@ -208,7 +261,7 @@ var _ = Describe("TerraformPullRequest controller", func() { Context("PR annotations", func() { Context("No discovered commit annotation", func() { It("Should return true", func() { - delete(pr.Annotations, annotations.LastDiscoveredCommit) + pr.Status.LastDiscoveredCommit = "" condition, value := reconciler.AreLayersStillPlanning(pr) Expect(condition.Reason).To(Equal("NoCommitDiscovered")) Expect(value).To(BeTrue()) @@ -224,7 +277,7 @@ var _ = Describe("TerraformPullRequest controller", func() { }) Context("Discovered and Last Branch different", func() { It("Should return false", func() { - pr.Annotations[annotations.LastDiscoveredCommit] = "other" + pr.Status.LastDiscoveredCommit = "other" condition, value := reconciler.AreLayersStillPlanning(pr) Expect(condition.Reason).To(Equal("StillNeedsDiscovery")) Expect(value).To(BeTrue()) @@ -301,7 +354,7 @@ var _ = Describe("TerraformPullRequest controller", func() { Expect(result.RequeueAfter).To(Equal(reconciler.Config.Controller.Timers.WaitAction)) }) It("should have a LastDiscoveredCommit annotation", func() { - Expect(pr.Annotations[annotations.LastDiscoveredCommit]).To(Equal(pr.Annotations[annotations.LastBranchCommit])) + Expect(pr.Status.LastDiscoveredCommit).To(Equal(pr.Annotations[annotations.LastBranchCommit])) }) It("should have created 2 temp layers", func() { layers, err := controller.GetLinkedLayers(k8sClient, pr) @@ -330,7 +383,7 @@ var _ = Describe("TerraformPullRequest controller", func() { Expect(result.RequeueAfter).To(Equal(reconciler.Config.Controller.Timers.WaitAction)) }) It("should have a LastCommentedCommit annotation", func() { - Expect(pr.Annotations[annotations.LastCommentedCommit]).To(Equal(pr.Annotations[annotations.LastDiscoveredCommit])) + Expect(pr.Status.LastCommentedCommit).To(Equal(pr.Status.LastDiscoveredCommit)) }) }) Describe("When a TerraformPullRequest has all its comment up to date", Ordered, func() { @@ -375,7 +428,7 @@ var _ = Describe("TerraformPullRequest controller", func() { Expect(result.RequeueAfter).To(Equal(reconciler.Config.Controller.Timers.WaitAction)) }) It("should have a LastDiscoveredCommit annotation", func() { - Expect(pr.Annotations[annotations.LastDiscoveredCommit]).To(Equal(pr.Annotations[annotations.LastBranchCommit])) + Expect(pr.Status.LastDiscoveredCommit).To(Equal(pr.Annotations[annotations.LastBranchCommit])) }) It("should not have created temp layers", func() { layers, err := controller.GetLinkedLayers(k8sClient, pr) @@ -425,7 +478,7 @@ var _ = Describe("TerraformPullRequest controller", func() { Expect(pr.Status.State).To(Equal("DiscoveryNeeded")) }) It("should not have a LastDiscoveredCommit annotation", func() { - Expect(pr.Annotations).NotTo(HaveKey(annotations.LastDiscoveredCommit)) + Expect(pr.Status.LastDiscoveredCommit).To(Equal("")) }) }) }) diff --git a/internal/controllers/terraformpullrequest/states.go b/internal/controllers/terraformpullrequest/states.go index bd46d70e..11e9f6c0 100644 --- a/internal/controllers/terraformpullrequest/states.go +++ b/internal/controllers/terraformpullrequest/states.go @@ -2,8 +2,6 @@ package terraformpullrequest import ( "context" - "fmt" - "strings" configv1alpha1 "github.com/padok-team/burrito/api/v1alpha1" "github.com/padok-team/burrito/internal/annotations" @@ -13,122 +11,117 @@ import ( ctrl "sigs.k8s.io/controller-runtime" ) -type State interface { - getHandler() func(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest) ctrl.Result +const ( + DiscoveryNeeded string = "DiscoveryNeeded" + Planning string = "Planning" + CommentNeeded string = "CommentNeeded" + Idle string = "Idle" +) + +type State struct { + handler func(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest, state *State) ctrl.Result + Status configv1alpha1.TerraformPullRequestStatus } -func (r *Reconciler) GetState(ctx context.Context, pr *configv1alpha1.TerraformPullRequest) (State, []metav1.Condition) { +func (s *State) Handler(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest) ctrl.Result { + return s.handler(ctx, r, repository, pr, s) +} + +func (r *Reconciler) GetState(ctx context.Context, pr *configv1alpha1.TerraformPullRequest) State { + var state State log := log.WithContext(ctx) c1, isLastCommitDiscovered := r.IsLastCommitDiscovered(pr) c2, areLayersStillPlanning := r.AreLayersStillPlanning(pr) c3, isCommentUpToDate := r.IsCommentUpToDate(pr) conditions := []metav1.Condition{c1, c2, c3} + state = State{ + Status: configv1alpha1.TerraformPullRequestStatus{ + Conditions: conditions, + LastDiscoveredCommit: pr.Status.LastDiscoveredCommit, + LastCommentedCommit: pr.Status.LastCommentedCommit, + }, + } switch { case !isLastCommitDiscovered: log.Infof("pull request %s needs to be discovered", pr.Name) - return &DiscoveryNeeded{}, conditions + state.handler = discoveryNeededHandler + state.Status.State = DiscoveryNeeded case isLastCommitDiscovered && isCommentUpToDate: log.Infof("pull request %s comment is up to date", pr.Name) - return &Idle{}, conditions + state.handler = idleHandler + state.Status.State = Idle case isLastCommitDiscovered && areLayersStillPlanning: log.Infof("pull request %s layers are still planning, waiting", pr.Name) - return &Planning{}, conditions + state.handler = planningHandler + state.Status.State = Planning case isLastCommitDiscovered && !areLayersStillPlanning && !isCommentUpToDate: log.Infof("pull request %s layers have finished, posting comment", pr.Name) - return &CommentNeeded{}, conditions + state.handler = commentNeededHandler + state.Status.State = CommentNeeded default: log.Infof("pull request %s is in an unknown state, defaulting to idle. If this happens please file an issue, this is not an intended behavior.", pr.Name) - return &Idle{}, conditions + state.handler = idleHandler + state.Status.State = Idle } + return state } -type Idle struct{} - -func (s *Idle) getHandler() func(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest) ctrl.Result { - return func(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest) ctrl.Result { - return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.WaitAction} - } +func idleHandler(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest, state *State) ctrl.Result { + return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.WaitAction} } -type Planning struct{} - -func (s *Planning) getHandler() func(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest) ctrl.Result { - return func(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest) ctrl.Result { - return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.WaitAction} - } +func planningHandler(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest, state *State) ctrl.Result { + return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.WaitAction} } -type DiscoveryNeeded struct{} - -func (s *DiscoveryNeeded) getHandler() func(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest) ctrl.Result { - return func(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest) ctrl.Result { - // Delete already existing temporary layers - err := r.deleteTempLayers(ctx, pr) - if err != nil { - log.Errorf("failed to delete temp layers for pull request %s: %s", pr.Name, err) - } - layers, err := r.getAffectedLayers(repository, pr) - if err != nil { - log.Errorf("failed to get affected layers for pull request %s: %s", pr.Name, err) - return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.OnError} - } - newLayers := generateTempLayers(pr, layers) - for _, layer := range newLayers { - err := r.Client.Create(ctx, &layer) - if err != nil { - log.Errorf("failed to create layer %s: %s", layer.Name, err) - return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.OnError} - } - } - // TODO: setting this annotation triggers another reconciliation cycle while this one is still running, which is not ideal - err = annotations.Add(ctx, r.Client, pr, map[string]string{annotations.LastDiscoveredCommit: pr.Annotations[annotations.LastBranchCommit]}) +func discoveryNeededHandler(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest, state *State) ctrl.Result { + err := r.deleteTempLayers(ctx, pr) + if err != nil { + log.Errorf("failed to delete temp layers for pull request %s: %s", pr.Name, err) + } + layers, err := r.getAffectedLayers(repository, pr) + if err != nil { + log.Errorf("failed to get affected layers for pull request %s: %s", pr.Name, err) + return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.OnError} + } + newLayers := generateTempLayers(pr, layers) + for _, layer := range newLayers { + err := r.Client.Create(ctx, &layer) if err != nil { - log.Errorf("failed to add annotation %s to pull request %s: %s", annotations.LastDiscoveredCommit, pr.Name, err) + log.Errorf("failed to create layer %s: %s", layer.Name, err) return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.OnError} } - return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.WaitAction} } + state.Status.LastDiscoveredCommit = pr.Annotations[annotations.LastBranchCommit] + return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.WaitAction} } -type CommentNeeded struct{} - -func (s *CommentNeeded) getHandler() func(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest) ctrl.Result { - return func(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest) ctrl.Result { - layers, err := GetLinkedLayers(r.Client, pr) - if err != nil { - log.Errorf("failed to get linked layers for pull request %s: %s", pr.Name, err) - return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.OnError} - } - - var provider Provider - found := false - for _, p := range r.Providers { - if p.IsFromProvider(pr) { - provider = p - found = true - } - } - if !found { - log.Infof("failed to get pull request provider. Requeuing") - return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.WaitAction} - } +func commentNeededHandler(ctx context.Context, r *Reconciler, repository *configv1alpha1.TerraformRepository, pr *configv1alpha1.TerraformPullRequest, state *State) ctrl.Result { + layers, err := GetLinkedLayers(r.Client, pr) + if err != nil { + log.Errorf("failed to get linked layers for pull request %s: %s", pr.Name, err) + return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.OnError} + } - comment := comment.NewDefaultComment(layers, r.Storage) - err = provider.Comment(repository, pr, comment) - if err != nil { - log.Errorf("an error occurred while commenting pull request: %s", err) - return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.OnError} - } - err = annotations.Add(ctx, r.Client, pr, map[string]string{annotations.LastCommentedCommit: pr.Annotations[annotations.LastDiscoveredCommit]}) - if err != nil { - log.Errorf("failed to add annotation %s to pull request %s: %s", annotations.LastCommentedCommit, pr.Name, err) - return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.OnError} + var provider Provider + found := false + for _, p := range r.Providers { + if p.IsFromProvider(pr) { + provider = p + found = true } + } + if !found { + log.Infof("failed to get pull request provider. Requeuing") return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.WaitAction} } -} -func getStateString(state State) string { - t := strings.Split(fmt.Sprintf("%T", state), ".") - return t[len(t)-1] + comment := comment.NewDefaultComment(layers, r.Storage) + err = provider.Comment(repository, pr, comment) + if err != nil { + log.Errorf("an error occurred while commenting pull request: %s", err) + return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.OnError} + } + state.Status.LastCommentedCommit = pr.Annotations[annotations.LastBranchCommit] + return ctrl.Result{RequeueAfter: r.Config.Controller.Timers.WaitAction} } diff --git a/internal/controllers/terraformpullrequest/testdata/nominal-case.yaml b/internal/controllers/terraformpullrequest/testdata/nominal-case.yaml index 6d7cad3d..80c8663b 100644 --- a/internal/controllers/terraformpullrequest/testdata/nominal-case.yaml +++ b/internal/controllers/terraformpullrequest/testdata/nominal-case.yaml @@ -63,7 +63,6 @@ metadata: app.kubernetes.io/instance: in-cluster-burrito annotations: webhook.terraform.padok.cloud/branch-commit: 04410b5b7d90b82ad658b86564a9aa4bce411ac9 - pullrequest.terraform.padok.cloud/last-discovered-commit: 04410b5b7d90b82ad658b86564a9aa4bce411ac9 spec: provider: mock branch: feature-branch-2 @@ -106,8 +105,6 @@ metadata: app.kubernetes.io/instance: in-cluster-burrito annotations: webhook.terraform.padok.cloud/branch-commit: 04410b5b7d90b82ad658b86564a9aa4bce411ac9 - pullrequest.terraform.padok.cloud/last-discovered-commit: 04410b5b7d90b82ad658b86564a9aa4bce411ac9 - pullrequest.terraform.padok.cloud/last-commented-commit: 04410b5b7d90b82ad658b86564a9aa4bce411ac9 spec: provider: mock branch: feature-branch-3 diff --git a/manifests/crds/config.terraform.padok.cloud_terraformpullrequests.yaml b/manifests/crds/config.terraform.padok.cloud_terraformpullrequests.yaml index 2456ffe0..743bff92 100644 --- a/manifests/crds/config.terraform.padok.cloud_terraformpullrequests.yaml +++ b/manifests/crds/config.terraform.padok.cloud_terraformpullrequests.yaml @@ -144,6 +144,10 @@ spec: - type type: object type: array + lastCommentedCommit: + type: string + lastDiscoveredCommit: + type: string state: type: string type: object diff --git a/manifests/install.yaml b/manifests/install.yaml index 2da4947d..c84de657 100644 --- a/manifests/install.yaml +++ b/manifests/install.yaml @@ -1447,6 +1447,10 @@ spec: - type type: object type: array + lastCommentedCommit: + type: string + lastDiscoveredCommit: + type: string state: type: string type: object