Fix govet warnings
Signed-off-by: James Munnelly <james@munnelly.eu>
This commit is contained in:
parent
7c54cb8dda
commit
f466aeea88
@ -85,7 +85,7 @@ func runfilewatch(filename string) {
|
||||
// let the k8s scheduler restart us
|
||||
// TODO(dmo): figure out if there's a way to do this with clean
|
||||
// shutdown
|
||||
klog.Info("Detected change in TLS certificate %s. Restarting to pick up new certificate", filename)
|
||||
klog.Infof("Detected change in TLS certificate %s. Restarting to pick up new certificate", filename)
|
||||
os.Exit(0)
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ type ACMEChallenge struct {
|
||||
|
||||
// Token is the token that must be presented for this challenge.
|
||||
// This is used to compute the 'key' that must also be presented.
|
||||
Token string `json:"token""`
|
||||
Token string `json:"token"`
|
||||
|
||||
// Type is the type of challenge being offered, e.g. http-01, dns-01
|
||||
Type ACMEChallengeType `json:"type"`
|
||||
|
||||
@ -182,7 +182,7 @@ func TestSign(t *testing.T) {
|
||||
TokenSecretRef: &cmmeta.SecretKeySelector{
|
||||
Key: "secret-key",
|
||||
LocalObjectReference: cmmeta.LocalObjectReference{
|
||||
"non-existing-secret",
|
||||
Name: "non-existing-secret",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -220,7 +220,7 @@ func TestSign(t *testing.T) {
|
||||
SecretRef: cmmeta.SecretKeySelector{
|
||||
Key: "secret-key",
|
||||
LocalObjectReference: cmmeta.LocalObjectReference{
|
||||
"non-existing-secret",
|
||||
Name: "non-existing-secret",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -257,7 +257,7 @@ func TestSign(t *testing.T) {
|
||||
TokenSecretRef: &cmmeta.SecretKeySelector{
|
||||
Key: "my-token-key",
|
||||
LocalObjectReference: cmmeta.LocalObjectReference{
|
||||
"token-secret",
|
||||
Name: "token-secret",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -296,7 +296,7 @@ func TestSign(t *testing.T) {
|
||||
RoleId: "my-role-id",
|
||||
SecretRef: cmmeta.SecretKeySelector{
|
||||
LocalObjectReference: cmmeta.LocalObjectReference{
|
||||
"role-secret",
|
||||
Name: "role-secret",
|
||||
},
|
||||
Key: "my-role-key",
|
||||
},
|
||||
@ -336,7 +336,7 @@ func TestSign(t *testing.T) {
|
||||
TokenSecretRef: &cmmeta.SecretKeySelector{
|
||||
Key: "my-token-key",
|
||||
LocalObjectReference: cmmeta.LocalObjectReference{
|
||||
"token-secret",
|
||||
Name: "token-secret",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -376,7 +376,7 @@ func TestSign(t *testing.T) {
|
||||
RoleId: "my-role-id",
|
||||
SecretRef: cmmeta.SecretKeySelector{
|
||||
LocalObjectReference: cmmeta.LocalObjectReference{
|
||||
"role-secret",
|
||||
Name: "role-secret",
|
||||
},
|
||||
Key: "my-role-key",
|
||||
},
|
||||
|
||||
@ -46,7 +46,7 @@ func TestCalculateDurationUntilRenew(t *testing.T) {
|
||||
desc: "generate an event if certificate duration is lower than requested duration",
|
||||
notBefore: now(),
|
||||
notAfter: now().Add(time.Hour * 24 * 90),
|
||||
duration: &metav1.Duration{time.Hour * 24 * 120},
|
||||
duration: &metav1.Duration{Duration: time.Hour * 24 * 120},
|
||||
renewBefore: nil,
|
||||
expectedExpiry: time.Hour * 24 * 60,
|
||||
},
|
||||
@ -70,24 +70,24 @@ func TestCalculateDurationUntilRenew(t *testing.T) {
|
||||
desc: "expiry of 2/3 of certificate duration when duration < 30 minutes",
|
||||
notBefore: now(),
|
||||
notAfter: now().Add(time.Hour),
|
||||
duration: &metav1.Duration{time.Hour},
|
||||
renewBefore: &metav1.Duration{time.Hour / 3},
|
||||
duration: &metav1.Duration{Duration: time.Hour},
|
||||
renewBefore: &metav1.Duration{Duration: time.Hour / 3},
|
||||
expectedExpiry: time.Hour * 2 / 3,
|
||||
},
|
||||
{
|
||||
desc: "expiry of 60 days of certificate duration",
|
||||
notBefore: now(),
|
||||
notAfter: now().Add(time.Hour * 24 * 365),
|
||||
duration: &metav1.Duration{time.Hour * 24 * 365},
|
||||
renewBefore: &metav1.Duration{time.Hour * 24 * 60},
|
||||
duration: &metav1.Duration{Duration: time.Hour * 24 * 365},
|
||||
renewBefore: &metav1.Duration{Duration: time.Hour * 24 * 60},
|
||||
expectedExpiry: (time.Hour * 24 * 365) - (time.Hour * 24 * 60),
|
||||
},
|
||||
{
|
||||
desc: "expiry of 2/3 of certificate duration when renewBefore greater than certificate duration",
|
||||
notBefore: now(),
|
||||
notAfter: now().Add(time.Hour * 24 * 35),
|
||||
duration: &metav1.Duration{time.Hour * 24 * 35},
|
||||
renewBefore: &metav1.Duration{time.Hour * 24 * 40},
|
||||
duration: &metav1.Duration{Duration: time.Hour * 24 * 35},
|
||||
renewBefore: &metav1.Duration{Duration: time.Hour * 24 * 40},
|
||||
expectedExpiry: time.Hour * 24 * 35 * 2 / 3,
|
||||
},
|
||||
{
|
||||
@ -96,7 +96,7 @@ func TestCalculateDurationUntilRenew(t *testing.T) {
|
||||
notBefore: now().Add(-time.Hour),
|
||||
notAfter: now().Add(-time.Hour).Add(time.Hour * 24 * 90),
|
||||
duration: nil,
|
||||
renewBefore: &metav1.Duration{time.Hour*2159 + time.Minute*50},
|
||||
renewBefore: &metav1.Duration{Duration: time.Hour*2159 + time.Minute*50},
|
||||
expectedExpiry: -time.Minute * 50,
|
||||
},
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@ type ACMEChallenge struct {
|
||||
|
||||
// Token is the token that must be presented for this challenge.
|
||||
// This is used to compute the 'key' that must also be presented.
|
||||
Token string `json:"token""`
|
||||
Token string `json:"token"`
|
||||
|
||||
// Type is the type of challenge being offered, e.g. http-01, dns-01
|
||||
Type ACMEChallengeType `json:"type"`
|
||||
|
||||
@ -273,8 +273,7 @@ func (v *Vault) requestTokenWithAppRoleRef(client Client, appRole *v1alpha2.Vaul
|
||||
defer resp.Body.Close()
|
||||
|
||||
vaultResult := vault.Secret{}
|
||||
resp.DecodeJSON(&vaultResult)
|
||||
if err != nil {
|
||||
if err := resp.DecodeJSON(&vaultResult); err != nil {
|
||||
return "", fmt.Errorf("unable to decode JSON payload: %s", err.Error())
|
||||
}
|
||||
|
||||
|
||||
@ -29,7 +29,6 @@ import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
@ -168,7 +167,9 @@ func TestSign(t *testing.T) {
|
||||
}
|
||||
|
||||
cert, _, err := v.Sign(test.csrPEM, time.Minute)
|
||||
if !reflect.DeepEqual(test.expectedErr, err) {
|
||||
if ((test.expectedErr == nil) != (err == nil)) &&
|
||||
test.expectedErr != nil &&
|
||||
test.expectedErr.Error() != err.Error() {
|
||||
t.Errorf("%s: unexpected error, exp=%v got=%v",
|
||||
name, test.expectedErr, err)
|
||||
}
|
||||
@ -471,7 +472,9 @@ func TestSetToken(t *testing.T) {
|
||||
}
|
||||
|
||||
err := v.setToken(test.fakeClient)
|
||||
if !reflect.DeepEqual(test.expectedErr, err) {
|
||||
if ((test.expectedErr == nil) != (err == nil)) &&
|
||||
test.expectedErr != nil &&
|
||||
test.expectedErr.Error() != err.Error() {
|
||||
t.Errorf("unexpected error, exp=%v got=%v",
|
||||
test.expectedErr, err)
|
||||
}
|
||||
@ -569,7 +572,9 @@ func TestAppRoleRef(t *testing.T) {
|
||||
}
|
||||
|
||||
roleID, secretID, err := v.appRoleRef(test.appRole)
|
||||
if !reflect.DeepEqual(test.expectedErr, err) {
|
||||
if ((test.expectedErr == nil) != (err == nil)) &&
|
||||
test.expectedErr != nil &&
|
||||
test.expectedErr.Error() != err.Error() {
|
||||
t.Errorf("unexpected error, exp=%v got=%v",
|
||||
test.expectedErr, err)
|
||||
}
|
||||
@ -665,7 +670,9 @@ func TestTokenRef(t *testing.T) {
|
||||
}
|
||||
|
||||
token, err := v.tokenRef("test-name", "test-namespace", test.key)
|
||||
if !reflect.DeepEqual(test.expectedErr, err) {
|
||||
if ((test.expectedErr == nil) != (err == nil)) &&
|
||||
test.expectedErr != nil &&
|
||||
test.expectedErr.Error() != err.Error() {
|
||||
t.Errorf("unexpected error, exp=%v got=%v",
|
||||
test.expectedErr, err)
|
||||
}
|
||||
@ -741,7 +748,9 @@ func TestNewConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
cfg, err := v.newConfig()
|
||||
if !reflect.DeepEqual(test.expectedErr, err) {
|
||||
if ((test.expectedErr == nil) != (err == nil)) &&
|
||||
test.expectedErr != nil &&
|
||||
test.expectedErr.Error() != err.Error() {
|
||||
t.Errorf("unexpected error, exp=%v got=%v",
|
||||
test.expectedErr, err)
|
||||
}
|
||||
@ -866,7 +875,9 @@ func TestRequestTokenWithAppRoleRef(t *testing.T) {
|
||||
}
|
||||
|
||||
token, err := v.requestTokenWithAppRoleRef(test.client, test.appRole)
|
||||
if !reflect.DeepEqual(test.expectedErr, err) {
|
||||
if ((test.expectedErr == nil) != (err == nil)) &&
|
||||
test.expectedErr != nil &&
|
||||
test.expectedErr.Error() != err.Error() {
|
||||
t.Errorf("unexpected error, exp=%v got=%v",
|
||||
test.expectedErr, err)
|
||||
}
|
||||
|
||||
@ -388,7 +388,7 @@ func TestRoute53AmbientCreds(t *testing.T) {
|
||||
defer f.Finish(t)
|
||||
s := f.Solver
|
||||
_, _, err := s.solverForChallenge(context.Background(), f.Issuer, f.Challenge)
|
||||
if !reflect.DeepEqual(tt.out.expectedErr, err) {
|
||||
if tt.out.expectedErr != err {
|
||||
t.Fatalf("expected error %v, got error %v", tt.out.expectedErr, err)
|
||||
}
|
||||
|
||||
@ -480,7 +480,7 @@ func TestRoute53AssumeRole(t *testing.T) {
|
||||
defer f.Finish(t)
|
||||
s := f.Solver
|
||||
_, _, err := s.solverForChallenge(context.Background(), f.Issuer, f.Challenge)
|
||||
if !reflect.DeepEqual(tt.out.expectedErr, err) {
|
||||
if tt.out.expectedErr != err {
|
||||
t.Fatalf("expected error %v, got error %v", tt.out.expectedErr, err)
|
||||
}
|
||||
|
||||
|
||||
@ -72,7 +72,6 @@ var _ = framework.CertManagerDescribe("ACME Certificate (HTTP01)", func() {
|
||||
f.RequireAddon(pebble)
|
||||
|
||||
var acmeIngressDomain string
|
||||
var acmeIngressClass string
|
||||
issuerName := "test-acme-issuer"
|
||||
certificateName := "test-acme-certificate"
|
||||
certificateSecretName := "test-acme-certificate"
|
||||
@ -136,7 +135,6 @@ var _ = framework.CertManagerDescribe("ACME Certificate (HTTP01)", func() {
|
||||
|
||||
JustBeforeEach(func() {
|
||||
acmeIngressDomain = addon.NginxIngress.Details().NewTestDomain()
|
||||
acmeIngressClass = addon.NginxIngress.Details().IngressClass
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
|
||||
@ -66,7 +66,6 @@ var _ = framework.CertManagerDescribe("ACME CertificateRequest (HTTP01)", func()
|
||||
f.RequireAddon(pebble)
|
||||
|
||||
var acmeIngressDomain string
|
||||
var acmeIngressClass string
|
||||
issuerName := "test-acme-issuer"
|
||||
certificateRequestName := "test-acme-certificate-request"
|
||||
// fixedIngressName is the name of an ingress resource that is configured
|
||||
@ -129,7 +128,6 @@ var _ = framework.CertManagerDescribe("ACME CertificateRequest (HTTP01)", func()
|
||||
|
||||
JustBeforeEach(func() {
|
||||
acmeIngressDomain = addon.NginxIngress.Details().NewTestDomain()
|
||||
acmeIngressClass = addon.NginxIngress.Details().IngressClass
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
|
||||
@ -100,7 +100,7 @@ var _ = framework.CertManagerDescribe("CA Certificate", func() {
|
||||
label string
|
||||
}{
|
||||
{
|
||||
inputDuration: &metav1.Duration{time.Hour * 24 * 35},
|
||||
inputDuration: &metav1.Duration{Duration: time.Hour * 24 * 35},
|
||||
inputRenewBefore: nil,
|
||||
expectedDuration: time.Hour * 24 * 35,
|
||||
label: "35 days",
|
||||
|
||||
@ -122,7 +122,7 @@ var _ = framework.CertManagerDescribe("CA CertificateRequest", func() {
|
||||
label string
|
||||
}{
|
||||
{
|
||||
inputDuration: &metav1.Duration{time.Hour * 24 * 35},
|
||||
inputDuration: &metav1.Duration{Duration: time.Hour * 24 * 35},
|
||||
expectedDuration: time.Hour * 24 * 35,
|
||||
label: "35 days",
|
||||
},
|
||||
|
||||
@ -67,7 +67,7 @@ var _ = framework.CertManagerDescribe("Self Signed Certificate", func() {
|
||||
label string
|
||||
}{
|
||||
{
|
||||
inputDuration: &metav1.Duration{time.Hour * 24 * 35},
|
||||
inputDuration: &metav1.Duration{Duration: time.Hour * 24 * 35},
|
||||
inputRenewBefore: nil,
|
||||
expectedDuration: time.Hour * 24 * 35,
|
||||
label: "35 days",
|
||||
|
||||
@ -127,7 +127,7 @@ var _ = framework.CertManagerDescribe("SelfSigned CertificateRequest", func() {
|
||||
label string
|
||||
}{
|
||||
{
|
||||
inputDuration: &metav1.Duration{time.Hour * 24 * 35},
|
||||
inputDuration: &metav1.Duration{Duration: time.Hour * 24 * 35},
|
||||
expectedDuration: time.Hour * 24 * 35,
|
||||
label: "35 days",
|
||||
},
|
||||
|
||||
@ -129,7 +129,7 @@ var _ = framework.CertManagerDescribe("Vault Certificate (AppRole)", func() {
|
||||
event string
|
||||
}{
|
||||
{
|
||||
inputDuration: &metav1.Duration{time.Hour * 24 * 35},
|
||||
inputDuration: &metav1.Duration{Duration: time.Hour * 24 * 35},
|
||||
inputRenewBefore: nil,
|
||||
expectedDuration: time.Hour * 24 * 35,
|
||||
label: "valid for 35 days",
|
||||
@ -141,14 +141,14 @@ var _ = framework.CertManagerDescribe("Vault Certificate (AppRole)", func() {
|
||||
label: "valid for the default value (90 days)",
|
||||
},
|
||||
{
|
||||
inputDuration: &metav1.Duration{time.Hour * 24 * 365},
|
||||
inputDuration: &metav1.Duration{Duration: time.Hour * 24 * 365},
|
||||
inputRenewBefore: nil,
|
||||
expectedDuration: time.Hour * 24 * 90,
|
||||
label: "with Vault configured maximum TTL duration (90 days) when requested duration is greater than TTL",
|
||||
},
|
||||
{
|
||||
inputDuration: &metav1.Duration{time.Hour * 24 * 240},
|
||||
inputRenewBefore: &metav1.Duration{time.Hour * 24 * 120},
|
||||
inputDuration: &metav1.Duration{Duration: time.Hour * 24 * 240},
|
||||
inputRenewBefore: &metav1.Duration{Duration: time.Hour * 24 * 120},
|
||||
expectedDuration: time.Hour * 24 * 90,
|
||||
label: "with a warning event when renewBefore is bigger than the duration",
|
||||
},
|
||||
|
||||
@ -141,7 +141,7 @@ var _ = framework.CertManagerDescribe("Vault CertificateRequest (AppRole)", func
|
||||
event string
|
||||
}{
|
||||
{
|
||||
inputDuration: &metav1.Duration{time.Hour * 24 * 35},
|
||||
inputDuration: &metav1.Duration{Duration: time.Hour * 24 * 35},
|
||||
expectedDuration: time.Hour * 24 * 35,
|
||||
label: "valid for 35 days",
|
||||
},
|
||||
@ -151,12 +151,12 @@ var _ = framework.CertManagerDescribe("Vault CertificateRequest (AppRole)", func
|
||||
label: "valid for the default value (90 days)",
|
||||
},
|
||||
{
|
||||
inputDuration: &metav1.Duration{time.Hour * 24 * 365},
|
||||
inputDuration: &metav1.Duration{Duration: time.Hour * 24 * 365},
|
||||
expectedDuration: time.Hour * 24 * 90,
|
||||
label: "with Vault configured maximum TTL duration (90 days) when requested duration is greater than TTL",
|
||||
},
|
||||
{
|
||||
inputDuration: &metav1.Duration{time.Hour * 24 * 240},
|
||||
inputDuration: &metav1.Duration{Duration: time.Hour * 24 * 240},
|
||||
expectedDuration: time.Hour * 24 * 90,
|
||||
label: "with a warning event when renewBefore is bigger than the duration",
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user