Skip to content
Permalink
Browse files

Merge pull request #1190 from justinsb/dont_rewrite_shared_vars

Avoid rewriting template values, mark them as const
  • Loading branch information
k8s-ci-robot committed Nov 14, 2019
2 parents 28fb4c5 + 7b632b2 commit 074202516e1faf9aa4af6b80fe9d80ca433c71b9
Showing with 75 additions and 74 deletions.
  1. +1 −1 pkg/scaffold/project/authproxyrole.go
  2. +1 −1 pkg/scaffold/project/authproxyrolebinding.go
  3. +2 −2 pkg/scaffold/project/boilerplate.go
  4. +1 −1 pkg/scaffold/project/gitignore.go
  5. +1 −1 pkg/scaffold/project/gopkg.go
  6. +1 −1 pkg/scaffold/project/kustomize.go
  7. +1 −1 pkg/scaffold/project/kustomize_manager_base.go
  8. +1 −1 pkg/scaffold/project/kustomize_rbac_base.go
  9. +1 −1 pkg/scaffold/project/makefile.go
  10. +1 −1 pkg/scaffold/v1/authproxyservice.go
  11. +1 −1 pkg/scaffold/v1/controller/add.go
  12. +1 −1 pkg/scaffold/v1/controller/controller.go
  13. +1 −1 pkg/scaffold/v1/controller/controllersuitetest.go
  14. +1 −1 pkg/scaffold/v1/controller/controllertest.go
  15. +1 −1 pkg/scaffold/v1/crd/addtoscheme.go
  16. +1 −1 pkg/scaffold/v1/crd/crd_sample.go
  17. +1 −1 pkg/scaffold/v1/crd/doc.go
  18. +1 −1 pkg/scaffold/v1/crd/group.go
  19. +1 −1 pkg/scaffold/v1/crd/register.go
  20. +1 −1 pkg/scaffold/v1/crd/types.go
  21. +1 −1 pkg/scaffold/v1/crd/typestest.go
  22. +1 −1 pkg/scaffold/v1/crd/version_suitetest.go
  23. +1 −1 pkg/scaffold/v1/kustomize_image_patch.go
  24. +1 −1 pkg/scaffold/v1/manager/apis.go
  25. +1 −1 pkg/scaffold/v1/manager/cmd.go
  26. +1 −1 pkg/scaffold/v1/manager/config.go
  27. +1 −1 pkg/scaffold/v1/manager/controller.go
  28. +1 −1 pkg/scaffold/v1/manager/dockerfile.go
  29. +1 −1 pkg/scaffold/v1/manager/webhook.go
  30. +1 −1 pkg/scaffold/v1/metricsauth/kustomize_auth_proxy_patch.go
  31. +1 −1 pkg/scaffold/v1/metricsauth/kustomize_metrics_patch.go
  32. +1 −1 pkg/scaffold/v1/webhook/add_admissionbuilder_handler.go
  33. +1 −1 pkg/scaffold/v1/webhook/add_server.go
  34. +1 −1 pkg/scaffold/v1/webhook/admissionbuilder.go
  35. +1 −1 pkg/scaffold/v1/webhook/admissionhandler.go
  36. +1 −1 pkg/scaffold/v1/webhook/admissionwebhooks.go
  37. +1 −1 pkg/scaffold/v1/webhook/server.go
  38. +1 −1 pkg/scaffold/v2/authproxyservice.go
  39. +1 −1 pkg/scaffold/v2/certmanager/certificate.go
  40. +1 −1 pkg/scaffold/v2/certmanager/kustomize.go
  41. +1 −1 pkg/scaffold/v2/certmanager/kustomizeconfig.go
  42. +1 −1 pkg/scaffold/v2/controller.go
  43. +1 −1 pkg/scaffold/v2/controller_suitetest.go
  44. +1 −1 pkg/scaffold/v2/crd/enablecainjection_patch.go
  45. +1 −1 pkg/scaffold/v2/crd/enablewebhook_patch.go
  46. +1 −1 pkg/scaffold/v2/crd/kustomizeconfig.go
  47. +1 −1 pkg/scaffold/v2/crd_sample.go
  48. +1 −1 pkg/scaffold/v2/dockerfile.go
  49. +1 −1 pkg/scaffold/v2/gomod.go
  50. +1 −1 pkg/scaffold/v2/group.go
  51. +1 −1 pkg/scaffold/v2/kustomize.go
  52. +1 −1 pkg/scaffold/v2/leaderelectionrole.go
  53. +1 −1 pkg/scaffold/v2/leaderelectionrolebinding.go
  54. +1 −1 pkg/scaffold/v2/makefile.go
  55. +1 −1 pkg/scaffold/v2/manager/config.go
  56. +1 −1 pkg/scaffold/v2/manager/kustomization.go
  57. +1 −1 pkg/scaffold/v2/metricsauth/kustomize_auth_proxy_patch.go
  58. +1 −1 pkg/scaffold/v2/mgrrolebinding.go
  59. +1 −1 pkg/scaffold/v2/prometheus/kustomize.go
  60. +1 −1 pkg/scaffold/v2/prometheus/monitor.go
  61. +1 −1 pkg/scaffold/v2/rbac.go
  62. +1 −1 pkg/scaffold/v2/types.go
  63. +1 −1 pkg/scaffold/v2/webhook/enablecainection_patch.go
  64. +1 −1 pkg/scaffold/v2/webhook/kustomization.go
  65. +1 −1 pkg/scaffold/v2/webhook/kustomizeconfig.go
  66. +1 −1 pkg/scaffold/v2/webhook/service.go
  67. +5 −4 pkg/scaffold/v2/webhook/webhook.go
  68. +1 −1 pkg/scaffold/v2/webhook_manager_patch.go
  69. +1 −1 plugins/addon/controller.go
  70. +1 −1 plugins/addon/type.go
