Skip to content

Commit

Permalink
Merge branch 'main' into support-common-git-template-source
Browse files Browse the repository at this point in the history
  • Loading branch information
petar-cvit committed Oct 30, 2024
2 parents ff8e34f + 5b87399 commit d2ca579
Show file tree
Hide file tree
Showing 115 changed files with 9,219 additions and 2,326 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![CNCF Badge](https://img.shields.io/badge/CNCF%20Landscape-5699C6?style=flat-square&color=5699C6)](https://landscape.cncf.io/?item=app-definition-and-development--application-definition-image-build--cyclops)
[![Docker Pulls](https://img.shields.io/docker/pulls/cyclopsui/cyclops-ui?style=flat-square&logo=docker&color=%230db7ed)](https://hub.docker.com/repository/docker/cyclopsui/cyclops-ui/general)
[![Docker Pulls](https://img.shields.io/docker/pulls/cyclopsui/cyclops-ctrl?style=flat-square&logo=docker&color=%230db7ed)](https://hub.docker.com/repository/docker/cyclopsui/cyclops-ctrl/general)
[![Go Report Card](https://goreportcard.com/badge/github.com/cyclops-ui/cyclops/cyclops-ctrl?style=flat-square)](https://goreportcard.com/report/github.com/cyclops-ui/cyclops/cyclops-ctrl)
[![GitHub Actions CI](https://img.shields.io/github/actions/workflow/status/cyclops-ui/cyclops/ci.yml?style=flat-square&logo=github&logoColor=white&label=cyclops%20build)](https://github.com/cyclops-ui/cyclops/actions/workflows/ci.yml)
[![GitHub Actions web](https://img.shields.io/github/actions/workflow/status/cyclops-ui/cyclops/web.yaml?style=flat-square&logo=github&logoColor=white&label=GitHub%20pages%20build)](https://github.com/cyclops-ui/cyclops/actions/workflows/web.yaml)
Expand Down Expand Up @@ -49,7 +49,7 @@ Cyclops can either be installed manually by applying the latest manifest, by usi
To install Cyclops using `kubectl` into your cluster, run the commands below:

```bash
kubectl apply -f https://raw.githubusercontent.com/cyclops-ui/cyclops/v0.13.1/install/cyclops-install.yaml && kubectl apply -f https://raw.githubusercontent.com/cyclops-ui/cyclops/v0.13.1/install/demo-templates.yaml
kubectl apply -f https://raw.githubusercontent.com/cyclops-ui/cyclops/v0.14.1/install/cyclops-install.yaml && kubectl apply -f https://raw.githubusercontent.com/cyclops-ui/cyclops/v0.14.1/install/demo-templates.yaml
```

It will create a new namespace called `cyclops` and deploy everything you need for your Cyclops instance to run.
Expand Down
1 change: 1 addition & 0 deletions cyclops-ctrl/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DISABLE_TELEMETRY=true
PORT=8888
WATCH_NAMESPACE=cyclops
WATCH_NAMESPACE_HELM=
CYCLOPS_VERSION=v0.0.0
2 changes: 2 additions & 0 deletions cyclops-ctrl/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
bin
cover.out
cover.html
18 changes: 18 additions & 0 deletions cyclops-ctrl/.mockery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
quiet: False
disable-version-string: True
with-expecter: True
mockname: "{{.InterfaceName}}"
filename: "{{.MockName}}.go"
outpkg: mocks
dir: mocks
packages:
github.com/cyclops-ui/cyclops/cyclops-ctrl/pkg/cluster/k8sclient:
interfaces:
IKubernetesClient:
config:
dir: pkg/mocks
github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/template:
interfaces:
ITemplateRepo:
config:
dir: mocks
10 changes: 10 additions & 0 deletions cyclops-ctrl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,13 @@ group-imports:

unit-test:
go test -v -tags musl,dynamic ./...

coverage:
go test -v -coverprofile cover.out ./...
go tool cover -html cover.out -o cover.html
open cover.html

mockery:
GOBIN=$(LOCALBIN) go install github.com/vektra/mockery/v2@latest
./bin/mockery

16 changes: 16 additions & 0 deletions cyclops-ctrl/api/v1alpha1/module_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,22 @@ type ModuleValue struct {
Value string `json:"value"`
}

type TemplateSourceType string

const (
TemplateSourceTypeGit TemplateSourceType = "git"
TemplateSourceTypeHelm TemplateSourceType = "helm"
TemplateSourceTypeOCI TemplateSourceType = "oci"
)

type TemplateRef struct {
URL string `json:"repo"`
Path string `json:"path"`
Version string `json:"version"`

// +kubebuilder:validation:Enum=git;helm;oci
// +kubebuilder:validation:Optional
SourceType TemplateSourceType `json:"sourceType,omitempty"`
}

type TemplateGitRef struct {
Expand Down Expand Up @@ -88,6 +100,10 @@ type HistoryTemplateRef struct {
URL string `json:"repo"`
Path string `json:"path"`
Version string `json:"version"`

// +kubebuilder:validation:Enum=git;helm;oci
// +kubebuilder:validation:Optional
SourceType TemplateSourceType `json:"sourceType,omitempty"`
}

type HistoryEntry struct {
Expand Down
20 changes: 16 additions & 4 deletions cyclops-ctrl/cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/auth"
"github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/handler"
"github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/integrations/helm"
"github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/modulecontroller"
"github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/prometheus"
"github.com/cyclops-ui/cyclops/cyclops-ctrl/internal/telemetry"
Expand Down Expand Up @@ -90,7 +91,9 @@ func main() {

prometheus.StartCacheMetricsUpdater(&monitor, templatesRepo.ReturnCache(), 10*time.Second, setupLog)

handler, err := handler.New(templatesRepo, k8sClient, renderer, telemetryClient, monitor)
helmReleaseClient := helm.NewReleaseClient(getHelmWatchNamespace())

handler, err := handler.New(templatesRepo, k8sClient, helmReleaseClient, renderer, telemetryClient, monitor)
if err != nil {
panic(err)
}
Expand All @@ -110,7 +113,7 @@ func main() {
}),
Cache: ctrlCache.Options{
DefaultNamespaces: map[string]ctrlCache.Config{
getWatchNamespace("WATCH_NAMESPACE"): {},
getWatchNamespace(): {},
},
},
})
Expand All @@ -126,6 +129,7 @@ func main() {
k8sClient,
renderer,
telemetryClient,
monitor,
)).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Module")
os.Exit(1)
Expand Down Expand Up @@ -160,10 +164,18 @@ func getEnvBool(key string) bool {
return b
}

func getWatchNamespace(key string) string {
value := os.Getenv(key)
func getWatchNamespace() string {
value := os.Getenv("WATCH_NAMESPACE")
if value == "" {
return "cyclops"
}
return value
}

func getHelmWatchNamespace() string {
value := os.Getenv("WATCH_NAMESPACE_HELM")
if value == "" {
return ""
}
return value
}
12 changes: 12 additions & 0 deletions cyclops-ctrl/config/crd/bases/cyclops-ui.com_modules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ spec:
type: string
repo:
type: string
sourceType:
enum:
- git
- helm
- oci
type: string
version:
type: string
required:
Expand Down Expand Up @@ -74,6 +80,12 @@ spec:
type: string
repo:
type: string
sourceType:
enum:
- git
- helm
- oci
type: string
version:
type: string
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ spec:
type: string
repo:
type: string
sourceType:
enum:
- git
- helm
- oci
type: string
version:
type: string
required:
Expand Down
47 changes: 46 additions & 1 deletion cyclops-ctrl/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
github.com/pkg/errors v0.9.1
github.com/posthog/posthog-go v0.0.0-20240315130956-036dfa9f3555
github.com/prometheus/client_golang v1.16.0
github.com/stretchr/testify v1.8.4
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
helm.sh/helm/v3 v3.15.3
Expand All @@ -27,20 +28,26 @@ require (
k8s.io/apimachinery v0.30.1
k8s.io/client-go v0.30.1
sigs.k8s.io/controller-runtime v0.18.4
sigs.k8s.io/yaml v1.4.0
)

require (
dario.cat/mergo v1.0.0 // indirect
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Masterminds/squirrel v1.5.4 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230828082145-3c4c8a2d2371 // indirect
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/containerd/containerd v1.7.12 // indirect
Expand All @@ -57,12 +64,17 @@ require (
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/evanphx/json-patch v5.7.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-errors/errors v1.4.2 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
Expand All @@ -78,51 +90,79 @@ require (
github.com/golang/glog v1.1.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/btree v1.0.1 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/gosuri/uitable v0.0.4 // indirect
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jmoiron/sqlx v1.3.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/leodido/go-urn v1.2.4 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.0-rc6 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rubenv/sql-migrate v1.5.2 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.8.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/xlab/treeprint v1.2.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/arch v0.3.0 // indirect
Expand All @@ -145,11 +185,16 @@ require (
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gotest.tools/v3 v3.5.1 // indirect
k8s.io/apiserver v0.30.1 // indirect
k8s.io/cli-runtime v0.30.0 // indirect
k8s.io/component-base v0.30.1 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/kubectl v0.30.0 // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
oras.land/oras-go v1.2.5 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/kustomize/kyaml v0.14.3-0.20230601165947-6ce0bf390ce3 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit d2ca579

Please sign in to comment.