Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ help: ## Display this help.

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=git-sync-controller-manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=git-controller-manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand Down
8 changes: 4 additions & 4 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
domain: ocm.software
layout:
- go.kubebuilder.io/v3
projectName: git-sync-controller
repo: github.com/open-component-model/git-sync-controller
projectName: git-controller
repo: github.com/open-component-model/git-controller
resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: ocm.software
group: delivery
kind: GitSync
path: github.com/open-component-model/git-sync-controller/api/v1alpha1
kind: Sync
path: github.com/open-component-model/git-controller/api/v1alpha1
version: v1alpha1
version: "3"
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# git-sync-controller
# git-controller
// TODO(user): Add simple overview of use/purpose

## Description
Expand All @@ -16,15 +16,15 @@ kubectl apply -f config/samples/
```

2. Build and push your image to the location specified by `IMG`:

```sh
make docker-build docker-push IMG=<some-registry>/git-sync-controller:tag
make docker-build docker-push IMG=<some-registry>/git-controller:tag
```

3. Deploy the controller to the cluster with the image specified by `IMG`:

```sh
make deploy IMG=<some-registry>/git-sync-controller:tag
make deploy IMG=<some-registry>/git-controller:tag
```

### Uninstall CRDs
Expand All @@ -47,8 +47,8 @@ make undeploy
### How it works
This project aims to follow the Kubernetes [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/)

It uses [Controllers](https://kubernetes.io/docs/concepts/architecture/controller/)
which provides a reconcile function responsible for synchronizing resources untile the desired state is reached on the cluster
It uses [Controllers](https://kubernetes.io/docs/concepts/architecture/controller/)
which provides a reconcile function responsible for synchronizing resources untile the desired state is reached on the cluster

### Test It Out
1. Install the CRDs into the cluster:
Expand Down
6 changes: 3 additions & 3 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ install = kustomize('config/default')
# running process.
objects = decode_yaml_stream(install)
for o in objects:
if o.get('kind') == 'Deployment' and o.get('metadata').get('name') == 'git-sync-controller':
if o.get('kind') == 'Deployment' and o.get('metadata').get('name') == 'git-controller':
o['spec']['template']['spec']['securityContext']['runAsNonRoot'] = False
break

Expand All @@ -33,7 +33,7 @@ load('ext://restart_process', 'docker_build_with_restart')
# Once done, rebuilding now should be a lot faster since only the relevant
# binary is rebuilt and the hot swat wrapper takes care of the rest.
local_resource(
'git-sync-controller-binary',
'git-controller-binary',
'CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/manager ./',
deps = [
"main.go",
Expand All @@ -54,7 +54,7 @@ local_resource(
entrypoint = ['/manager']
dockerfile = 'tilt.dockerfile'
docker_build_with_restart(
'ghcr.io/open-component-model/git-sync-controller',
'ghcr.io/open-component-model/git-controller',
'.',
dockerfile = dockerfile,
entrypoint = entrypoint,
Expand Down
30 changes: 15 additions & 15 deletions api/v1alpha1/gitsync_types.go → api/v1alpha1/sync_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ type CommitTemplate struct {
Message string `json:"message"`
}

// GitSyncSpec defines the desired state of GitSync
type GitSyncSpec struct {
// SyncSpec defines the desired state of Sync
type SyncSpec struct {
SnapshotRef Ref `json:"snapshotRef"`
Interval metav1.Duration `json:"interval"`
URL string `json:"url"`
Expand All @@ -36,8 +36,8 @@ type GitSyncSpec struct {
Prune bool `json:"prune,omitempty"`
}

// GitSyncStatus defines the observed state of GitSync
type GitSyncStatus struct {
// SyncStatus defines the observed state of Sync
type SyncStatus struct {
Digest string `json:"digest,omitempty"`

// ObservedGeneration is the last reconciled generation.
Expand All @@ -50,42 +50,42 @@ type GitSyncStatus struct {
}

// GetConditions returns the conditions of the ComponentVersion.
func (in *GitSync) GetConditions() []metav1.Condition {
func (in *Sync) GetConditions() []metav1.Condition {
return in.Status.Conditions
}

// SetConditions sets the conditions of the ComponentVersion.
func (in *GitSync) SetConditions(conditions []metav1.Condition) {
func (in *Sync) SetConditions(conditions []metav1.Condition) {
in.Status.Conditions = conditions
}

// GetRequeueAfter returns the duration after which the ComponentVersion must be
// reconciled again.
func (in GitSync) GetRequeueAfter() time.Duration {
func (in Sync) GetRequeueAfter() time.Duration {
return in.Spec.Interval.Duration
}

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

// GitSync is the Schema for the gitsyncs API
type GitSync struct {
// Sync is the Schema for the syncs API
type Sync struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec GitSyncSpec `json:"spec,omitempty"`
Status GitSyncStatus `json:"status,omitempty"`
Spec SyncSpec `json:"spec,omitempty"`
Status SyncStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&GitSync{}, &GitSyncList{})
SchemeBuilder.Register(&Sync{}, &SyncList{})
}
86 changes: 37 additions & 49 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
name: gitsyncs.delivery.ocm.software
name: syncs.delivery.ocm.software
spec:
group: delivery.ocm.software
names:
kind: GitSync
listKind: GitSyncList
plural: gitsyncs
singular: gitsync
kind: Sync
listKind: SyncList
plural: syncs
singular: sync
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: GitSync is the Schema for the gitsyncs API
description: Sync is the Schema for the syncs API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -33,7 +33,7 @@ spec:
metadata:
type: object
spec:
description: GitSyncSpec defines the desired state of GitSync
description: SyncSpec defines the desired state of Sync
properties:
authRef:
description: Ref defines a name and namespace ref to any object.
Expand Down Expand Up @@ -92,7 +92,7 @@ spec:
- url
type: object
status:
description: GitSyncStatus defines the observed state of GitSync
description: SyncStatus defines the observed state of Sync
properties:
conditions:
items:
Expand Down
2 changes: 1 addition & 1 deletion config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
resources:
- bases/delivery.ocm.software_gitsyncs.yaml
- bases/delivery.ocm.software_syncs.yaml
#+kubebuilder:scaffold:crdkustomizeresource

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
Loading