Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
9af4a27
list custom resource managed resources
petar-cvit Oct 14, 2024
3a4312c
identify child label by crd gvk
petar-cvit Oct 14, 2024
6d392f5
add use state deps
petar-cvit Oct 14, 2024
3033505
add use callback deps
petar-cvit Oct 15, 2024
32205d5
child labels configmap
petar-cvit Oct 15, 2024
85e8c24
remove print
petar-cvit Oct 16, 2024
9b9480d
fetch resource relations from configmap
petar-cvit Oct 29, 2024
f220b9e
remove volume mount
petar-cvit Oct 29, 2024
aa4e154
Merge branch 'main' into crd-managed-resources
petar-cvit Jan 3, 2025
2a80544
resolve conflicts
petar-cvit Jan 3, 2025
844d088
remove unused getCustomChildLabels
petar-cvit Jan 3, 2025
33f9b7e
Merge branch 'main' into crd-managed-resources
petar-cvit Feb 28, 2025
86cd760
use crds as templates
petar-cvit Mar 4, 2025
2988522
render crd templates
petar-cvit Mar 4, 2025
0d297b3
fix controller tests
petar-cvit Mar 4, 2025
26d6394
template store with crd source type
petar-cvit Mar 5, 2025
14d013e
crd template store with templates tab
petar-cvit Mar 5, 2025
3fd2e4f
fix tests
petar-cvit Mar 5, 2025
dc064d6
remove deps
petar-cvit Mar 6, 2025
6ef3241
remove props
petar-cvit Mar 6, 2025
d4b61c4
template store tab labels
petar-cvit Mar 6, 2025
63563ec
remove env var
petar-cvit Mar 6, 2025
cf8a0e4
Merge pull request #769 from cyclops-ui/template-source-crd
petar-cvit Mar 6, 2025
00b0b9f
check template source on validation
petar-cvit Mar 6, 2025
7df3c12
sort imports
petar-cvit Mar 6, 2025
00d2001
deploy button loading
petar-cvit Feb 28, 2025
8d8c5d5
launch week #2 announcement (#770)
KaradzaJuraj Mar 4, 2025
4d7d1c3
👣 [blog] how we took gitops further (#771)
KaradzaJuraj Mar 6, 2025
c9b4209
1️⃣ [lw2] day #1 (#775)
KaradzaJuraj Mar 10, 2025
210264f
2️⃣ [lw] day 2 (#776)
KaradzaJuraj Mar 11, 2025
3e0997c
🅱️ backstage plugins docs (#777)
petar-cvit Mar 11, 2025
f2ebd19
🧩 [lw] day 3 (#779)
KaradzaJuraj Mar 12, 2025
1b3f8e7
✌️ lw #2 - day 4 feature (#781)
petar-cvit Mar 13, 2025
f6a3fed
🎭 [blog] portal vs platform (#782)
KaradzaJuraj Mar 13, 2025
8adc9d7
[lw2] day 5 (#783)
KaradzaJuraj Mar 14, 2025
0290ab7
mark module CRD status fields as optional (#784)
petar-cvit Mar 15, 2025
5c0b271
📮 emit cyclops install manager (#785)
petar-cvit Mar 17, 2025
c930a57
⚙️ update cyclops to v0.18.1
github-actions[bot] Mar 17, 2025
dbcff32
🤖 helm chart to v0.18.1 (#786)
petar-cvit Mar 17, 2025
d3e753e
🥁 handle errors on fethcing api resources (#772)
petar-cvit Mar 18, 2025
014172d
⚙️ update cyclops to v0.18.2
github-actions[bot] Mar 18, 2025
8933df4
🪵 check group version on resource list render (#788)
petar-cvit Mar 19, 2025
2e918ab
🔥 add k8s role resource (#789)
petar-cvit Mar 20, 2025
4f52836
rm ph (#790)
KaradzaJuraj Mar 20, 2025
8ff5724
remove lw teaser
petar-cvit Mar 27, 2025
2b48284
🧩 [lw] day 3 (#779)
KaradzaJuraj Mar 12, 2025
719564d
🔥 Helm chart install docs (#792)
petar-cvit Mar 23, 2025
c22e2f1
remove namespace select handler (#794)
petar-cvit Mar 25, 2025
20d15a0
🚢 [blog] how platform engineering helps you move like a startup again…
KaradzaJuraj Mar 27, 2025
9a01e78
remove empty
petar-cvit Mar 28, 2025
d6ec2cd
Merge branch 'main' into crd-managed-resources
petar-cvit Apr 3, 2025
ab1eb02
shoe additional printer columns on a cr
petar-cvit Apr 5, 2025
f920c30
map additional printer columns on a CR
petar-cvit Apr 5, 2025
b12ceb7
Merge branch 'main' into crd-managed-resources
petar-cvit Apr 7, 2025
659d931
update install crds
petar-cvit Apr 7, 2025
90c77d4
Merge branch 'main' into crd-managed-resources
petar-cvit Apr 7, 2025
d398c2e
Merge branch 'main' into crd-managed-resources
petar-cvit May 29, 2025
de4c154
use k8s config
petar-cvit May 29, 2025
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
1 change: 1 addition & 0 deletions cyclops-ctrl/.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ WATCH_NAMESPACE=cyclops
WATCH_NAMESPACE_HELM=
CYCLOPS_VERSION=v0.0.0
MODULE_TARGET_NAMESPACE=
CONFIG_PATH=config.yaml
24 changes: 17 additions & 7 deletions cyclops-ctrl/api/v1alpha1/module_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
TemplateSourceTypeGit TemplateSourceType = "git"
TemplateSourceTypeHelm TemplateSourceType = "helm"
TemplateSourceTypeOCI TemplateSourceType = "oci"
TemplateSourceTypeCRD TemplateSourceType = "crd"

GitOpsWriteRepoAnnotation = "cyclops-ui.com/write-repo"
GitOpsWritePathAnnotation = "cyclops-ui.com/write-path"
Expand All @@ -55,11 +56,15 @@ const (
)

type TemplateRef struct {
URL string `json:"repo"`
Path string `json:"path"`
// +kubebuilder:validation:Optional
URL string `json:"repo"`
// +kubebuilder:validation:Optional
Path string `json:"path"`
// +kubebuilder:validation:Optional
Version string `json:"version"`

// +kubebuilder:validation:Enum=git;helm;oci
// +kubebuilder:validation:Optional
CRDName string `json:"CRDName"`
// +kubebuilder:validation:Enum=git;helm;oci;crd
// +kubebuilder:validation:Optional
SourceType TemplateSourceType `json:"sourceType,omitempty"`
}
Expand Down Expand Up @@ -106,11 +111,16 @@ type ModuleStatus struct {
}

type HistoryTemplateRef struct {
URL string `json:"repo"`
Path string `json:"path"`
// +kubebuilder:validation:Optional
URL string `json:"repo"`
// +kubebuilder:validation:Optional
Path string `json:"path"`
// +kubebuilder:validation:Optional
Version string `json:"version"`
// +kubebuilder:validation:Optional
CRDName string `json:"CRDName"`

// +kubebuilder:validation:Enum=git;helm;oci
// +kubebuilder:validation:Enum=git;helm;oci;crd
// +kubebuilder:validation:Optional
SourceType TemplateSourceType `json:"sourceType,omitempty"`
}
Expand Down
3 changes: 2 additions & 1 deletion cyclops-ctrl/cmd/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ func main() {
templatesRepo := template.NewRepo(
credsResolver,
cache.NewInMemoryTemplatesCache(),
k8sClient,
)

monitor, err := prometheus.NewMonitor(setupLog)
Expand Down Expand Up @@ -128,7 +129,7 @@ func main() {
}),
Cache: ctrlCache.Options{
DefaultNamespaces: map[string]ctrlCache.Config{
watchNamespace: {},
getWatchNamespace(): {},
},
},
})
Expand Down
13 changes: 13 additions & 0 deletions cyclops-ctrl/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
childLabels:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment so that people know it's an example for testing

- group: kro.run
version: v1alpha1
kind: Application
matchLabels:
kro.run/instance-name: "{{ .metadata.name }}"
managedGVKs:
- group: apps
version: v1
resource: deployments
- group: ""
version: v1
resource: services
14 changes: 6 additions & 8 deletions cyclops-ctrl/config/crd/bases/cyclops-ui.com_modules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ spec:
type: string
template:
properties:
CRDName:
type: string
path:
type: string
repo:
Expand All @@ -71,13 +73,10 @@ spec:
- git
- helm
- oci
- crd
type: string
version:
type: string
required:
- path
- repo
- version
type: object
values:
x-kubernetes-preserve-unknown-fields: true
Expand All @@ -104,6 +103,8 @@ spec:
type: string
template:
properties:
CRDName:
type: string
path:
type: string
repo:
Expand All @@ -113,13 +114,10 @@ spec:
- git
- helm
- oci
- crd
type: string
version:
type: string
required:
- path
- repo
- version
type: object
values:
x-kubernetes-preserve-unknown-fields: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ spec:
type: object
spec:
properties:
CRDName:
type: string
path:
type: string
repo:
Expand All @@ -64,13 +66,10 @@ spec:
- git
- helm
- oci
- crd
type: string
version:
type: string
required:
- path
- repo
- version
type: object
type: object
served: true
Expand Down
18 changes: 18 additions & 0 deletions cyclops-ctrl/internal/controller/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,21 @@ func (c *Cluster) ListNamespaces(ctx *gin.Context) {

ctx.JSON(http.StatusOK, namespaces)
}

func (c *Cluster) ListCRDs(ctx *gin.Context) {
ctx.Header("Access-Control-Allow-Origin", "*")

crds, err := c.kubernetesClient.ListCRDs()
if err != nil {
ctx.JSON(http.StatusInternalServerError, dto.NewError("Error fetching namespaces", err.Error()))
return
}

crdNames := make([]string, 0)

for _, crd := range crds {
crdNames = append(crdNames, crd.Name)
}

ctx.JSON(http.StatusOK, crdNames)
}
23 changes: 16 additions & 7 deletions cyclops-ctrl/internal/controller/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func (m *Modules) Manifest(ctx *gin.Context) {
request.TemplateRef.Path,
request.TemplateRef.Version,
"",
request.TemplateRef.CRDName,
request.TemplateRef.SourceType,
)
if err != nil {
Expand All @@ -209,7 +210,7 @@ func (m *Modules) Manifest(ctx *gin.Context) {
return
}

manifest, err := m.renderer.HelmTemplate(v1alpha1.Module{
manifest, err := m.renderer.RenderManifest(v1alpha1.Module{
ObjectMeta: metav1.ObjectMeta{
Name: ctx.Param("name"),
},
Expand All @@ -218,6 +219,7 @@ func (m *Modules) Manifest(ctx *gin.Context) {
URL: request.TemplateRef.URL,
Path: request.TemplateRef.Path,
Version: request.TemplateRef.Version,
CRDName: request.TemplateRef.CRDName,
SourceType: request.TemplateRef.SourceType,
},
Values: request.Values,
Expand Down Expand Up @@ -250,6 +252,7 @@ func (m *Modules) CurrentManifest(ctx *gin.Context) {
module.Spec.TemplateRef.Path,
module.Spec.TemplateRef.Version,
module.Status.TemplateResolvedVersion,
module.Spec.TemplateRef.CRDName,
module.Spec.TemplateRef.SourceType,
)
if err != nil {
Expand All @@ -258,7 +261,7 @@ func (m *Modules) CurrentManifest(ctx *gin.Context) {
return
}

manifest, err := m.renderer.HelmTemplate(*module, targetTemplate)
manifest, err := m.renderer.RenderManifest(*module, targetTemplate)
if err != nil {
fmt.Println(err)
ctx.Status(http.StatusInternalServerError)
Expand Down Expand Up @@ -420,6 +423,7 @@ func (m *Modules) UpdateModule(ctx *gin.Context) {
URL: curr.Spec.TemplateRef.URL,
Path: curr.Spec.TemplateRef.Path,
Version: curr.Status.TemplateResolvedVersion,
CRDName: curr.Spec.TemplateRef.CRDName,
SourceType: curr.Spec.TemplateRef.SourceType,
},
Values: curr.Spec.Values,
Expand Down Expand Up @@ -484,6 +488,7 @@ func (m *Modules) HistoryEntryManifest(ctx *gin.Context) {
targetGeneration.TemplateRef.Path,
targetGeneration.TemplateRef.Version,
"",
targetGeneration.TemplateRef.CRDName,
targetGeneration.TemplateRef.SourceType,
)
if err != nil {
Expand All @@ -492,7 +497,7 @@ func (m *Modules) HistoryEntryManifest(ctx *gin.Context) {
return
}

manifest, err := m.renderer.HelmTemplate(v1alpha1.Module{
manifest, err := m.renderer.RenderManifest(v1alpha1.Module{
ObjectMeta: metav1.ObjectMeta{
Name: request.ModuleName,
},
Expand Down Expand Up @@ -656,6 +661,7 @@ func (m *Modules) ResourcesForModule(ctx *gin.Context) {
module.Spec.TemplateRef.Path,
templateVersion,
module.Status.TemplateResolvedVersion,
module.Spec.TemplateRef.CRDName,
module.Spec.TemplateRef.SourceType,
)
if err != nil {
Expand All @@ -670,7 +676,7 @@ func (m *Modules) ResourcesForModule(ctx *gin.Context) {
return
}

manifest, err := m.renderer.HelmTemplate(*module, t)
manifest, err := m.renderer.RenderManifest(*module, t)
if err != nil {
fmt.Println("error rendering manifest", err)
ctx.JSON(http.StatusInternalServerError, dto.NewError("Error rendering Module manifest", err.Error()))
Expand Down Expand Up @@ -710,6 +716,7 @@ func (m *Modules) Template(ctx *gin.Context) {
module.Spec.TemplateRef.Path,
module.Spec.TemplateRef.Version,
module.Status.TemplateResolvedVersion,
module.Spec.TemplateRef.CRDName,
module.Spec.TemplateRef.SourceType,
)
if err != nil {
Expand All @@ -718,7 +725,7 @@ func (m *Modules) Template(ctx *gin.Context) {
return
}

currentManifest, err := m.renderer.HelmTemplate(*module, currentTemplate)
currentManifest, err := m.renderer.RenderManifest(*module, currentTemplate)
if err != nil {
fmt.Println(err)
ctx.JSON(http.StatusInternalServerError, dto.NewError("Error templating current", err.Error()))
Expand All @@ -730,6 +737,7 @@ func (m *Modules) Template(ctx *gin.Context) {
module.Spec.TemplateRef.Path,
module.Spec.TemplateRef.Version,
module.Status.TemplateResolvedVersion,
module.Spec.TemplateRef.CRDName,
module.Spec.TemplateRef.SourceType,
)
if err != nil {
Expand All @@ -738,7 +746,7 @@ func (m *Modules) Template(ctx *gin.Context) {
return
}

proposedManifest, err := m.renderer.HelmTemplate(*module, proposedTemplate)
proposedManifest, err := m.renderer.RenderManifest(*module, proposedTemplate)
if err != nil {
fmt.Println(err)
ctx.JSON(http.StatusInternalServerError, dto.NewError("Error templating proposed", err.Error()))
Expand Down Expand Up @@ -768,6 +776,7 @@ func (m *Modules) HelmTemplate(ctx *gin.Context) {
module.Spec.TemplateRef.Path,
module.Spec.TemplateRef.Version,
module.Status.TemplateResolvedVersion,
module.Spec.TemplateRef.CRDName,
module.Spec.TemplateRef.SourceType,
)
if err != nil {
Expand All @@ -776,7 +785,7 @@ func (m *Modules) HelmTemplate(ctx *gin.Context) {
return
}

_, err = m.renderer.HelmTemplate(*module, currentTemplate)
_, err = m.renderer.RenderManifest(*module, currentTemplate)
if err != nil {
fmt.Println(err)
ctx.JSON(http.StatusInternalServerError, dto.NewError("Error templating", err.Error()))
Expand Down
16 changes: 16 additions & 0 deletions cyclops-ctrl/internal/controller/sse/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,22 @@ func (s *Server) ReleaseResources(ctx *gin.Context) {
s.streamResources(ctx, resources)
}

func (s *Server) CRDResources(ctx *gin.Context) {
r, err := s.k8sClient.GetResource(ctx.Query("group"), ctx.Query("version"), ctx.Query("kind"), ctx.Query("name"), ctx.Query("namespace"))
if err != nil {
ctx.String(http.StatusInternalServerError, err.Error())
return
}

other, ok := r.(*dto.Other)
if !ok {
ctx.String(http.StatusInternalServerError, "failed to fetch resource")
return
}

s.streamResources(ctx, other.Children)
}

func (s *Server) streamResources(ctx *gin.Context, resources []*dto.Resource) {
watchSpecs := make([]k8sclient.ResourceWatchSpec, 0, len(resources))
for _, resource := range resources {
Expand Down
Loading