fix: enable env vars in setup steps (and deprecate admin subcommand) (#3871)

* fix: enable env vars in setup steps (and deprecate admin subcommand)

* fix tests and error text
This commit is contained in:
Livio Spring 2022-06-27 12:32:34 +02:00 committed by GitHub
parent 30f553dea1
commit 12d4d3ea0b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 44 additions and 31 deletions

View File

@ -6,10 +6,10 @@ import (
"github.com/spf13/cobra"
"github.com/zitadel/zitadel/cmd/admin/initialise"
"github.com/zitadel/zitadel/cmd/admin/key"
"github.com/zitadel/zitadel/cmd/admin/setup"
"github.com/zitadel/zitadel/cmd/admin/start"
"github.com/zitadel/zitadel/cmd/initialise"
"github.com/zitadel/zitadel/cmd/key"
"github.com/zitadel/zitadel/cmd/setup"
"github.com/zitadel/zitadel/cmd/start"
)
func New() *cobra.Command {
@ -17,6 +17,7 @@ func New() *cobra.Command {
Use: "admin",
Short: "The ZITADEL admin CLI lets you interact with your instance",
Long: `The ZITADEL admin CLI lets you interact with your instance`,
Deprecated: "please use subcommands directly, e.g. `zitadel start`",
RunE: func(cmd *cobra.Command, args []string) error {
return errors.New("no additional command provided")
},

View File

@ -3,6 +3,7 @@ package initialise
import (
"github.com/spf13/viper"
"github.com/zitadel/logging"
"github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/id"
)

View File

@ -58,9 +58,9 @@ type encryptionKeyConfig struct {
}
func MustNewSteps(v *viper.Viper) *Steps {
viper.AutomaticEnv()
viper.SetEnvPrefix("ZITADEL")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
v.AutomaticEnv()
v.SetEnvPrefix("ZITADEL")
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
v.SetConfigType("yaml")
err := v.ReadConfig(bytes.NewBuffer(defaultSteps))
logging.OnError(err).Fatal("unable to read setup steps")

View File

@ -8,8 +8,8 @@ import (
"github.com/spf13/viper"
"github.com/zitadel/logging"
"github.com/zitadel/zitadel/cmd/admin/key"
"github.com/zitadel/zitadel/cmd/admin/tls"
"github.com/zitadel/zitadel/cmd/key"
"github.com/zitadel/zitadel/cmd/tls"
"github.com/zitadel/zitadel/internal/database"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/migration"

View File

@ -4,8 +4,8 @@ import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
"github.com/zitadel/zitadel/cmd/admin/key"
"github.com/zitadel/zitadel/cmd/admin/tls"
"github.com/zitadel/zitadel/cmd/key"
"github.com/zitadel/zitadel/cmd/tls"
)
var tlsMode *string

View File

@ -21,8 +21,8 @@ import (
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
"github.com/zitadel/zitadel/cmd/admin/key"
cmd_tls "github.com/zitadel/zitadel/cmd/admin/tls"
"github.com/zitadel/zitadel/cmd/key"
cmd_tls "github.com/zitadel/zitadel/cmd/tls"
admin_es "github.com/zitadel/zitadel/internal/admin/repository/eventsourcing"
"github.com/zitadel/zitadel/internal/api"
"github.com/zitadel/zitadel/internal/api/assets"

View File

@ -5,10 +5,10 @@ import (
"github.com/spf13/viper"
"github.com/zitadel/logging"
"github.com/zitadel/zitadel/cmd/admin/initialise"
"github.com/zitadel/zitadel/cmd/admin/key"
"github.com/zitadel/zitadel/cmd/admin/setup"
"github.com/zitadel/zitadel/cmd/admin/tls"
"github.com/zitadel/zitadel/cmd/initialise"
"github.com/zitadel/zitadel/cmd/key"
"github.com/zitadel/zitadel/cmd/setup"
"github.com/zitadel/zitadel/cmd/tls"
)
func NewStartFromInit() *cobra.Command {

View File

@ -12,6 +12,10 @@ import (
"github.com/zitadel/logging"
"github.com/zitadel/zitadel/cmd/admin"
"github.com/zitadel/zitadel/cmd/initialise"
"github.com/zitadel/zitadel/cmd/key"
"github.com/zitadel/zitadel/cmd/setup"
"github.com/zitadel/zitadel/cmd/start"
)
var (
@ -41,7 +45,14 @@ func New(out io.Writer, in io.Reader, args []string) *cobra.Command {
cobra.OnInitialize(initConfig)
cmd.PersistentFlags().StringArrayVar(&configFiles, "config", nil, "path to config file to overwrite system defaults")
cmd.AddCommand(admin.New())
cmd.AddCommand(
admin.New(), //is now deprecated, remove later on
initialise.New(),
setup.New(),
start.New(),
start.NewStartFromInit(),
key.New(),
)
return cmd
}

View File

@ -5,8 +5,8 @@ services:
restart: always
networks:
- zitadel
image: ghcr.io/zitadel/zitadel:v2.0.0-v2-alpha.32-amd64
command: admin start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled
image: ghcr.io/zitadel/zitadel:v2.0.0-v2-alpha.33-amd64
command: start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled
environment:
- ZITADEL_DATABASE_HOST=db
- ZITADEL_DEFAULTINSTANCE_CUSTOMDOMAIN=localhost

View File

@ -36,5 +36,5 @@ DefaultInstance:
EOF
# Pass multiple config files using the --config argument
zitadel admin start-from-init --config ./zitadel-config.yaml --config ./zitadel-secrets.yaml --masterkey "MasterkeyNeedsToHave32Characters"
zitadel start-from-init --config ./zitadel-config.yaml --config ./zitadel-secrets.yaml --masterkey "MasterkeyNeedsToHave32Characters"
```

View File

@ -21,11 +21,11 @@ export ZITADEL_DEFAULTINSTANCE_CUSTOMDOMAIN=localhost
Download the zitadel binary
```bash
curl -s https://api.github.com/repos/zitadel/zitadel/releases/tags/v2.0.0-v2-alpha.17 | grep "browser_download_url.*zitadel_.*_linux_$(dpkg --print-architecture)" | cut -d '"' -f 4 | sudo wget -i - -O /usr/local/bin/zitadel && sudo chmod +x /usr/local/bin/zitadel && sudo chown $(id -u):$(id -g) /usr/local/bin/zitadel
curl -s https://api.github.com/repos/zitadel/zitadel/releases/tags/v2.0.0-v2-alpha.33 | grep "browser_download_url.*zitadel_.*_linux_$(dpkg --print-architecture)" | cut -d '"' -f 4 | sudo wget -i - -O /usr/local/bin/zitadel && sudo chmod +x /usr/local/bin/zitadel && sudo chown $(id -u):$(id -g) /usr/local/bin/zitadel
```
Run the database and application containers
```bash
zitadel admin start-from-init --tlsMode disabled --masterkey "MasterkeyNeedsToHave32Characters"
zitadel start-from-init --tlsMode disabled --masterkey "MasterkeyNeedsToHave32Characters"
```

View File

@ -30,11 +30,11 @@ brew install zitadel/tap/zitadel
... or download the binary from GitHub
```bash
curl -s https://api.github.com/repos/zitadel/zitadel/releases/tags/v2.0.0-v2-alpha.17 | grep "browser_download_url.*zitadel_.*_darwin_${MY_ARCHITECTURE}" | cut -d '"' -f 4 | sudo wget -i - -O /usr/local/bin/zitadel && sudo chmod +x /usr/local/bin/zitadel && sudo chown $(id -u):$(id -g) /usr/local/bin/zitadel
curl -s https://api.github.com/repos/zitadel/zitadel/releases/tags/v2.0.0-v2-alpha.33 | grep "browser_download_url.*zitadel_.*_darwin_${MY_ARCHITECTURE}" | cut -d '"' -f 4 | sudo wget -i - -O /usr/local/bin/zitadel && sudo chmod +x /usr/local/bin/zitadel && sudo chown $(id -u):$(id -g) /usr/local/bin/zitadel
```
Run ZITADEL
```bash
zitadel admin start-from-init --tlsMode disabled --masterkey "MasterkeyNeedsToHave32Characters"
zitadel start-from-init --tlsMode disabled --masterkey "MasterkeyNeedsToHave32Characters"
```

View File

@ -7,7 +7,7 @@ import (
)
var (
ErrMissingConfig = errors.New("")
ErrMissingConfig = errors.New("TLS is enabled: please specify a key (path) and a cert (path) or disable TLS if needed (e.g. by setting flag `--tlsMode external` or `--tlsMode disabled")
)
type TLS struct {

View File

@ -8,7 +8,7 @@ import (
"github.com/cockroachdb/cockroach-go/v2/testserver"
"github.com/zitadel/logging"
"github.com/zitadel/zitadel/cmd/admin/initialise"
"github.com/zitadel/zitadel/cmd/initialise"
)
var (

View File

@ -8,7 +8,7 @@ import (
"github.com/cockroachdb/cockroach-go/v2/testserver"
"github.com/zitadel/logging"
"github.com/zitadel/zitadel/cmd/admin/initialise"
"github.com/zitadel/zitadel/cmd/initialise"
)
var (