mirror of
https://github.com/wahyd4/cert-manager.git
synced 2026-08-09 05:06:38 +10:00
cleanup & better error debug printing
Signed-off-by: Inteon <42113979+inteon@users.noreply.github.com>
This commit is contained in:
@@ -13,7 +13,6 @@ go_library(
|
||||
"ingress_controller.go",
|
||||
"samplewebhook.go",
|
||||
"suite.go",
|
||||
"tiller.go",
|
||||
"venafi.go",
|
||||
],
|
||||
importpath = "github.com/jetstack/cert-manager/test/e2e/framework/config",
|
||||
|
||||
@@ -22,9 +22,6 @@ import (
|
||||
|
||||
// Addons contains global configuration for instances of addons
|
||||
type Addons struct {
|
||||
// Tiller describes the global configuration values for the tiller addon
|
||||
Tiller Tiller
|
||||
|
||||
// Helm describes the global configuration values for helm
|
||||
Helm Helm
|
||||
|
||||
@@ -52,7 +49,6 @@ type Addons struct {
|
||||
}
|
||||
|
||||
func (a *Addons) AddFlags(fs *flag.FlagSet) {
|
||||
a.Tiller.AddFlags(fs)
|
||||
a.Helm.AddFlags(fs)
|
||||
a.ACMEServer.AddFlags(fs)
|
||||
a.IngressController.AddFlags(fs)
|
||||
@@ -64,7 +60,6 @@ func (a *Addons) AddFlags(fs *flag.FlagSet) {
|
||||
|
||||
func (a *Addons) Validate() []error {
|
||||
var errs []error
|
||||
errs = append(errs, a.Tiller.Validate()...)
|
||||
errs = append(errs, a.Helm.Validate()...)
|
||||
errs = append(errs, a.ACMEServer.Validate()...)
|
||||
errs = append(errs, a.IngressController.Validate()...)
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
Copyright 2020 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 config
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Tiller struct {
|
||||
// Tiller image repo to use when deploying
|
||||
ImageRepo string
|
||||
|
||||
// Tiller image tag to use when deploying
|
||||
ImageTag string
|
||||
}
|
||||
|
||||
func (n *Tiller) AddFlags(fs *flag.FlagSet) {
|
||||
fs.StringVar(&n.ImageRepo, "tiller-image-repo", "gcr.io/kubernetes-helm/tiller", "docker image repo for tiller-deploy")
|
||||
fs.StringVar(&n.ImageTag, "tiller-image-tag", "bazel", "docker image tag for tiller-deploy")
|
||||
}
|
||||
|
||||
func (n *Tiller) Validate() []error {
|
||||
var errs []error
|
||||
if n.ImageRepo == "" {
|
||||
errs = append(errs, fmt.Errorf("--tiller-image-repo must be specified"))
|
||||
}
|
||||
if n.ImageTag == "" {
|
||||
errs = append(errs, fmt.Errorf("--tiller-image-tag must be specified"))
|
||||
}
|
||||
return errs
|
||||
}
|
||||
@@ -6,6 +6,7 @@ go_library(
|
||||
"certificaterequests.go",
|
||||
"certificates.go",
|
||||
"certificatesigningrequests.go",
|
||||
"describe.go",
|
||||
"helper.go",
|
||||
"kubectl.go",
|
||||
"pod_start.go",
|
||||
@@ -20,6 +21,7 @@ go_library(
|
||||
"//pkg/apis/certmanager/v1:go_default_library",
|
||||
"//pkg/apis/meta/v1:go_default_library",
|
||||
"//pkg/client/clientset/versioned:go_default_library",
|
||||
"//pkg/client/clientset/versioned/scheme:go_default_library",
|
||||
"//pkg/client/clientset/versioned/typed/certmanager/v1:go_default_library",
|
||||
"//pkg/controller/certificatesigningrequests/util:go_default_library",
|
||||
"//pkg/util:go_default_library",
|
||||
@@ -34,8 +36,11 @@ go_library(
|
||||
"@io_k8s_api//core/v1:go_default_library",
|
||||
"@io_k8s_apimachinery//pkg/api/errors:go_default_library",
|
||||
"@io_k8s_apimachinery//pkg/apis/meta/v1:go_default_library",
|
||||
"@io_k8s_apimachinery//pkg/runtime:go_default_library",
|
||||
"@io_k8s_apimachinery//pkg/runtime/serializer/json:go_default_library",
|
||||
"@io_k8s_apimachinery//pkg/util/wait:go_default_library",
|
||||
"@io_k8s_client_go//kubernetes:go_default_library",
|
||||
"@io_k8s_client_go//kubernetes/scheme:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -71,15 +71,9 @@ func (h *Helper) waitForCertificateCondition(client clientset.CertificateInterfa
|
||||
if pollErr != nil && certificate != nil {
|
||||
log.Logf("Failed waiting for certificate %v: %v\n", name, pollErr.Error())
|
||||
|
||||
if len(certificate.Status.Conditions) > 0 {
|
||||
log.Logf("Observed certificate conditions:\n")
|
||||
for _, cond := range certificate.Status.Conditions {
|
||||
log.Logf("- Last Status: '%s' Reason: '%s', Message: '%s'\n", cond.Status, cond.Reason, cond.Message)
|
||||
}
|
||||
}
|
||||
log.Logf("Certificate:\n")
|
||||
h.describeCMObject(certificate)
|
||||
|
||||
log.Logf("Certificate description:\n")
|
||||
h.Kubectl(certificate.Namespace).DescribeResource("certificate", name)
|
||||
log.Logf("Order and challenge descriptions:\n")
|
||||
h.Kubectl(certificate.Namespace).Describe("order", "challenge")
|
||||
|
||||
@@ -124,6 +118,11 @@ func (h *Helper) WaitForCertificateReadyAndDoneIssuing(cert *cmapi.Certificate,
|
||||
return false
|
||||
}
|
||||
|
||||
if certificate.Status.NextPrivateKeySecretName != nil {
|
||||
log.Logf("Expected Certificate %v 'next-private-key-secret-name' attribute to be empty but has: %v", certificate.Name, *certificate.Status.NextPrivateKeySecretName)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}, timeout)
|
||||
}
|
||||
@@ -158,6 +157,11 @@ func (h *Helper) WaitForCertificateNotReadyAndDoneIssuing(cert *cmapi.Certificat
|
||||
return false
|
||||
}
|
||||
|
||||
if certificate.Status.NextPrivateKeySecretName != nil {
|
||||
log.Logf("Expected Certificate %v 'next-private-key-secret-name' attribute to be empty but has: %v", certificate.Name, *certificate.Status.NextPrivateKeySecretName)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}, timeout)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright 2020 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 helper
|
||||
|
||||
import (
|
||||
cmscheme "github.com/jetstack/cert-manager/pkg/client/clientset/versioned/scheme"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
runtimejson "k8s.io/apimachinery/pkg/runtime/serializer/json"
|
||||
kubescheme "k8s.io/client-go/kubernetes/scheme"
|
||||
"os"
|
||||
)
|
||||
|
||||
func (h *Helper) describeKubeObject(object runtime.Object) error {
|
||||
serializer := runtimejson.NewSerializerWithOptions(runtimejson.DefaultMetaFactory, kubescheme.Scheme, kubescheme.Scheme, runtimejson.SerializerOptions{
|
||||
Yaml: true,
|
||||
Pretty: true,
|
||||
})
|
||||
encoder := kubescheme.Codecs.WithoutConversion().EncoderForVersion(serializer, nil)
|
||||
return encoder.Encode(object, os.Stdout)
|
||||
}
|
||||
|
||||
func (h *Helper) describeCMObject(object runtime.Object) error {
|
||||
serializer := runtimejson.NewSerializerWithOptions(runtimejson.DefaultMetaFactory, cmscheme.Scheme, cmscheme.Scheme, runtimejson.SerializerOptions{
|
||||
Yaml: true,
|
||||
Pretty: true,
|
||||
})
|
||||
encoder := cmscheme.Codecs.WithoutConversion().EncoderForVersion(serializer, nil)
|
||||
return encoder.Encode(object, os.Stdout)
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/helper/validation"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/helper/validation/certificates"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/helper/validation/certificatesigningrequests"
|
||||
"github.com/jetstack/cert-manager/test/e2e/framework/log"
|
||||
)
|
||||
|
||||
// ValidateCertificate retrieves the issued certificate and runs all validation functions
|
||||
@@ -42,6 +43,12 @@ func (h *Helper) ValidateCertificate(certificate *cmapi.Certificate, validations
|
||||
for _, fn := range validations {
|
||||
err := fn(certificate, secret)
|
||||
if err != nil {
|
||||
log.Logf("Certificate:\n")
|
||||
h.describeCMObject(certificate)
|
||||
|
||||
log.Logf("Secret:\n")
|
||||
h.describeKubeObject(secret)
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,8 @@ func (s *Suite) complete(f *framework.Framework) {
|
||||
s.DomainSuffix = f.Config.Addons.IngressController.Domain
|
||||
case "Gateway":
|
||||
s.DomainSuffix = f.Config.Addons.Gateway.Domain
|
||||
default:
|
||||
s.DomainSuffix = "example.com"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user