Skip to content

Commit

Permalink
Remove the templates-controller and webhooks (#12)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
foot authored Jul 13, 2023
1 parent 5c4e306 commit c92dc80
Show file tree
Hide file tree
Showing 29 changed files with 153 additions and 1,316 deletions.
33 changes: 0 additions & 33 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,36 +32,3 @@ jobs:
cache: true
- name: Test
run: make test

build:
runs-on: ubuntu-latest
permissions:
contents: read # for actions/checkout to fetch code
packages: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # for git describe
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Log in to the Container registry
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ helmify:

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


# go-get-tool will 'go get' any package $2 and install it to $1.
Expand Down
8 changes: 0 additions & 8 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,14 @@ resources:
kind: CAPITemplate
path: github.com/weaveworks/templates-controller/apis/capi/v1alpha1
version: v1alpha1
webhooks:
conversion: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: weave.works
group: capi
kind: CAPITemplate
path: github.com/weaveworks/templates-controller/apis/capi/v1alpha2
version: v1alpha2
webhooks:
conversion: true
webhookVersion: v1
- api:
crdVersion: v1
namespaced: true
Expand All @@ -39,7 +32,6 @@ resources:
- api:
crdVersion: v1
namespaced: true
controller: true
domain: weave.works
group: templates
kind: GitOpsTemplate
Expand Down
27 changes: 0 additions & 27 deletions apis/capi/v1alpha1/capitemplate_conversion.go

This file was deleted.

33 changes: 0 additions & 33 deletions apis/capi/v1alpha1/capitemplate_webhook.go

This file was deleted.

33 changes: 0 additions & 33 deletions apis/capi/v1alpha2/capitemplate_webhook.go

This file was deleted.

16 changes: 0 additions & 16 deletions apis/core/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,3 @@ func ConvertV1SpecToSpec(s TemplateSpecV1) TemplateSpec {
},
}
}

// Convert v1alpha2 spec to v1alpha1 spec
func ConvertV2SpecToV1Spec(s TemplateSpec) TemplateSpecV1 {
resourceTemplates := []ResourceTemplateContent{}
for _, rt := range s.ResourceTemplates {
resourceTemplates = append(resourceTemplates, rt.Content...)
}

return TemplateSpecV1{
Description: s.Description,
RenderType: s.RenderType,
Params: s.Params,
Charts: s.Charts,
ResourceTemplates: resourceTemplates,
}
}
33 changes: 0 additions & 33 deletions apis/core/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,39 +41,6 @@ func TestConvertV1SpectToSpec(t *testing.T) {
assert.Equal(t, expected, spec)
}

func TestConvertV2SpecToV1Spec(t *testing.T) {
expected := TemplateSpecV1{
Description: "description",
RenderType: "renderType",
Params: []TemplateParam{
{
Name: "name",
Description: "description",
},
},
Charts: ChartsSpec{
Items: []Chart{
{
Chart: "chart",
},
},
},
// only diff is here
// everything concatenated, paths lost
ResourceTemplates: []ResourceTemplateContent{
makeTemplateResource("foo"),
makeTemplateResource("foo2"),
makeTemplateResource("bar"),
makeTemplateResource("bar2"),
},
}

v2spec := makeTemplateSpec()
v1Spec := ConvertV2SpecToV1Spec(v2spec)

assert.Equal(t, expected, v1Spec)
}

func makeTemplateSpec() TemplateSpec {
return TemplateSpec{
Description: "description",
Expand Down
28 changes: 0 additions & 28 deletions apis/gitops/v1alpha1/gitopstemplate_conversion.go

This file was deleted.

17 changes: 0 additions & 17 deletions apis/gitops/v1alpha1/gitopstemplate_webhook.go

This file was deleted.

17 changes: 0 additions & 17 deletions apis/gitops/v1alpha2/gitopstemplate_webhook.go

This file was deleted.

39 changes: 0 additions & 39 deletions config/certmanager/certificate.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions config/certmanager/kustomization.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions config/certmanager/kustomizeconfig.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ resources:
patchesStrategicMerge:
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix.
# patches here are for enabling the conversion webhook for each CRD
- patches/webhook_in_capitemplates.yaml
- patches/webhook_in_templates_gitopstemplates.yaml
#- patches/webhook_in_capitemplates.yaml
#- patches/webhook_in_templates_gitopstemplates.yaml
#+kubebuilder:scaffold:crdkustomizewebhookpatch

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

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

0 comments on commit c92dc80

Please sign in to comment.