-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mengqi Yu
committed
Jun 5, 2019
1 parent
71237a9
commit 09f13b4
Showing
44 changed files
with
551 additions
and
147 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
Copyright 2019 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 v2 | ||
|
||
import ( | ||
"fmt" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/markbates/inflect" | ||
|
||
"sigs.k8s.io/kubebuilder/pkg/scaffold/input" | ||
"sigs.k8s.io/kubebuilder/pkg/scaffold/v1/resource" | ||
) | ||
|
||
// EnableCAInjectionPatch scaffolds a EnableCAInjectionPatch for a Resource | ||
type EnableCAInjectionPatch struct { | ||
input.Input | ||
|
||
// Resource is the Resource to make the EnableCAInjectionPatch for | ||
Resource *resource.Resource | ||
} | ||
|
||
// GetInput implements input.File | ||
func (p *EnableCAInjectionPatch) GetInput() (input.Input, error) { | ||
if p.Path == "" { | ||
rs := inflect.NewDefaultRuleset() | ||
plural := rs.Pluralize(strings.ToLower(p.Resource.Kind)) | ||
p.Path = filepath.Join("config", "crd", "patches", | ||
fmt.Sprintf("cainjection_in_%s.yaml", plural)) | ||
} | ||
p.TemplateBody = EnableCAInjectionPatchTemplate | ||
return p.Input, nil | ||
} | ||
|
||
// Validate validates the values | ||
func (g *EnableCAInjectionPatch) Validate() error { | ||
return g.Resource.Validate() | ||
} | ||
|
||
var EnableCAInjectionPatchTemplate = `# The following patch adds a directive for certmanager to inject CA into the CRD | ||
# CRD conversion requires k8s 1.13 or later. | ||
apiVersion: apiextensions.k8s.io/v1beta1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
certmanager.k8s.io/inject-ca-from: $(NAMESPACE)/$(CERTIFICATENAME) | ||
name: {{ .Resource.Resource }}.{{ .Resource.Group }}.{{ .Domain }} | ||
` |
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
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 2018 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 v2 | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"sigs.k8s.io/kubebuilder/pkg/scaffold/input" | ||
) | ||
|
||
var _ input.File = &KustomizeImagePatch{} | ||
|
||
// KustomizeImagePatch scaffolds the patch file for customizing image URL | ||
// manifest file for manager resource. | ||
type KustomizeImagePatch struct { | ||
input.Input | ||
|
||
// ImageURL to use for controller image in manager's manifest. | ||
ImageURL string | ||
} | ||
|
||
// GetInput implements input.File | ||
func (c *KustomizeImagePatch) GetInput() (input.Input, error) { | ||
if c.Path == "" { | ||
c.Path = filepath.Join("config", "default", "manager_image_patch.yaml") | ||
} | ||
if c.ImageURL == "" { | ||
c.ImageURL = "IMAGE_URL" | ||
} | ||
c.TemplateBody = kustomizeImagePatchTemplate | ||
c.Input.IfExistsAction = input.Error | ||
return c.Input, nil | ||
} | ||
|
||
var kustomizeImagePatchTemplate = `apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
# Change the value of image field below to your controller image URL | ||
- image: {{ .ImageURL }} | ||
name: manager | ||
` |
Oops, something went wrong.