mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-27 01:32:15 +00:00
feat: Instance create (#4502)
* feat(instance): implement create instance with direct machine user and credentials * fix: deprecated add endpoint and variable declaration * fix(instance): update logic for pats and machinekeys * fix(instance): unit test corrections and additional unit test for pats and machinekeys * fix(instance-create): include review changes * fix(instance-create): linter fixes * move iframe usage to solution scenarios configurations * Revert "move iframe usage to solution scenarios configurations" This reverts commit 9db31f3808e6dfcae9907bc574c072436a19865a. * fix merge * fix: add review suggestions Co-authored-by: Livio Spring <[email protected]> * fix: add review changes * fix: add review changes for default definitions * fix: add review changes for machinekey details * fix: add machinekey output when setup with machineuser * fix: add changes from review * fix instance converter for machine and allow overwriting of further machine fields Co-authored-by: Livio Spring <[email protected]>
This commit is contained in:
co-authored by
Livio Spring
parent
c5ebeea590
commit
47ffa52f0f
+21
-1
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/text/language"
|
||||
@@ -21,6 +22,7 @@ type FirstInstance struct {
|
||||
InstanceName string
|
||||
DefaultLanguage language.Tag
|
||||
Org command.OrgSetup
|
||||
MachineKeyPath string
|
||||
|
||||
instanceSetup command.InstanceSetup
|
||||
userEncryptionKey *crypto.KeyConfig
|
||||
@@ -97,7 +99,25 @@ func (mig *FirstInstance) Execute(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
|
||||
_, _, err = cmd.SetUpInstance(ctx, &mig.instanceSetup)
|
||||
_, _, key, _, err := cmd.SetUpInstance(ctx, &mig.instanceSetup)
|
||||
if key == nil {
|
||||
return err
|
||||
}
|
||||
|
||||
f := os.Stdout
|
||||
if mig.MachineKeyPath != "" {
|
||||
f, err = os.OpenFile(mig.MachineKeyPath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
keyDetails, err := key.Detail()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = fmt.Fprintln(f, string(keyDetails))
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package setup
|
||||
import (
|
||||
"bytes"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/spf13/viper"
|
||||
@@ -39,6 +40,7 @@ func MustNewConfig(v *viper.Viper) *Config {
|
||||
hook.Base64ToBytesHookFunc(),
|
||||
hook.TagToLanguageHookFunc(),
|
||||
mapstructure.StringToTimeDurationHookFunc(),
|
||||
mapstructure.StringToTimeHookFunc(time.RFC3339),
|
||||
mapstructure.StringToSliceHookFunc(","),
|
||||
database.DecodeHook,
|
||||
)),
|
||||
@@ -87,6 +89,7 @@ func MustNewSteps(v *viper.Viper) *Steps {
|
||||
hook.Base64ToBytesHookFunc(),
|
||||
hook.TagToLanguageHookFunc(),
|
||||
mapstructure.StringToTimeDurationHookFunc(),
|
||||
mapstructure.StringToTimeHookFunc(time.RFC3339),
|
||||
mapstructure.StringToSliceHookFunc(","),
|
||||
)),
|
||||
)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
FirstInstance:
|
||||
MachineKeyPath:
|
||||
InstanceName: ZITADEL
|
||||
DefaultLanguage: en
|
||||
Org:
|
||||
@@ -22,3 +23,10 @@ FirstInstance:
|
||||
Verified:
|
||||
Password: Password1!
|
||||
PasswordChangeRequired: true
|
||||
Machine:
|
||||
Machine:
|
||||
Username:
|
||||
Name:
|
||||
MachineKey:
|
||||
ExpirationDate:
|
||||
Type:
|
||||
|
||||
Reference in New Issue
Block a user