@@ -38,7 +38,7 @@ func (r *AuthProxyRole) GetInput() (input.Input, error) {
return r.Input, nil
}

var proxyRoleTemplate = `apiVersion: rbac.authorization.k8s.io/v1
const proxyRoleTemplate = `apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: proxy-role
@@ -38,7 +38,7 @@ func (r *AuthProxyRoleBinding) GetInput() (input.Input, error) {
return r.Input, nil
}

var proxyRoleBindinggTemplate = `apiVersion: rbac.authorization.k8s.io/v1
const proxyRoleBindinggTemplate = `apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: proxy-rolebinding
@@ -65,7 +65,7 @@ func (c *Boilerplate) GetInput() (input.Input, error) {
return c.Input, nil
}

var apache = `/*
const apache = `/*
{{ if .Owner }}Copyright {{ .Year }} {{ .Owner }}.
{{ end }}
Licensed under the Apache License, Version 2.0 (the "License");
@@ -81,6 +81,6 @@ See the License for the specific language governing permissions and
limitations under the License.
*/`

var none = `/*
const none = `/*
{{ if .Owner }}Copyright {{ .Year }} {{ .Owner }}{{ end }}.
*/`
@@ -36,7 +36,7 @@ func (c *GitIgnore) GetInput() (input.Input, error) {
return c.Input, nil
}

var gitignoreTemplate = `
const gitignoreTemplate = `
# Binaries for programs and plugins
*.exe
*.exe~
@@ -134,7 +134,7 @@ const DefaultGopkgUserContent = `required = [
`

var depTemplate = `{{ .UserContent }}
const depTemplate = `{{ .UserContent }}
# STANZAS BELOW ARE GENERATED AND MAY BE WRITTEN - DO NOT MODIFY BELOW THIS LINE.
{{ range $element := .Stanzas -}}
@@ -51,7 +51,7 @@ func (c *Kustomize) GetInput() (input.Input, error) {
return c.Input, nil
}

var kustomizeTemplate = `# Adds namespace to all resources.
const kustomizeTemplate = `# Adds namespace to all resources.
namespace: {{.Prefix}}-system
# Value of this field is prepended to the
@@ -39,6 +39,6 @@ func (c *KustomizeManager) GetInput() (input.Input, error) {
return c.Input, nil
}

var kustomizeManagerTemplate = `resources:
const kustomizeManagerTemplate = `resources:
- manager.yaml
`
@@ -39,7 +39,7 @@ func (c *KustomizeRBAC) GetInput() (input.Input, error) {
return c.Input, nil
}

var kustomizeRBACTemplate = `resources:
const kustomizeRBACTemplate = `resources:
- rbac_role.yaml
- rbac_role_binding.yaml
# Comment the following 3 lines if you want to disable
@@ -48,7 +48,7 @@ func (c *Makefile) GetInput() (input.Input, error) {
return c.Input, nil
}

var makefileTemplate = `
const makefileTemplate = `
# Image URL to use all building/pushing image targets
IMG ?= {{ .Image }}
@@ -38,7 +38,7 @@ func (r *AuthProxyService) GetInput() (input.Input, error) {
return r.Input, nil
}

var AuthProxyServiceTemplate = `apiVersion: v1
const AuthProxyServiceTemplate = `apiVersion: v1
kind: Service
metadata:
annotations:
@@ -45,7 +45,7 @@ func (a *AddController) GetInput() (input.Input, error) {
return a.Input, nil
}

var addControllerTemplate = `{{ .Boilerplate }}
const addControllerTemplate = `{{ .Boilerplate }}
package controller
@@ -97,7 +97,7 @@ func getResourceInfo(coreGroups map[string]string, r *resource.Resource, in inpu
return path.Join(in.Repo, "pkg", "apis"), r.Group + "." + in.Domain
}

var controllerTemplate = `{{ .Boilerplate }}
const controllerTemplate = `{{ .Boilerplate }}
package {{ lower .Resource.Kind }}
@@ -42,7 +42,7 @@ func (a *SuiteTest) GetInput() (input.Input, error) {
return a.Input, nil
}

var controllerSuiteTestTemplate = `{{ .Boilerplate }}
const controllerSuiteTestTemplate = `{{ .Boilerplate }}
package {{ lower .Resource.Kind }}
@@ -66,7 +66,7 @@ func (a *Test) GetInput() (input.Input, error) {
return a.Input, nil
}

var controllerTestTemplate = `{{ .Boilerplate }}
const controllerTestTemplate = `{{ .Boilerplate }}
package {{ lower .Resource.Kind }}
@@ -52,7 +52,7 @@ func (a *AddToScheme) Validate() error {
// NB(directxman12): we need that package alias on the API import otherwise imports.Process
// gets wicked (or hella, if you're feeling west-coasty) confused.

var addResourceTemplate = `{{ .Boilerplate }}
const addResourceTemplate = `{{ .Boilerplate }}
package apis
@@ -52,7 +52,7 @@ func (c *CRDSample) Validate() error {
return c.Resource.Validate()
}

var crdSampleTemplate = `apiVersion: {{ .Resource.Group }}.{{ .Domain }}/{{ .Resource.Version }}
const crdSampleTemplate = `apiVersion: {{ .Resource.Group }}.{{ .Domain }}/{{ .Resource.Version }}
kind: {{ .Resource.Kind }}
metadata:
labels:
@@ -50,7 +50,7 @@ func (a *Doc) Validate() error {
return a.Resource.Validate()
}

var docGoTemplate = `{{ .Boilerplate }}
const docGoTemplate = `{{ .Boilerplate }}
// Package {{.Resource.Version}} contains API Schema definitions for the {{ .Resource.GroupImportSafe }} {{.Resource.Version}} API group
// +k8s:openapi-gen=true
@@ -47,7 +47,7 @@ func (g *Group) Validate() error {
return g.Resource.Validate()
}

var groupTemplate = `{{ .Boilerplate }}
const groupTemplate = `{{ .Boilerplate }}
// Package {{ .Resource.GroupImportSafe }} contains {{ .Resource.Group }} API versions
package {{ .Resource.GroupImportSafe }}
@@ -47,7 +47,7 @@ func (r *Register) Validate() error {
return r.Resource.Validate()
}

var registerTemplate = `{{ .Boilerplate }}
const registerTemplate = `{{ .Boilerplate }}
// NOTE: Boilerplate only. Ignore this file.
@@ -51,7 +51,7 @@ func (t *Types) Validate() error {
return t.Resource.Validate()
}

var typesTemplate = `{{ .Boilerplate }}
const typesTemplate = `{{ .Boilerplate }}
package {{ .Resource.Version }}
@@ -51,7 +51,7 @@ func (t *TypesTest) Validate() error {
return t.Resource.Validate()
}

var typesTestTemplate = `{{ .Boilerplate }}
const typesTestTemplate = `{{ .Boilerplate }}
package {{ .Resource.Version }}
@@ -49,7 +49,7 @@ func (v *VersionSuiteTest) Validate() error {
return v.Resource.Validate()
}

var versionSuiteTestTemplate = `{{ .Boilerplate }}
const versionSuiteTestTemplate = `{{ .Boilerplate }}
package {{ .Resource.Version }}
@@ -46,7 +46,7 @@ func (c *KustomizeImagePatch) GetInput() (input.Input, error) {
return c.Input, nil
}

var kustomizeImagePatchTemplate = `apiVersion: apps/v1
const kustomizeImagePatchTemplate = `apiVersion: apps/v1
kind: StatefulSet
metadata:
name: controller-manager
@@ -58,7 +58,7 @@ func (a *APIs) GetInput() (input.Input, error) {
return a.Input, nil
}

var apisTemplate = `{{ .Boilerplate }}
const apisTemplate = `{{ .Boilerplate }}
{{ range $line := .Comments }}{{ $line }}
{{ end }}
@@ -38,7 +38,7 @@ func (a *Cmd) GetInput() (input.Input, error) {
return a.Input, nil
}

var cmdTemplate = `{{ .Boilerplate }}
const cmdTemplate = `{{ .Boilerplate }}
package main
@@ -40,7 +40,7 @@ func (c *Config) GetInput() (input.Input, error) {
return c.Input, nil
}

var configTemplate = `apiVersion: v1
const configTemplate = `apiVersion: v1
kind: Namespace
metadata:
labels:
@@ -38,7 +38,7 @@ func (c *Controller) GetInput() (input.Input, error) {
return c.Input, nil
}

var controllerTemplate = `{{ .Boilerplate }}
const controllerTemplate = `{{ .Boilerplate }}
package controller
@@ -36,7 +36,7 @@ func (c *Dockerfile) GetInput() (input.Input, error) {
return c.Input, nil
}

var dockerfileTemplate = `# Build the manager binary
const dockerfileTemplate = `# Build the manager binary
FROM golang:1.10.3 as builder
# Copy in the go src
@@ -38,7 +38,7 @@ func (c *Webhook) GetInput() (input.Input, error) {
return c.Input, nil
}

var webhookTemplate = `{{ .Boilerplate }}
const webhookTemplate = `{{ .Boilerplate }}
package webhook
@@ -40,7 +40,7 @@ func (c *KustomizeAuthProxyPatch) GetInput() (input.Input, error) {
return c.Input, nil
}

var kustomizeAuthProxyPatchTemplate = `# This patch inject a sidecar container which is a HTTP proxy for the controller manager,
const kustomizeAuthProxyPatchTemplate = `# This patch inject a sidecar container which is a HTTP proxy for the controller manager,
# it performs RBAC authorization against the Kubernetes API using SubjectAccessReviews.
apiVersion: apps/v1
kind: StatefulSet
@@ -40,7 +40,7 @@ func (c *KustomizePrometheusMetricsPatch) GetInput() (input.Input, error) {
return c.Input, nil
}

var kustomizePrometheusMetricsPatchTemplate = `# This patch enables Prometheus scraping for the manager pod.
const kustomizePrometheusMetricsPatchTemplate = `# This patch enables Prometheus scraping for the manager pod.
apiVersion: apps/v1
kind: StatefulSet
metadata:
@@ -49,7 +49,7 @@ func (a *AddAdmissionWebhookBuilderHandler) GetInput() (input.Input, error) {
return a.Input, nil
}

var addAdmissionWebhookBuilderHandlerTemplate = `{{ .Boilerplate }}
const addAdmissionWebhookBuilderHandlerTemplate = `{{ .Boilerplate }}
package {{ .Server }}server
@@ -45,7 +45,7 @@ func (a *AddServer) GetInput() (input.Input, error) {
return a.Input, nil
}

var addServerTemplate = `{{ .Boilerplate }}
const addServerTemplate = `{{ .Boilerplate }}
package webhook
@@ -75,7 +75,7 @@ func (a *AdmissionWebhookBuilder) GetInput() (input.Input, error) {
return a.Input, nil
}

var admissionWebhookBuilderTemplate = `{{ .Boilerplate }}
const admissionWebhookBuilderTemplate = `{{ .Boilerplate }}
package {{ .Type }}
@@ -74,7 +74,7 @@ func (a *AdmissionHandler) GetInput() (input.Input, error) {
return a.Input, nil
}

var addAdmissionHandlerTemplate = `{{ .Boilerplate }}
const addAdmissionHandlerTemplate = `{{ .Boilerplate }}
package {{ .Type }}
@@ -51,7 +51,7 @@ func (a *AdmissionWebhooks) GetInput() (input.Input, error) {
return a.Input, nil
}

var webhooksTemplate = `{{ .Boilerplate }}
const webhooksTemplate = `{{ .Boilerplate }}
package {{ .Type }}
@@ -45,7 +45,7 @@ func (a *Server) GetInput() (input.Input, error) {
return a.Input, nil
}

var serverTemplate = `{{ .Boilerplate }}
const serverTemplate = `{{ .Boilerplate }}
package {{ .Server }}server
@@ -38,7 +38,7 @@ func (r *AuthProxyService) GetInput() (input.Input, error) {
return r.Input, nil
}

var AuthProxyServiceTemplate = `apiVersion: v1
const AuthProxyServiceTemplate = `apiVersion: v1
kind: Service
metadata:
labels:
@@ -36,7 +36,7 @@ func (p *CertManager) GetInput() (input.Input, error) {
return p.Input, nil
}

var certManagerTemplate = `# The following manifests contain a self-signed issuer CR and a certificate CR.
const certManagerTemplate = `# The following manifests contain a self-signed issuer CR and a certificate CR.
# More document can be found at https://docs.cert-manager.io
# WARNING: Targets CertManager 0.11 check https://docs.cert-manager.io/en/latest/tasks/upgrading/index.html for breaking changes
apiVersion: cert-manager.io/v1alpha2
@@ -36,7 +36,7 @@ func (p *Kustomization) GetInput() (input.Input, error) {
return p.Input, nil
}

var kustomizationTemplate = `resources:
const kustomizationTemplate = `resources:
- certificate.yaml
configurations:
@@ -36,7 +36,7 @@ func (p *KustomizeConfig) GetInput() (input.Input, error) {
return p.Input, nil
}

var kustomizeConfigTemplate = `# This configuration is for teaching kustomize how to update name ref and var substitution
const kustomizeConfigTemplate = `# This configuration is for teaching kustomize how to update name ref and var substitution
nameReference:
- kind: Issuer
group: cert-manager.io
@@ -64,7 +64,7 @@ func (a *Controller) GetInput() (input.Input, error) {
return a.Input, nil
}

var controllerTemplate = `{{ .Boilerplate }}
const controllerTemplate = `{{ .Boilerplate }}
package controllers
@@ -61,7 +61,7 @@ func (v *ControllerSuiteTest) Validate() error {
return v.Resource.Validate()
}

var controllerSuiteTestTemplate = `{{ .Boilerplate }}
const controllerSuiteTestTemplate = `{{ .Boilerplate }}
package controllers

0 comments on commit 0742025

Please sign in to comment.
You can’t perform that action at this time.