Skip to content

Commit

Permalink
Merge pull request #200 from weaveworks/minimal-leveltriggered-contro…
Browse files Browse the repository at this point in the history
…ller

Minimal level-triggered controller
  • Loading branch information
squaremo authored Oct 9, 2023
2 parents c9fc692 + c2403e0 commit d19807f
Show file tree
Hide file tree
Showing 15 changed files with 1,105 additions and 44 deletions.
8 changes: 8 additions & 0 deletions api/v1alpha1/conditions.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package v1alpha1

// Reasons are provided as utility, and are not part of the declarative API.

// Reasons used by the original controller.
const (
// TargetClusterNotFoundReason signals a failure to locate a cluster resource on the management cluster.
TargetClusterNotFoundReason string = "TargetClusterNotFound"
Expand All @@ -9,3 +11,9 @@ const (
// ReconciliationSucceededReason signals that a Pipeline has been successfully reconciled.
ReconciliationSucceededReason string = "ReconciliationSucceeded"
)

// Reasons used by the level-triggered controller.
const (
// TargetNotReadableReason signals that an app object pointed to by a Pipeline cannot be read, either because it is not found, or it's on a cluster that cannot be reached.
TargetNotReadableReason string = "TargetNotReadable"
)
21 changes: 21 additions & 0 deletions api/v1alpha1/pipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ func (p *PipelineStatus) setWaitingApproval(env string, waitingApproval WaitingA

type EnvironmentStatus struct {
WaitingApproval WaitingApproval `json:"waitingApproval,omitempty"`
Targets []TargetStatus `json:"targets,omitempty"`
}

// WaitingApproval holds the environment revision that's currently waiting approval.
Expand All @@ -193,6 +194,26 @@ type WaitingApproval struct {
Revision string `json:"revision"`
}

// ClusterAppReference is a fully-qualified target reference. It holds
// the namespaced target name and its type, and the cluster reference
// if the target is in a remote cluster.
type ClusterAppReference struct {
LocalAppReference `json:",inline"`
ClusterRef *CrossNamespaceClusterReference `json:"clusterRef,omitempty"`
}

// TargetStatus represents the status of an application object.
type TargetStatus struct {
// ClusterAppRef gives the app object reference, and a cluster reference if in a remote cluster
ClusterAppRef ClusterAppReference `json:"clusterAppRef"`
// Ready is true if the application object is present and healthy, and false otherwise.
Ready bool `json:"ready"`
// Revision is set if the application object is present and has had a configuration applied, and empty otherwise.
Revision string `json:"revision,omitempty"`
// Error is set if the application object is not present or not ready, and empty otherwise.
Error string `json:"error,omitempty"`
}

type Environment struct {
// Name defines the name of this environment. This is commonly something such as "dev" or "prod".
// +required
Expand Down
46 changes: 45 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion charts/pipeline-controller/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apiVersion: v2
name: pipeline-controller
description: Pipeline-controller Helm chart for Weave GitOps Enterprise
type: application
version: 0.21.0
version: "0.22.0"
appVersion: "v0.0.31"
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,72 @@ spec:
environments:
additionalProperties:
properties:
targets:
items:
description: TargetStatus represents the status of an application
object.
properties:
clusterAppRef:
description: ClusterAppRef gives the app object reference,
and a cluster reference if in a remote cluster
properties:
apiVersion:
description: API version of the referent.
type: string
clusterRef:
description: CrossNamespaceClusterReference contains
enough information to let you locate the typed Kubernetes
resource object at cluster level.
properties:
apiVersion:
description: API version of the referent.
type: string
kind:
description: Kind of the referent.
enum:
- GitopsCluster
type: string
name:
description: Name of the referent.
type: string
namespace:
description: Namespace of the referent, defaults
to the namespace of the Kubernetes resource
object that contains the reference.
type: string
required:
- kind
- name
type: object
kind:
description: Kind of the referent.
type: string
name:
description: Name of the referent.
type: string
required:
- apiVersion
- kind
- name
type: object
error:
description: Error is set if the application object is
not present or not ready, and empty otherwise.
type: string
ready:
description: Ready is true if the application object is
present and healthy, and false otherwise.
type: boolean
revision:
description: Revision is set if the application object
is present and has had a configuration applied, and
empty otherwise.
type: string
required:
- clusterAppRef
- ready
type: object
type: array
waitingApproval:
description: WaitingApproval holds the environment revision
that's currently waiting approval.
Expand Down
66 changes: 66 additions & 0 deletions config/crd/bases/pipelines.weave.works_pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,72 @@ spec:
environments:
additionalProperties:
properties:
targets:
items:
description: TargetStatus represents the status of an application
object.
properties:
clusterAppRef:
description: ClusterAppRef gives the app object reference,
and a cluster reference if in a remote cluster
properties:
apiVersion:
description: API version of the referent.
type: string
clusterRef:
description: CrossNamespaceClusterReference contains
enough information to let you locate the typed Kubernetes
resource object at cluster level.
properties:
apiVersion:
description: API version of the referent.
type: string
kind:
description: Kind of the referent.
enum:
- GitopsCluster
type: string
name:
description: Name of the referent.
type: string
namespace:
description: Namespace of the referent, defaults
to the namespace of the Kubernetes resource
object that contains the reference.
type: string
required:
- kind
- name
type: object
kind:
description: Kind of the referent.
type: string
name:
description: Name of the referent.
type: string
required:
- apiVersion
- kind
- name
type: object
error:
description: Error is set if the application object is
not present or not ready, and empty otherwise.
type: string
ready:
description: Ready is true if the application object is
present and healthy, and false otherwise.
type: boolean
revision:
description: Revision is set if the application object
is present and has had a configuration applied, and
empty otherwise.
type: string
required:
- clusterAppRef
- ready
type: object
type: array
waitingApproval:
description: WaitingApproval holds the environment revision
that's currently waiting approval.
Expand Down
Loading

0 comments on commit d19807f

Please sign in to comment.