-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add helm plugin scaffolding new layout
- Loading branch information
1 parent
85663a9
commit 4c409fb
Showing
78 changed files
with
6,783 additions
and
424 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,58 @@ | ||
#!/usr/bin/env bash | ||
|
||
# remove running containers on exit | ||
function cleanup() { | ||
kind delete cluster | ||
} | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
source ./hack/lib/common.sh | ||
source ./hack/lib/test_lib.sh | ||
|
||
test_dir=./test | ||
tests=$test_dir/e2e-helm-new | ||
|
||
export TRACE=1 | ||
export GO111MODULE=on | ||
|
||
: ${K8S_VERSION:?"must be set"} | ||
|
||
prepare_staging_dir $tmp_sdk_root | ||
fetch_tools $tmp_sdk_root | ||
|
||
header_text "###" | ||
header_text "### These envtest environment variables are required for the default unit tests" | ||
header_text "### scaffolded in the test operator project. No e2e tests currently use envtest." | ||
header_text "###" | ||
|
||
setup_envs $tmp_sdk_root | ||
build_sdk $tmp_sdk_root | ||
setup_kustomize $tmp_sdk_root | ||
|
||
header_text "### Create a cluster of version $K8S_VERSION." | ||
|
||
kind create cluster -v 4 --retain --wait=1m \ | ||
--config $test_dir/kind-config.yaml \ | ||
--image=kindest/node:$K8S_VERSION | ||
|
||
kind export kubeconfig | ||
|
||
kubectl cluster-info | ||
|
||
header_text "###" | ||
header_text "### Building Helm Image" | ||
header_text "###" | ||
make image-build-helm | ||
|
||
header_text "###" | ||
header_text "### Loading kubebuilder images" | ||
header_text "###" | ||
docker pull gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0 | ||
kind load docker-image gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0 | ||
|
||
trap_add cleanup EXIT | ||
|
||
go test $tests -v -ginkgo.v |
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,56 @@ | ||
/* | ||
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 cmdutil | ||
|
||
import "sigs.k8s.io/kubebuilder/pkg/plugin/scaffold" | ||
|
||
// RunOptions represent the types used to implement the different commands | ||
type RunOptions interface { | ||
// - Step 1: verify that the command can be run (e.g., go version, project version, arguments, ...) | ||
Validate() error | ||
// - Step 2: create the Scaffolder instance | ||
GetScaffolder() (scaffold.Scaffolder, error) | ||
// - Step 3: call the Scaffold method of the Scaffolder instance. Doesn't need any method | ||
// - Step 4: finish the command execution | ||
PostScaffold() error | ||
} | ||
|
||
// Run executes a command | ||
func Run(options RunOptions) error { | ||
// Step 1: validate | ||
if err := options.Validate(); err != nil { | ||
return err | ||
} | ||
|
||
// Step 2: get scaffolder | ||
scaffolder, err := options.GetScaffolder() | ||
if err != nil { | ||
return err | ||
} | ||
// Step 3: scaffold | ||
if scaffolder != nil { | ||
if err := scaffolder.Scaffold(); err != nil { | ||
return err | ||
} | ||
} | ||
// Step 4: finish | ||
if err := options.PostScaffold(); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
Oops, something went wrong.