From b0e0f2b89d8d9c14f582b6d40ad0620c943b0902 Mon Sep 17 00:00:00 2001 From: Mariano Cano Date: Mon, 2 Aug 2021 14:45:59 -0700 Subject: [PATCH] Use linkedca GetAdmin and GetProvisioner. --- authority/linkedca.go | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/authority/linkedca.go b/authority/linkedca.go index 75bc6e1a..e0678aca 100644 --- a/authority/linkedca.go +++ b/authority/linkedca.go @@ -15,7 +15,6 @@ import ( "time" "github.com/pkg/errors" - "github.com/smallstep/certificates/errs" "go.step.sm/crypto/jose" "go.step.sm/crypto/keyutil" "go.step.sm/crypto/tlsutil" @@ -141,18 +140,13 @@ func (c *linkedCaClient) CreateProvisioner(ctx context.Context, prov *linkedca.P } func (c *linkedCaClient) GetProvisioner(ctx context.Context, id string) (*linkedca.Provisioner, error) { - resp, err := c.client.GetConfiguration(ctx, &linkedca.ConfigurationRequest{ - AuthorityId: c.authorityID, + resp, err := c.client.GetProvisioner(ctx, &linkedca.GetProvisionerRequest{ + Id: id, }) if err != nil { return nil, errors.Wrap(err, "error getting provisioners") } - for _, p := range resp.Provisioners { - if p.Id == id { - return p, nil - } - } - return nil, errs.NotFound("provisioner not found") + return resp, nil } func (c *linkedCaClient) GetProvisioners(ctx context.Context) ([]*linkedca.Provisioner, error) { @@ -199,18 +193,13 @@ func (c *linkedCaClient) CreateAdmin(ctx context.Context, adm *linkedca.Admin) e } func (c *linkedCaClient) GetAdmin(ctx context.Context, id string) (*linkedca.Admin, error) { - resp, err := c.client.GetConfiguration(ctx, &linkedca.ConfigurationRequest{ - AuthorityId: c.authorityID, + resp, err := c.client.GetAdmin(ctx, &linkedca.GetAdminRequest{ + Id: id, }) if err != nil { return nil, errors.Wrap(err, "error getting admins") } - for _, a := range resp.Admins { - if a.Id == id { - return a, nil - } - } - return nil, errs.NotFound("admin not found") + return resp, nil } func (c *linkedCaClient) GetAdmins(ctx context.Context) ([]*linkedca.Admin, error) {