-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding support for scaffolding a componentconfig type
Signed-off-by: Chris Hein <me@chrishein.com>
- Loading branch information
1 parent
367fa11
commit 23e49e0
Showing
13 changed files
with
252 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
pkg/plugin/v3/scaffolds/internal/templates/componentconfig.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package templates | ||
|
||
import ( | ||
"sigs.k8s.io/kubebuilder/pkg/model/file" | ||
) | ||
|
||
var _ file.Template = &ComponentConfig{} | ||
|
||
// ComponentConfig scaffolds the ComponentConfig file in manager folder. | ||
type ComponentConfig struct { | ||
file.TemplateMixin | ||
file.DomainMixin | ||
file.RepositoryMixin | ||
} | ||
|
||
// SetTemplateDefaults implements input.Template | ||
func (f *ComponentConfig) SetTemplateDefaults() error { | ||
if f.Path == "" { | ||
f.Path = "config.yaml" | ||
} | ||
|
||
f.TemplateBody = componentConfigTemplate | ||
|
||
f.IfExistsAction = file.Error | ||
|
||
return nil | ||
} | ||
|
||
const componentConfigTemplate = `apiVersion: controller-runtime.sigs.k8s.io/v1alpha1 | ||
kind: ControllerManagerConfiguration | ||
metrics: | ||
bindAddress: :8080 | ||
webhook: | ||
port: 9443 | ||
leaderElection: | ||
leaderElect: false | ||
resourceLock: configmaps | ||
resourceName: {{ hash .Repo }}.{{ .Domain }}", | ||
` |
61 changes: 61 additions & 0 deletions
61
pkg/plugin/v3/scaffolds/internal/templates/config/kdefault/config_manager_patch.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
Copyright 2020 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package kdefault | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"sigs.k8s.io/kubebuilder/pkg/model/file" | ||
) | ||
|
||
var _ file.Template = &ManagerConfigPatch{} | ||
|
||
// ManagerConfigPatch scaffolds a ManagerConfigPatch for a Resource | ||
type ManagerConfigPatch struct { | ||
file.TemplateMixin | ||
} | ||
|
||
// SetTemplateDefaults implements input.Template | ||
func (f *ManagerConfigPatch) SetTemplateDefaults() error { | ||
if f.Path == "" { | ||
f.Path = filepath.Join("config", "default", "manager_config_patch.yaml") | ||
} | ||
|
||
f.TemplateBody = managerConfigPatchTemplate | ||
|
||
return nil | ||
} | ||
|
||
const managerConfigPatchTemplate = `apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: manager | ||
volumeMounts: | ||
- name: config | ||
mountPath: /config.yaml | ||
subPath: config.yaml | ||
volumes: | ||
- name: config | ||
configMap: | ||
name: controller-config | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.