mirror of
https://github.com/wahyd4/cert-manager.git
synced 2026-08-09 05:06:38 +10:00
Fix circular dependency
Signed-off-by: JoshVanL <vleeuwenjoshua@gmail.com>
This commit is contained in:
@@ -78,17 +78,26 @@ container_pull(
|
||||
)
|
||||
|
||||
# Load and define targets defined in //hack/bin
|
||||
load("//hack/bin:deps.bzl", install_hack_bin = "install")
|
||||
load(
|
||||
"//hack/bin:deps.bzl",
|
||||
install_hack_bin = "install",
|
||||
)
|
||||
|
||||
install_hack_bin()
|
||||
|
||||
# Load and define targets defined in //hack/bin
|
||||
load("//test/e2e:images.bzl", install_e2e_images = "install")
|
||||
load(
|
||||
"//test/e2e:images.bzl",
|
||||
install_e2e_images = "install",
|
||||
)
|
||||
|
||||
install_e2e_images()
|
||||
|
||||
# Load and define targets used for reference doc generation
|
||||
load("//docs/generated/reference:deps.bzl", install_docs_dependencies = "install")
|
||||
load(
|
||||
"//docs/generated/reference:deps.bzl",
|
||||
install_docs_dependencies = "install",
|
||||
)
|
||||
|
||||
install_docs_dependencies()
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ go_test(
|
||||
"//pkg/apis/certmanager/v1alpha1:go_default_library",
|
||||
"//pkg/controller/certificaterequests/test:go_default_library",
|
||||
"//pkg/controller/test:go_default_library",
|
||||
"//pkg/internal/vault:go_default_library",
|
||||
"//pkg/internal/vault/fake:go_default_library",
|
||||
"//test/unit/gen:go_default_library",
|
||||
"//vendor/k8s.io/api/core/v1:go_default_library",
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha1"
|
||||
testcr "github.com/jetstack/cert-manager/pkg/controller/certificaterequests/test"
|
||||
testpkg "github.com/jetstack/cert-manager/pkg/controller/test"
|
||||
internalvault "github.com/jetstack/cert-manager/pkg/internal/vault"
|
||||
fakevault "github.com/jetstack/cert-manager/pkg/internal/vault/fake"
|
||||
"github.com/jetstack/cert-manager/test/unit/gen"
|
||||
)
|
||||
@@ -182,7 +183,7 @@ func TestSign(t *testing.T) {
|
||||
},
|
||||
CheckFn: testcr.MustNoResponse,
|
||||
},
|
||||
fakeVault: fakevault.NewFakeVault().WithSign(nil, nil, errors.New("failed to sign")),
|
||||
fakeVault: fakevault.NewFakeVault().WithNew(internalvault.New).WithSign(nil, nil, errors.New("failed to sign")),
|
||||
expectedErr: false,
|
||||
},
|
||||
"a client with a app role secret referenced with role but failed to sign should report fail": {
|
||||
@@ -209,7 +210,7 @@ func TestSign(t *testing.T) {
|
||||
},
|
||||
CheckFn: testcr.MustNoResponse,
|
||||
},
|
||||
fakeVault: fakevault.NewFakeVault().WithNoOpNew().WithSign(nil, nil, errors.New("failed to sign")),
|
||||
fakeVault: fakevault.NewFakeVault().WithSign(nil, nil, errors.New("failed to sign")),
|
||||
expectedErr: false,
|
||||
},
|
||||
"a client with a token secret referenced with token and signs should return certificate": {
|
||||
@@ -231,7 +232,7 @@ func TestSign(t *testing.T) {
|
||||
ExpectedEvents: []string{},
|
||||
CheckFn: testcr.NoPrivateKeyFieldsSetCheck(rsaPEMCert),
|
||||
},
|
||||
fakeVault: fakevault.NewFakeVault().WithSign(rsaPEMCert, rsaPEMCert, nil),
|
||||
fakeVault: fakevault.NewFakeVault().WithNew(internalvault.New).WithSign(rsaPEMCert, rsaPEMCert, nil),
|
||||
expectedErr: false,
|
||||
},
|
||||
"a client with a app role secret referenced with role should return certificate": {
|
||||
@@ -256,7 +257,7 @@ func TestSign(t *testing.T) {
|
||||
ExpectedEvents: []string{},
|
||||
CheckFn: testcr.NoPrivateKeyFieldsSetCheck(rsaPEMCert),
|
||||
},
|
||||
fakeVault: fakevault.NewFakeVault().WithNoOpNew().WithSign(rsaPEMCert, rsaPEMCert, nil),
|
||||
fakeVault: fakevault.NewFakeVault().WithSign(rsaPEMCert, rsaPEMCert, nil),
|
||||
expectedErr: false,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
/*
|
||||
Copyright 2019 The Jetstack cert-manager contributors.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
@@ -29,6 +29,7 @@ type VaultFactory func(string, corelisters.SecretLister, v1alpha1.GenericIssuer)
|
||||
|
||||
type Vault interface {
|
||||
Sign(csrPEM []byte, duration time.Duration) (certPEM []byte, caPEM []byte, err error)
|
||||
Sys() *vault.Sys
|
||||
}
|
||||
|
||||
type VaultClient interface {
|
||||
|
||||
@@ -11,7 +11,6 @@ go_library(
|
||||
deps = [
|
||||
"//pkg/apis/certmanager/v1alpha1:go_default_library",
|
||||
"//pkg/internal:go_default_library",
|
||||
"//pkg/internal/vault:go_default_library",
|
||||
"//vendor/github.com/hashicorp/vault/api:go_default_library",
|
||||
"//vendor/k8s.io/client-go/listers/core/v1:go_default_library",
|
||||
],
|
||||
|
||||
@@ -19,11 +19,11 @@ package fake
|
||||
import (
|
||||
"time"
|
||||
|
||||
vault "github.com/hashicorp/vault/api"
|
||||
corelisters "k8s.io/client-go/listers/core/v1"
|
||||
|
||||
"github.com/jetstack/cert-manager/pkg/apis/certmanager/v1alpha1"
|
||||
"github.com/jetstack/cert-manager/pkg/internal"
|
||||
"github.com/jetstack/cert-manager/pkg/internal/vault"
|
||||
)
|
||||
|
||||
var _ internal.Vault = &Vault{}
|
||||
@@ -34,13 +34,19 @@ type Vault struct {
|
||||
}
|
||||
|
||||
func NewFakeVault() *Vault {
|
||||
return &Vault{
|
||||
NewFn: vault.New,
|
||||
v := &Vault{
|
||||
SignFn: func([]byte, time.Duration) ([]byte, []byte, error) {
|
||||
return nil, nil, nil
|
||||
},
|
||||
}
|
||||
|
||||
v.NewFn = func(string, corelisters.SecretLister, v1alpha1.GenericIssuer) (internal.Vault, error) {
|
||||
return v, nil
|
||||
}
|
||||
|
||||
return v
|
||||
}
|
||||
|
||||
func (v *Vault) Sign(csrPEM []byte, duration time.Duration) ([]byte, []byte, error) {
|
||||
return v.SignFn(csrPEM, duration)
|
||||
}
|
||||
@@ -52,10 +58,8 @@ func (v *Vault) WithSign(certPEM, caPEM []byte, err error) *Vault {
|
||||
return v
|
||||
}
|
||||
|
||||
func (v *Vault) WithNoOpNew() *Vault {
|
||||
v.NewFn = func(string, corelisters.SecretLister, v1alpha1.GenericIssuer) (internal.Vault, error) {
|
||||
return v, nil
|
||||
}
|
||||
func (v *Vault) WithNew(f internal.VaultFactory) *Vault {
|
||||
v.NewFn = f
|
||||
return v
|
||||
}
|
||||
|
||||
@@ -67,3 +71,7 @@ func (v *Vault) New(ns string, sl corelisters.SecretLister, iss v1alpha1.Generic
|
||||
|
||||
return v, nil
|
||||
}
|
||||
|
||||
func (v *Vault) Sys() *vault.Sys {
|
||||
return new(vault.Sys)
|
||||
}
|
||||
|
||||
@@ -282,8 +282,7 @@ func TestSetToken(t *testing.T) {
|
||||
),
|
||||
fakeClient: vaultfake.NewFakeClient(),
|
||||
expectedToken: "",
|
||||
expectedErr: errors.New(
|
||||
"error reading Vault AppRole from secret: test-namespace/secret-ref-name: secret not found"),
|
||||
expectedErr: errors.New("secret not found"),
|
||||
},
|
||||
|
||||
"if app role secret ref set, return client using token stored": {
|
||||
@@ -674,7 +673,7 @@ func TestRequestTokenWithAppRoleRef(t *testing.T) {
|
||||
),
|
||||
|
||||
expectedToken: "",
|
||||
expectedErr: errors.New("error reading Vault AppRole from secret: test-namespace/test-secret: secret not found"),
|
||||
expectedErr: errors.New("secret not found"),
|
||||
},
|
||||
"if a raw request fails then error": {
|
||||
client: vaultfake.NewFakeClient().WithRawRequest(nil, errors.New("request failed")),
|
||||
|
||||
Reference in New Issue
Block a user