Skip to content

Commit

Permalink
fix: set timeout from argument (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
livio-a committed Apr 21, 2023
1 parent 3a07a3c commit eacd7be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion cmd/migration/auth0/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"log"
"os"
"time"

"github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
"github.com/spf13/cobra"
Expand All @@ -28,6 +29,7 @@ var (
passwordPath string
outputPath string
organisationID string
timeout time.Duration
verifiedEmails bool
multiLine bool
)
Expand All @@ -37,6 +39,7 @@ func init() {
Cmd.Flags().StringVar(&passwordPath, "passwords", "./passwords.json", "path to the passwords.json")
Cmd.Flags().StringVar(&outputPath, "output", "./importBody.json", "path where the generated json will be saved")
Cmd.Flags().StringVar(&organisationID, "org", "", "id of the ZITADEL organisation, where the users will be imported")
Cmd.Flags().DurationVar(&timeout, "timeout", 30*time.Minute, "maximum duration to be used for the import")
Cmd.Flags().BoolVar(&verifiedEmails, "email-verified", true, "specify if imported emails are automatically verified (default)")
Cmd.Flags().BoolVar(&multiLine, "multiline", false, "print the JSON output in multiple lines")
}
Expand Down Expand Up @@ -136,7 +139,7 @@ func CreateZITADELMigration(orgID string, users []User, passwords []Password) *a
Orgs: createOrgs(orgID, users, passwords),
}
importData := &admin.ImportDataRequest{
Timeout: "30m",
Timeout: timeout.String(),
Data: &admin.ImportDataRequest_DataOrgs{
DataOrgs: importDataOrg,
},
Expand Down
10 changes: 7 additions & 3 deletions cmd/migration/auth0/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ With this example an organization in ZITADEL has to be existing and only the use
The migration requires the following input:
- organisation id (--org)
- users.json file with your exported Auth0 users (--users; default is ./users.json)
- password.json file with the exported Auth0 bcrypt passwords (--password; default is ./passwords.json)
- password.json file with the exported Auth0 bcrypt passwords (--passwords; default is ./passwords.json)

Execute the transformation and provide at least the organisation id:
```bash
./zitadel-tools migrate auth0 --org=<organisation id>
```

you can also specify custom path for the users, passwords and output JSON files:
You can specify additional parameters:
- output path (--output; default is ./importBody.json)
- timeout for the import data request (--timeout; default is 30m)
- pretty print the output JSON (--multiline)

```bash
./zitadel-tools migrate auth0 --org=<organisation id> --users=./users.json --password=./passwords.json --output=./importBody.json
./zitadel-tools migrate auth0 --org=<organisation id> --users=./users.json --passwords=./passwords.json --output=./importBody.json --timeout=1h --multiline
```

You will now get a new file importBody.json
Expand Down

0 comments on commit eacd7be

Please sign in to comment.