Skip to content

Commit

Permalink
Run gofumports on source
Browse files Browse the repository at this point in the history
  • Loading branch information
johanbrandhorst committed Dec 26, 2019
1 parent 60e3475 commit 5d940d8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
2 changes: 2 additions & 0 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,11 @@ type noopCache struct{}
func (*noopCache) Get(context.Context, string) (*tls.Certificate, error) {
return nil, ErrCacheMiss
}

func (*noopCache) Put(context.Context, string, *tls.Certificate) error {
return nil
}

func (*noopCache) Delete(context.Context, string) error {
return nil
}
8 changes: 4 additions & 4 deletions issuers/vault/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type RenewingToken struct {
token string
tokenMu sync.Mutex
errC chan error
cancel func()
cancel func()
}

// SetToken implements AuthMethod for RenewingToken.
Expand All @@ -71,7 +71,7 @@ func (r *RenewingToken) SetToken(ctx context.Context, cli *api.Client) error {
return
}
defer resp.Body.Close()

tok, tErr := api.ParseSecret(resp.Body)
if tErr != nil {
err = tErr
Expand Down Expand Up @@ -118,7 +118,7 @@ func (r *RenewingToken) SetToken(ctx context.Context, cli *api.Client) error {

// Needs renewal
req := cli.NewRequest("PUT", "/v1/auth/token/renew-self")

body := map[string]interface{}{"increment": r.TimeToLive.Seconds()}
if err := req.SetJSONBody(body); err != nil {
r.errC <- err
Expand All @@ -130,7 +130,7 @@ func (r *RenewingToken) SetToken(ctx context.Context, cli *api.Client) error {
return
}
defer resp.Body.Close()

tok, tErr := api.ParseSecret(resp.Body)
if tErr != nil {
r.errC <- err
Expand Down
4 changes: 2 additions & 2 deletions issuers/vault/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ type Issuer struct {
// the token already defined in the client for authentication.
func FromClient(v *api.Client, role string) *Issuer {
return &Issuer{
Role: role,
Role: role,
AuthMethod: ConstantToken(v.Token()),
cli: v,
cli: v,
}
}

Expand Down
32 changes: 16 additions & 16 deletions issuers/vault/vault_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ var _ = Describe("Vault Issuer", func() {

BeforeEach(func() {
iss = &vault.Issuer{
URL: vaultTLSConf.URL,
URL: vaultTLSConf.URL,
AuthMethod: vault.ConstantToken(vaultTLSConf.Token),
Role: vaultTLSConf.Role,
Role: vaultTLSConf.Role,
TLSConfig: &tls.Config{
RootCAs: vaultTLSConf.CertPool,
},
Expand Down Expand Up @@ -109,19 +109,19 @@ var _ = Describe("Vault Issuer", func() {
Context("with no explicit AuthMethod set", func() {
It("still works", func() {
cn := "somename.com"

tlsCert, err := iss.Issue(context.Background(), cn, conf)
Expect(err).NotTo(HaveOccurred())

Expect(tlsCert.Leaf).NotTo(BeNil(), "tlsCert.Leaf should be populated by Issue to track expiry")
Expect(tlsCert.Leaf.Subject.CommonName).To(Equal(cn))

// Check that chain is included
Expect(tlsCert.Certificate).To(HaveLen(2))
caCert, err := x509.ParseCertificate(tlsCert.Certificate[1])
Expect(err).NotTo(HaveOccurred())
Expect(caCert.Subject.SerialNumber).To(Equal(tlsCert.Leaf.Issuer.SerialNumber))

Expect(tlsCert.Leaf.NotBefore).To(BeTemporally("<", time.Now()))
Expect(tlsCert.Leaf.NotAfter).To(BeTemporally("~", time.Now().Add(iss.(*vault.Issuer).TimeToLive), 5*time.Second))
Expect(getOtherNames(tlsCert.Leaf)).To(ConsistOf(otherName{
Expand All @@ -134,9 +134,9 @@ var _ = Describe("Vault Issuer", func() {
Context("with URI SANs", func() {
BeforeEach(func() {
iss = &vault.Issuer{
URL: vaultTLSConf.URL,
URL: vaultTLSConf.URL,
AuthMethod: vault.ConstantToken(vaultTLSConf.Token),
Role: vaultTLSConf.RoleURISANs,
Role: vaultTLSConf.RoleURISANs,
TLSConfig: &tls.Config{
RootCAs: vaultTLSConf.CertPool,
},
Expand Down Expand Up @@ -172,10 +172,10 @@ var _ = Describe("Vault Issuer", func() {
Context("with a non-standard mount point", func() {
BeforeEach(func() {
iss = &vault.Issuer{
URL: vaultTLSConf.URL,
URL: vaultTLSConf.URL,
AuthMethod: vault.ConstantToken(vaultTLSConf.Token),
Mount: altMount,
Role: vaultTLSConf.Role,
Mount: altMount,
Role: vaultTLSConf.Role,
TLSConfig: &tls.Config{
RootCAs: vaultTLSConf.CertPool,
},
Expand Down Expand Up @@ -485,9 +485,9 @@ var _ = Describe("When using RenewingToken", func() {
}()

iss := &vault.Issuer{
URL: vaultTLSConf.URL,
URL: vaultTLSConf.URL,
AuthMethod: rt,
Role: vaultTLSConf.Role,
Role: vaultTLSConf.Role,
TLSConfig: &tls.Config{
RootCAs: vaultTLSConf.CertPool,
},
Expand All @@ -503,7 +503,7 @@ var _ = Describe("When using RenewingToken", func() {
_, err = iss.Issue(context.Background(), cn, conf)
Expect(err).To(Succeed())

time.Sleep(2*time.Second) // Should cause token to be renewed in the background.
time.Sleep(2 * time.Second) // Should cause token to be renewed in the background.

_, err = iss.Issue(context.Background(), cn, conf)
Expect(err).To(Succeed())
Expand Down Expand Up @@ -554,9 +554,9 @@ var _ = Describe("gRPC Test", func() {
cb = &certify.Certify{
CommonName: "Certify",
Issuer: &vault.Issuer{
URL: vaultTLSConf.URL,
URL: vaultTLSConf.URL,
AuthMethod: vault.ConstantToken(vaultTLSConf.Token),
Role: vaultTLSConf.Role,
Role: vaultTLSConf.Role,
TLSConfig: &tls.Config{
RootCAs: vaultTLSConf.CertPool,
},
Expand Down

0 comments on commit 5d940d8

Please sign in to comment.