snapshot of https://github.com/ory/kratos.git (master, 2026-09-15; blobs > 131072B omitted)
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
Some checks failed
CI / Run tests and lints (push) Failing after 29s
CI / Build CLI docs (push) Has been skipped
CI / Run Playwright end-to-end tests (mysql) (push) Failing after 3s
CI / Run Playwright end-to-end tests (postgres) (push) Failing after 2s
CI / Run Playwright end-to-end tests (sqlite) (push) Failing after 3s
CodeQL / Analyze (go) (push) Failing after 4s
CodeQL / Analyze (javascript) (push) Failing after 3s
Docker Image Scanners / scanners (push) Failing after 4s
Synchronize Issue Labels / Synchronize Issue Labels (push) Has been skipped
CI / Run end-to-end tests (postgres) (push) Failing after 19s
CI / Run end-to-end tests (sqlite) (push) Failing after 2s
CI / Run Playwright end-to-end tests (cockroach) (push) Failing after 2s
CI / Draft newsletter (push) Has been skipped
CI / Generate release (push) Has been skipped
CI / Pending approval Slack notification (push) Has been skipped
CI / Send newsletter (push) Has been skipped
This commit is contained in:
53
cmd/identities/helpers.go
Normal file
53
cmd/identities/helpers.go
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright © 2023 Ory Corp
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
package identities
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
"github.com/ory/x/cmdx"
|
||||
)
|
||||
|
||||
func parseIdentities(raw []byte) (rawIdentities []string) {
|
||||
res := gjson.ParseBytes(raw)
|
||||
if !res.IsArray() {
|
||||
return []string{res.Raw}
|
||||
}
|
||||
res.ForEach(func(_, v gjson.Result) bool {
|
||||
rawIdentities = append(rawIdentities, v.Raw)
|
||||
return true
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func readIdentities(cmd *cobra.Command, args []string) (map[string]string, error) {
|
||||
rawIdentities := make(map[string]string)
|
||||
if len(args) == 0 {
|
||||
fc, err := io.ReadAll(cmd.InOrStdin())
|
||||
if err != nil {
|
||||
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "STD_IN: Could not read: %s\n", err)
|
||||
return nil, cmdx.FailSilently(cmd)
|
||||
}
|
||||
for i, id := range parseIdentities(fc) {
|
||||
rawIdentities[fmt.Sprintf("STD_IN[%d]", i)] = id
|
||||
}
|
||||
return rawIdentities, nil
|
||||
}
|
||||
for _, fn := range args {
|
||||
fc, err := os.ReadFile(fn) // #nosec G304 -- file is supplied by user
|
||||
if err != nil {
|
||||
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), "%s: Could not open identity file: %s\n", fn, err)
|
||||
return nil, cmdx.FailSilently(cmd)
|
||||
}
|
||||
for i, id := range parseIdentities(fc) {
|
||||
rawIdentities[fmt.Sprintf("%s[%d]", fn, i)] = id
|
||||
}
|
||||
}
|
||||
return rawIdentities, nil
|
||||
}
|
||||
Reference in New Issue
Block a user