mirror of
https://github.com/wahyd4/cert-manager.git
synced 2026-08-09 05:06:38 +10:00
Merge pull request #4356 from jetstack-bot/cherry-pick-4342-to-release-1.5
[release-1.5] Don't wait for hooks in `kubectl cert-manager x install` integration test
This commit is contained in:
@@ -93,6 +93,7 @@ filegroup(
|
||||
"//test/e2e:all-srcs",
|
||||
"//test/integration:all-srcs",
|
||||
"//test/internal/apiserver:all-srcs",
|
||||
"//test/internal/util:all-srcs",
|
||||
"//test/unit/coreclients:all-srcs",
|
||||
"//test/unit/discovery:all-srcs",
|
||||
"//test/unit/gen:all-srcs",
|
||||
|
||||
@@ -47,6 +47,7 @@ type InstallOptions struct {
|
||||
|
||||
ChartName string
|
||||
DryRun bool
|
||||
Wait bool
|
||||
|
||||
genericclioptions.IOStreams
|
||||
}
|
||||
@@ -120,7 +121,7 @@ func NewCmdInstall(ctx context.Context, ioStreams genericclioptions.IOStreams, f
|
||||
SilenceErrors: true,
|
||||
}
|
||||
|
||||
addInstallUninstallFlags(cmd.Flags(), &options.client.Timeout, &options.client.Wait)
|
||||
addInstallUninstallFlags(cmd.Flags(), &options.client.Timeout, &options.Wait)
|
||||
addInstallFlags(cmd.Flags(), options.client)
|
||||
addValueOptionsFlags(cmd.Flags(), options.valueOpts)
|
||||
addChartPathOptionsFlags(cmd.Flags(), &options.client.ChartPathOptions)
|
||||
@@ -229,12 +230,11 @@ func (o *InstallOptions) runInstall(ctx context.Context) (*release.Release, erro
|
||||
// Install chart
|
||||
o.client.DryRun = false // Apply DryRun cli flags
|
||||
o.client.ClientOnly = false // Perform install against cluster
|
||||
// 'Atomic=True' means that if part of the install fails, all resource installs are reverted;
|
||||
// Helm supports 3 diffent combinations of the (Atomic, Wait) boolean couple:
|
||||
// (False, False), (False, True) or (True, True)
|
||||
// For simplicity, we want do not support Waiting without the Atomic option (False, True),
|
||||
// this allows this cli to use a single --wait=(True|False) flag
|
||||
o.client.Atomic = o.client.Wait
|
||||
|
||||
o.client.Wait = o.Wait // Wait for resources to be ready
|
||||
o.client.Atomic = o.Wait // If part of the install fails (& we are waiting), all resource installs are reverted;
|
||||
o.client.DisableHooks = !o.Wait // Disable hooks if wait is disabled
|
||||
|
||||
chartValues[installCRDsFlagName] = false // Do not render CRDs, as this might cause problems when uninstalling using helm
|
||||
|
||||
return o.client.Run(chart, chartValues)
|
||||
|
||||
@@ -8,7 +8,9 @@ go_test(
|
||||
"ctl_renew_test.go",
|
||||
"ctl_status_certificate_test.go",
|
||||
],
|
||||
data = glob(["testdata/**"]),
|
||||
data = glob(["testdata/**"]) + [
|
||||
"//deploy/charts/cert-manager:cert-manager.tgz",
|
||||
],
|
||||
embed = [":go_default_library"],
|
||||
deps = [
|
||||
"//cmd/ctl/pkg/convert:go_default_library",
|
||||
@@ -59,6 +61,7 @@ go_library(
|
||||
deps = [
|
||||
"//cmd/ctl/cmd:go_default_library",
|
||||
"//test/integration/ctl/install_framework:go_default_library",
|
||||
"//test/internal/util:go_default_library",
|
||||
"@com_github_sergi_go_diff//diffmatchpatch:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
|
||||
"github.com/jetstack/cert-manager/cmd/ctl/cmd"
|
||||
"github.com/jetstack/cert-manager/test/integration/ctl/install_framework"
|
||||
"github.com/jetstack/cert-manager/test/internal/util"
|
||||
)
|
||||
|
||||
func TestCtlInstall(t *testing.T) {
|
||||
@@ -98,10 +99,12 @@ func executeCommandAndCheckOutput(
|
||||
stdin := bytes.NewBufferString("")
|
||||
stdout := bytes.NewBufferString("")
|
||||
|
||||
chartPath := util.GetTestPath("deploy", "charts", "cert-manager", "cert-manager.tgz")
|
||||
cmd := cmd.NewCertManagerCtlCommand(ctx, stdin, stdout, stdout)
|
||||
cmd.SetArgs(append([]string{
|
||||
fmt.Sprintf("--kubeconfig=%s", kubeConfig),
|
||||
"--wait=false",
|
||||
fmt.Sprintf("--chart-name=%s", chartPath),
|
||||
"x",
|
||||
"install",
|
||||
}, inputArgs...))
|
||||
|
||||
@@ -4,11 +4,14 @@ go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"apiserver.go",
|
||||
"paths.go",
|
||||
"envs.go",
|
||||
],
|
||||
importpath = "github.com/jetstack/cert-manager/test/internal/apiserver",
|
||||
visibility = ["//test:__subpackages__"],
|
||||
deps = ["@io_k8s_sigs_controller_runtime//pkg/envtest:go_default_library"],
|
||||
deps = [
|
||||
"//test/internal/util:go_default_library",
|
||||
"@io_k8s_sigs_controller_runtime//pkg/envtest:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
|
||||
@@ -20,7 +20,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/jetstack/cert-manager/test/internal/util"
|
||||
)
|
||||
|
||||
// setEnvTestEnv configures environment variables for controller-runtime's
|
||||
@@ -44,7 +45,7 @@ Either re-run this test or set the %s environment variable.`, bin, key))
|
||||
}
|
||||
|
||||
func getPath(name string, path ...string) (string, error) {
|
||||
bazelPath := filepath.Join(append([]string{os.Getenv("RUNFILES_DIR"), "com_github_jetstack_cert_manager"}, path...)...)
|
||||
bazelPath := util.GetTestPath(path...)
|
||||
p, err := exec.LookPath(bazelPath)
|
||||
if err == nil {
|
||||
return p, nil
|
||||
@@ -0,0 +1,22 @@
|
||||
load("@io_bazel_rules_go//go:def.bzl", "go_library")
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["paths.go"],
|
||||
importpath = "github.com/jetstack/cert-manager/test/internal/util",
|
||||
visibility = ["//test:__subpackages__"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [":package-srcs"],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
Copyright 2021 The cert-manager 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 util
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func GetTestPath(path ...string) string {
|
||||
return filepath.Join(append([]string{os.Getenv("RUNFILES_DIR"), "com_github_jetstack_cert_manager"}, path...)...)
|
||||
}
|
||||
Reference in New Issue
Block a user