Skip to content

Commit

Permalink
fix: use public instead of common sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik committed Sep 30, 2020
1 parent e0a256d commit dcb4a36
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
5 changes: 3 additions & 2 deletions cmd/identities/helpers.go
Expand Up @@ -4,12 +4,13 @@ import (
"bytes"
"context"
"fmt"
"github.com/pkg/errors"
"github.com/tidwall/gjson"
"io"
"io/ioutil"
"testing"

"github.com/pkg/errors"
"github.com/tidwall/gjson"

"github.com/ory/kratos/identity"

"github.com/spf13/cobra"
Expand Down
3 changes: 2 additions & 1 deletion cmd/identities/import.go
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"

"github.com/spf13/cobra"

"github.com/ory/kratos/internal/clihelpers"
Expand Down Expand Up @@ -38,7 +39,7 @@ WARNING: Importing credentials is not yet supported.`,
}

for src, i := range is {
err = validateIdentity(cmd, src, i, c.Common.GetSchema)
err = validateIdentity(cmd, src, i, c.Public.GetSchema)
if err != nil {
return err
}
Expand Down
10 changes: 6 additions & 4 deletions cmd/identities/validate.go
Expand Up @@ -5,16 +5,18 @@ import (
"context"
"encoding/json"
"fmt"

"github.com/markbates/pkger"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/tidwall/gjson"

"github.com/ory/kratos/internal/httpclient/client/public"

"github.com/ory/kratos/internal/clihelpers"

"github.com/ory/jsonschema/v3"
"github.com/ory/kratos/cmd/cliclient"
"github.com/ory/kratos/internal/httpclient/client/common"
"github.com/ory/x/viperx"
)

Expand All @@ -34,7 +36,7 @@ Identities can be supplied via STD_IN or JSON files containing a single or an ar
}

for src, i := range is {
err = validateIdentity(cmd, src, i, c.Common.GetSchema)
err = validateIdentity(cmd, src, i, c.Public.GetSchema)
if err != nil {
return err
}
Expand All @@ -49,7 +51,7 @@ var schemas = make(map[string]*jsonschema.Schema)

const createIdentityPath = "api.swagger.json#/definitions/CreateIdentity"

type schemaGetter = func(params *common.GetSchemaParams) (*common.GetSchemaOK, error)
type schemaGetter = func(params *public.GetSchemaParams) (*public.GetSchemaOK, error)

// validateIdentity validates the json payload fc against
// 1. the swagger payload definition and
Expand Down Expand Up @@ -99,7 +101,7 @@ func validateIdentity(cmd *cobra.Command, src, i string, getRemoteSchema schemaG
customSchema, ok := schemas[sid.String()]
if !ok {
// get custom identity schema
ts, err := getRemoteSchema(&common.GetSchemaParams{ID: sid.String(), Context: context.Background()})
ts, err := getRemoteSchema(&public.GetSchemaParams{ID: sid.String(), Context: context.Background()})
if err != nil {
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "%s: Could not fetch schema with ID \"%s\": %s\n", src, sid.String(), err)
return clihelpers.FailSilently(cmd)
Expand Down
8 changes: 4 additions & 4 deletions cmd/identities/validate_test.go
Expand Up @@ -5,10 +5,10 @@ import (
"fmt"
"testing"

"github.com/ory/kratos/internal/httpclient/client/public"

"github.com/spf13/cobra"
"github.com/stretchr/testify/assert"

"github.com/ory/kratos/internal/httpclient/client/common"
)

func TestValidateIdentity(t *testing.T) {
Expand All @@ -20,8 +20,8 @@ func TestValidateIdentity(t *testing.T) {
return cmd, out, err
}
var testSchemaGetter = func(resp interface{}) schemaGetter {
return func(_ *common.GetSchemaParams) (*common.GetSchemaOK, error) {
return &common.GetSchemaOK{Payload: resp}, nil
return func(_ *public.GetSchemaParams) (*public.GetSchemaOK, error) {
return &public.GetSchemaOK{Payload: resp}, nil
}
}

Expand Down

0 comments on commit dcb4a36

Please sign in to comment.