Skip to content

Commit

Permalink
Move to gitops-tools repo.
Browse files Browse the repository at this point in the history
Rename GitopsCluster to GitOpsCluster.
  • Loading branch information
bigkevmcd committed Feb 23, 2024
1 parent 18aaaa1 commit 83a2aa5
Show file tree
Hide file tree
Showing 16 changed files with 163 additions and 131 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ jobs:
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.WGE_DOCKER_IO_USER }}
password: ${{ secrets.WGE_DOCKER_IO_PASSWORD }}
username: ${{ secrets.DOCKER_IO_USER }}
password: ${{ secrets.DOCKER_IO_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@dbef88086f6cef02e264edb7dbf63250c17cef6c # v5.5.0
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
### Bug Fixes

* use CAPIClusterRef when looking for kubeconfig secret ([4191177](https://github.com/weaveworks/cluster-controller/commit/4191177a12f6139e3eab3566b02e8be916adafea))
* use the NewGitopsClusterReconciler constructor ([a472d8c](https://github.com/weaveworks/cluster-controller/commit/a472d8c3d047691180d7fb6fc4710e3c79ec48e9))
* use the NewGitOpsClusterReconciler constructor ([a472d8c](https://github.com/weaveworks/cluster-controller/commit/a472d8c3d047691180d7fb6fc4710e3c79ec48e9))
* wait for control plane for readiness ([7d9497f](https://github.com/weaveworks/cluster-controller/commit/7d9497f4eea5714bd3b8b207559d179a4e4598a2))

## 1.0.0 (2022-04-21)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ VERSION ?= 0.0.1
# Image URL to use all building/pushing image targets
IMG ?= controller:latest
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.27
ENVTEST_K8S_VERSION = 1.29

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down
6 changes: 3 additions & 3 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ domain: weave.works
layout:
- go.kubebuilder.io/v3
projectName: cluster-controller
repo: github.com/weaveworks/cluster-controller
repo: github.com/gitops-tools/cluster-controller
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: weave.works
group: gitops
kind: GitopsCluster
path: github.com/weaveworks/cluster-controller/api/v1alpha1
kind: GitOpsCluster
path: github.com/gitops-tools/cluster-controller/api/v1alpha1
version: v1alpha1
version: "3"
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,33 @@

cluster-controller for Weave GitOps Enterprise.

This provides an in-cluster representation of clusters.

A `GitOpsCluster` can reference an existing CAPI cluster.

```yaml
apiVersion: gitops.weave.works/v1alpha1
kind: GitOpsCluster
metadata:
name: dev
namespace: default
spec:
capiClusterRef:
name: dev
```
Alternatively, a `GitOpsCluster` can reference a secret containing a kube config
file.

```yaml
apiVersion: gitops.weave.works/v1alpha1
kind: GitOpsCluster
metadata:
name: dev
namespace: default
spec:
secretRef:
name: dev
```

This code was originally written for Weave GitOps Enterprise.
30 changes: 15 additions & 15 deletions api/v1alpha1/gitopscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import (
"github.com/fluxcd/pkg/apis/meta"
)

// GitOpsClusterNoSecretFinalizerAnnotation if applied to a GitopsCluster
// GitOpsClusterNoSecretFinalizerAnnotation if applied to a GitOpsCluster
// indicates that we should not wait for the secret to be removed before
// allowing the cluster to be removed.
const GitOpsClusterNoSecretFinalizerAnnotation = "clusters.gitops.weave.works/no-secret-finalizer"

// GitopsClusterSpec defines the desired state of GitopsCluster
// GitOpsClusterSpec defines the desired state of GitOpsCluster
// +kubebuilder:validation:XValidation:rule="(has(self.secretRef) || has(self.capiClusterRef))",message="must provide a secretRef or capiClusterRef"
// +kubebuilder:validation:XValidation:rule="!(has(self.secretRef) && has(self.capiClusterRef))",message="cannot provide both capiClusterRef and secretRef"
type GitopsClusterSpec struct {
type GitOpsClusterSpec struct {
// SecretRef specifies the Secret containing the kubeconfig for a cluster.
// +optional
SecretRef *meta.LocalObjectReference `json:"secretRef,omitempty"`
Expand All @@ -39,20 +39,20 @@ type GitopsClusterSpec struct {
CAPIClusterRef *meta.LocalObjectReference `json:"capiClusterRef,omitempty"`
}

// GitopsClusterStatus defines the observed state of GitopsCluster
type GitopsClusterStatus struct {
// GitOpsClusterStatus defines the observed state of GitOpsCluster
type GitOpsClusterStatus struct {
// Conditions holds the conditions for the Cluster.
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

// GetConditions returns the status conditions of the object.
func (in GitopsCluster) GetConditions() []metav1.Condition {
func (in GitOpsCluster) GetConditions() []metav1.Condition {
return in.Status.Conditions
}

// SetConditions sets the status conditions on the object.
func (in *GitopsCluster) SetConditions(conditions []metav1.Condition) {
func (in *GitOpsCluster) SetConditions(conditions []metav1.Condition) {
in.Status.Conditions = conditions
}

Expand All @@ -63,25 +63,25 @@ func (in *GitopsCluster) SetConditions(conditions []metav1.Condition) {
// +kubebuilder:printcolumn:name="Status",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].message",description=""
// +kubebuilder:printcolumn:name="ClusterConnectivity",type="string",JSONPath=".status.conditions[?(@.type==\"ClusterConnectivity\")].status",description=""

// GitopsCluster is the Schema for the gitopsclusters API
// GitOpsCluster is the Schema for the gitopsclusters API
// +kubebuilder:validation:XValidation:rule="has(self.spec)",message="must confgure spec"
type GitopsCluster struct {
type GitOpsCluster struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec GitopsClusterSpec `json:"spec,omitempty"`
Status GitopsClusterStatus `json:"status,omitempty"`
Spec GitOpsClusterSpec `json:"spec,omitempty"`
Status GitOpsClusterStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&GitopsCluster{}, &GitopsClusterList{})
SchemeBuilder.Register(&GitOpsCluster{}, &GitOpsClusterList{})
}
39 changes: 20 additions & 19 deletions api/v1alpha1/zz_generated.deepcopy.go

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

15 changes: 8 additions & 7 deletions config/crd/bases/gitops.weave.works_gitopsclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.13.0
controller-gen.kubebuilder.io/version: v0.11.0
creationTimestamp: null
name: gitopsclusters.gitops.weave.works
spec:
group: gitops.weave.works
names:
kind: GitopsCluster
listKind: GitopsClusterList
kind: GitOpsCluster
listKind: GitOpsClusterList
plural: gitopsclusters
singular: gitopscluster
scope: Namespaced
Expand All @@ -30,7 +31,7 @@ spec:
name: v1alpha1
schema:
openAPIV3Schema:
description: GitopsCluster is the Schema for the gitopsclusters API
description: GitOpsCluster is the Schema for the gitopsclusters API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -45,7 +46,7 @@ spec:
metadata:
type: object
spec:
description: GitopsClusterSpec defines the desired state of GitopsCluster
description: GitOpsClusterSpec defines the desired state of GitOpsCluster
properties:
capiClusterRef:
description: CAPIClusterRef specifies the CAPI Cluster.
Expand Down Expand Up @@ -73,7 +74,7 @@ spec:
- message: cannot provide both capiClusterRef and secretRef
rule: '!(has(self.secretRef) && has(self.capiClusterRef))'
status:
description: GitopsClusterStatus defines the observed state of GitopsCluster
description: GitOpsClusterStatus defines the observed state of GitOpsCluster
properties:
conditions:
description: Conditions holds the conditions for the Cluster.
Expand Down Expand Up @@ -147,7 +148,7 @@ spec:
type: object
type: object
x-kubernetes-validations:
- message: must configure spec
- message: must confgure spec
rule: has(self.spec)
served: true
storage: true
Expand Down
1 change: 1 addition & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/gitops_v1alpha1_gitopscluster_capi.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: gitops.weave.works/v1alpha1
kind: GitopsCluster
kind: GitOpsCluster
metadata:
name: dev
namespace: default
Expand Down
2 changes: 1 addition & 1 deletion config/samples/gitops_v1alpha1_gitopscluster_secret.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: gitops.weave.works/v1alpha1
kind: GitopsCluster
kind: GitOpsCluster
metadata:
name: dev
namespace: default
Expand Down
Loading

0 comments on commit 83a2aa5

Please sign in to comment.