Use linkedca GetAdmin and GetProvisioner.

This commit is contained in:
Mariano Cano 2021-08-02 14:45:59 -07:00
parent 91a369f618
commit b0e0f2b89d

View file

@ -15,7 +15,6 @@ import (
"time" "time"
"github.com/pkg/errors" "github.com/pkg/errors"
"github.com/smallstep/certificates/errs"
"go.step.sm/crypto/jose" "go.step.sm/crypto/jose"
"go.step.sm/crypto/keyutil" "go.step.sm/crypto/keyutil"
"go.step.sm/crypto/tlsutil" "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) { func (c *linkedCaClient) GetProvisioner(ctx context.Context, id string) (*linkedca.Provisioner, error) {
resp, err := c.client.GetConfiguration(ctx, &linkedca.ConfigurationRequest{ resp, err := c.client.GetProvisioner(ctx, &linkedca.GetProvisionerRequest{
AuthorityId: c.authorityID, Id: id,
}) })
if err != nil { if err != nil {
return nil, errors.Wrap(err, "error getting provisioners") return nil, errors.Wrap(err, "error getting provisioners")
} }
for _, p := range resp.Provisioners { return resp, nil
if p.Id == id {
return p, nil
}
}
return nil, errs.NotFound("provisioner not found")
} }
func (c *linkedCaClient) GetProvisioners(ctx context.Context) ([]*linkedca.Provisioner, error) { 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) { func (c *linkedCaClient) GetAdmin(ctx context.Context, id string) (*linkedca.Admin, error) {
resp, err := c.client.GetConfiguration(ctx, &linkedca.ConfigurationRequest{ resp, err := c.client.GetAdmin(ctx, &linkedca.GetAdminRequest{
AuthorityId: c.authorityID, Id: id,
}) })
if err != nil { if err != nil {
return nil, errors.Wrap(err, "error getting admins") return nil, errors.Wrap(err, "error getting admins")
} }
for _, a := range resp.Admins { return resp, nil
if a.Id == id {
return a, nil
}
}
return nil, errs.NotFound("admin not found")
} }
func (c *linkedCaClient) GetAdmins(ctx context.Context) ([]*linkedca.Admin, error) { func (c *linkedCaClient) GetAdmins(ctx context.Context) ([]*linkedca.Admin, error) {