-
Notifications
You must be signed in to change notification settings - Fork 1.6k
π Refactor sampleexternalplugin to be a Valid Reference Implementation #5116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
bc205e3
aafb6f9
d70c339
5395def
9d001d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # Binaries for programs and plugins | ||
| *.exe | ||
| *.exe~ | ||
| *.dll | ||
| *.so | ||
| *.dylib | ||
| sampleexternalplugin | ||
| bin/ | ||
|
|
||
| # Test binary, built with `go test -c` | ||
| *.test | ||
|
|
||
| # Output of the go coverage tool, specifically when used with LiteIDE | ||
| *.out | ||
|
|
||
| # Go workspace file | ||
| go.work | ||
|
|
||
| # Temporary test directories | ||
| testdata/testplugin/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,17 +36,27 @@ func flagsCmd(pr *external.PluginRequest) external.PluginResponse { | |
| Flags: []external.Flag{}, | ||
| } | ||
|
|
||
| switch pr.Command { | ||
| // Parse args to determine which subcommand flags are being requested | ||
| var subcommand string | ||
| for _, arg := range pr.Args { | ||
| if arg == "--init" { | ||
| subcommand = "init" | ||
| break | ||
| } else if arg == "--edit" { | ||
| subcommand = "edit" | ||
| break | ||
| } | ||
| } | ||
|
|
||
| switch subcommand { | ||
| case "init": | ||
nerdeveloper marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| pluginResponse.Flags = scaffolds.InitFlags | ||
| case "create api": | ||
| pluginResponse.Flags = scaffolds.ApiFlags | ||
| case "create webhook": | ||
| pluginResponse.Flags = scaffolds.WebhookFlags | ||
| case "edit": | ||
| pluginResponse.Flags = scaffolds.EditFlags | ||
| default: | ||
| pluginResponse.Error = true | ||
| pluginResponse.ErrorMsgs = []string{ | ||
| "unrecognized command: " + pr.Command, | ||
| "unrecognized subcommand flag in args: " + string(rune(len(pr.Args))), | ||
|
||
| } | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /* | ||
| Copyright 2022 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 prometheus | ||
|
|
||
| // PrometheusKustomization represents the kustomization.yaml for Prometheus resources | ||
| type PrometheusKustomization struct { | ||
| Path string | ||
| Content string | ||
| } | ||
|
|
||
| // NewPrometheusKustomization creates a new kustomization.yaml for Prometheus resources | ||
| func NewPrometheusKustomization() *PrometheusKustomization { | ||
| return &PrometheusKustomization{ | ||
| Path: "config/prometheus/kustomization.yaml", | ||
| Content: prometheusKustomizationTemplate, | ||
| } | ||
| } | ||
|
|
||
| const prometheusKustomizationTemplate = `resources: | ||
| - prometheus.yaml | ||
| ` | ||
|
|
||
| // DefaultKustomizationPatch represents a patch to config/default/kustomization.yaml | ||
| type DefaultKustomizationPatch struct { | ||
| Path string | ||
| Content string | ||
| } | ||
|
|
||
| // NewDefaultKustomizationPatch creates a patch comment for the default kustomization.yaml | ||
| func NewDefaultKustomizationPatch() *DefaultKustomizationPatch { | ||
| return &DefaultKustomizationPatch{ | ||
| Path: "config/default/kustomization_prometheus_patch.yaml", | ||
| Content: defaultKustomizationPatchTemplate, | ||
| } | ||
| } | ||
|
|
||
| const defaultKustomizationPatchTemplate = `# [PROMETHEUS] To enable prometheus monitoring, uncomment the following line in config/default/kustomization.yaml: | ||
| # | ||
| # In the resources section, add: | ||
| # - ../prometheus | ||
| # | ||
| # This will include the Prometheus instance in your deployment. | ||
| # Make sure you have the Prometheus Operator installed in your cluster. | ||
| # | ||
| # For more information, see: https://github.com/prometheus-operator/prometheus-operator | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only one that we have is: https://github.com/kubernetes-sigs/kubebuilder/blob/master/testdata/project-v4/config/default/kustomization.yaml So, we need to keep the config centralised there. |
||
| ` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should pass some arg here so that we can ilustrate how to use it