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

Refactor to phase and health controllers #1015

Closed
wants to merge 2 commits into from
Closed
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
27 changes: 8 additions & 19 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -11,35 +11,24 @@ resources:
- controller: true
domain: int128.github.io
group: argocdcommenter
kind: ApplicationHealthComment
version: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: int128.github.io
group: argocdcommenter
kind: ApplicationHealth
path: github.com/int128/argocd-commenter/api/v1
version: v1
- controller: true
domain: int128.github.io
group: argocdcommenter
kind: ApplicationHealthDeployment
kind: ApplicationDeletionDeployment
version: v1
- controller: true
domain: int128.github.io
group: argocdcommenter
kind: ApplicationPhaseComment
kind: ApplicationPhase
version: v1
- controller: true
domain: int128.github.io
group: argocdcommenter
kind: ApplicationPhaseDeployment
kind: ApplicationHealth
version: v1
- controller: true
- api:
crdVersion: v1
namespaced: true
domain: int128.github.io
group: argocdcommenter
kind: ApplicationDeletionDeployment
kind: Notification
path: github.com/int128/argocd-commenter/api/v1
version: v1
version: "3"
60 changes: 0 additions & 60 deletions api/v1/applicationhealth_types.go

This file was deleted.

69 changes: 69 additions & 0 deletions api/v1/notification_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright 2021.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// NotificationSpec defines the desired state of Notification
type NotificationSpec struct{}

// NotificationStatus defines the observed state of Notification
type NotificationStatus struct {
// +optional
CommentState NotificationState `json:"commentState,omitempty"`

// +optional
DeploymentState NotificationState `json:"deploymentState,omitempty"`
}

type NotificationState string

const (
NotificationStateSyncing NotificationState = "Syncing"
NotificationStateSynced NotificationState = "Synced"
NotificationStateSyncFailed NotificationState = "SyncFailed"
NotificationStateProgressing NotificationState = "Progressing"
NotificationStateHealthy NotificationState = "Healthy"
NotificationStateDegraded NotificationState = "Degraded"
)

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// Notification is the Schema for the notifications API
type Notification struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NotificationSpec `json:"spec,omitempty"`
Status NotificationStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// NotificationList contains a list of Notification
type NotificationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Notification `json:"items"`
}

func init() {
SchemeBuilder.Register(&Notification{}, &NotificationList{})
}
38 changes: 19 additions & 19 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 8 additions & 32 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,57 +106,33 @@ func main() {
}
notificationClient := notification.NewClient(ghc)

if err = (&controller.ApplicationHealthReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ApplicationHealth")
os.Exit(1)
}

// comment controller
if err = (&controller.ApplicationPhaseCommentReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Notification: notificationClient,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ApplicationPhaseComment")
os.Exit(1)
}
if err = (&controller.ApplicationHealthCommentReconciler{
if err = (&controller.ApplicationDeletionDeploymentReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Notification: notificationClient,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ApplicationHealthComment")
setupLog.Error(err, "unable to create controller", "controller", "ApplicationDeletionDeployment")
os.Exit(1)
}

// deployment controller
if err = (&controller.ApplicationPhaseDeploymentReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Notification: notificationClient,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ApplicationPhaseDeployment")
os.Exit(1)
}
if err = (&controller.ApplicationHealthDeploymentReconciler{
if err = (&controller.ApplicationPhaseReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Notification: notificationClient,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ApplicationHealthDeployment")
setupLog.Error(err, "unable to create controller", "controller", "ApplicationPhase")
os.Exit(1)
}
if err = (&controller.ApplicationDeletionDeploymentReconciler{

if err = (&controller.ApplicationHealthReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
Notification: notificationClient,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "ApplicationDeletionDeployment")
setupLog.Error(err, "unable to create controller", "controller", "ApplicationHealth")
os.Exit(1)
}

//+kubebuilder:scaffold:builder

if err := mgr.AddHealthzCheck("healthz", healthz.Ping); err != nil {
Expand Down
Loading
Loading