Skip to content

Commit c92dc80

Browse files
authored
Remove the templates-controller and webhooks (#12)
* Remove the templates-controller and webhooks - The templates-controller only provides a webhook to convert v1alpha1 templates to v1alpha2 - This was done for a customer during a transition and is no longer needed - Remove the controller and the webhooks - We now generate a helm chart that only includes CRDs, this might be overkill * stop pushing docker image * Align files with a fresh kubebuiler project * only include CRDs in generated helm chart
1 parent 5c4e306 commit c92dc80

29 files changed

+153
-1316
lines changed

.github/workflows/ci.yaml

-33
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,3 @@ jobs:
3232
cache: true
3333
- name: Test
3434
run: make test
35-
36-
build:
37-
runs-on: ubuntu-latest
38-
permissions:
39-
contents: read # for actions/checkout to fetch code
40-
packages: write
41-
steps:
42-
- name: Checkout
43-
uses: actions/checkout@v3
44-
with:
45-
fetch-depth: 0 # for git describe
46-
ref: ${{ github.event.pull_request.head.sha || github.sha }}
47-
48-
- name: Log in to the Container registry
49-
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
50-
with:
51-
registry: ${{ env.REGISTRY }}
52-
username: ${{ github.actor }}
53-
password: ${{ secrets.GITHUB_TOKEN }}
54-
55-
- name: Extract metadata (tags, labels) for Docker
56-
id: meta
57-
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
58-
with:
59-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
60-
61-
- name: Build and push Docker image
62-
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
63-
with:
64-
context: .
65-
push: true
66-
tags: ${{ steps.meta.outputs.tags }}
67-
labels: ${{ steps.meta.outputs.labels }}

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ helmify:
159159

160160
.PHONY: helm
161161
helm: manifests kustomize helmify
162-
$(KUSTOMIZE) build config/default | $(HELMIFY) -crd-dir ../weave-gitops-enterprise/charts/templates-controller
162+
$(KUSTOMIZE) build config/crd | $(HELMIFY) -crd-dir ../weave-gitops-enterprise/charts/templates-controller
163163

164164

165165
# go-get-tool will 'go get' any package $2 and install it to $1.

PROJECT

-8
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,14 @@ resources:
1313
kind: CAPITemplate
1414
path: github.com/weaveworks/templates-controller/apis/capi/v1alpha1
1515
version: v1alpha1
16-
webhooks:
17-
conversion: true
18-
webhookVersion: v1
1916
- api:
2017
crdVersion: v1
2118
namespaced: true
22-
controller: true
2319
domain: weave.works
2420
group: capi
2521
kind: CAPITemplate
2622
path: github.com/weaveworks/templates-controller/apis/capi/v1alpha2
2723
version: v1alpha2
28-
webhooks:
29-
conversion: true
30-
webhookVersion: v1
3124
- api:
3225
crdVersion: v1
3326
namespaced: true
@@ -39,7 +32,6 @@ resources:
3932
- api:
4033
crdVersion: v1
4134
namespaced: true
42-
controller: true
4335
domain: weave.works
4436
group: templates
4537
kind: GitOpsTemplate

apis/capi/v1alpha1/capitemplate_conversion.go

-27
This file was deleted.

apis/capi/v1alpha1/capitemplate_webhook.go

-33
This file was deleted.

apis/capi/v1alpha2/capitemplate_webhook.go

-33
This file was deleted.

apis/core/utils.go

-16
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,3 @@ func ConvertV1SpecToSpec(s TemplateSpecV1) TemplateSpec {
1212
},
1313
}
1414
}
15-
16-
// Convert v1alpha2 spec to v1alpha1 spec
17-
func ConvertV2SpecToV1Spec(s TemplateSpec) TemplateSpecV1 {
18-
resourceTemplates := []ResourceTemplateContent{}
19-
for _, rt := range s.ResourceTemplates {
20-
resourceTemplates = append(resourceTemplates, rt.Content...)
21-
}
22-
23-
return TemplateSpecV1{
24-
Description: s.Description,
25-
RenderType: s.RenderType,
26-
Params: s.Params,
27-
Charts: s.Charts,
28-
ResourceTemplates: resourceTemplates,
29-
}
30-
}

apis/core/utils_test.go

-33
Original file line numberDiff line numberDiff line change
@@ -41,39 +41,6 @@ func TestConvertV1SpectToSpec(t *testing.T) {
4141
assert.Equal(t, expected, spec)
4242
}
4343

44-
func TestConvertV2SpecToV1Spec(t *testing.T) {
45-
expected := TemplateSpecV1{
46-
Description: "description",
47-
RenderType: "renderType",
48-
Params: []TemplateParam{
49-
{
50-
Name: "name",
51-
Description: "description",
52-
},
53-
},
54-
Charts: ChartsSpec{
55-
Items: []Chart{
56-
{
57-
Chart: "chart",
58-
},
59-
},
60-
},
61-
// only diff is here
62-
// everything concatenated, paths lost
63-
ResourceTemplates: []ResourceTemplateContent{
64-
makeTemplateResource("foo"),
65-
makeTemplateResource("foo2"),
66-
makeTemplateResource("bar"),
67-
makeTemplateResource("bar2"),
68-
},
69-
}
70-
71-
v2spec := makeTemplateSpec()
72-
v1Spec := ConvertV2SpecToV1Spec(v2spec)
73-
74-
assert.Equal(t, expected, v1Spec)
75-
}
76-
7744
func makeTemplateSpec() TemplateSpec {
7845
return TemplateSpec{
7946
Description: "description",

apis/gitops/v1alpha1/gitopstemplate_conversion.go

-28
This file was deleted.

apis/gitops/v1alpha1/gitopstemplate_webhook.go

-17
This file was deleted.

apis/gitops/v1alpha2/gitopstemplate_webhook.go

-17
This file was deleted.

config/certmanager/certificate.yaml

-39
This file was deleted.

config/certmanager/kustomization.yaml

-5
This file was deleted.

config/certmanager/kustomizeconfig.yaml

-16
This file was deleted.

config/crd/kustomization.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ resources:
99
patchesStrategicMerge:
1010
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
1111
# patches here are for enabling the conversion webhook for each CRD
12-
- patches/webhook_in_capitemplates.yaml
13-
- patches/webhook_in_templates_gitopstemplates.yaml
12+
#- patches/webhook_in_capitemplates.yaml
13+
#- patches/webhook_in_templates_gitopstemplates.yaml
1414
#+kubebuilder:scaffold:crdkustomizewebhookpatch
1515

1616
# [CERTMANAGER] To enable cert-manager, uncomment all the sections with [CERTMANAGER] prefix.
1717
# patches here are for enabling the CA injection for each CRD
18-
- patches/cainjection_in_capitemplates.yaml
19-
- patches/cainjection_in_templates_gitopstemplates.yaml
18+
#- patches/cainjection_in_capitemplates.yaml
19+
#- patches/cainjection_in_templates_gitopstemplates.yaml
2020
#+kubebuilder:scaffold:crdkustomizecainjectionpatch
2121

2222
# the following config is for teaching kustomize how to do kustomization for CRDs.

0 commit comments

Comments
 (0)