mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-04 15:35:10 +00:00
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:
parent
30f553dea1
commit
12d4d3ea0b
@ -6,17 +6,18 @@ 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 {
|
||||
adminCMD := &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`,
|
||||
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")
|
||||
},
|
||||
|
@ -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"
|
||||
)
|
@ -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")
|
@ -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"
|
@ -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
|
@ -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"
|
@ -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 {
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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"
|
||||
```
|
||||
|
@ -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"
|
||||
```
|
||||
|
@ -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"
|
||||
```
|
||||
|
@ -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 {
|
||||
|
@ -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 (
|
||||
|
@ -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 (
|
||||
|
Loading…
Reference in New Issue
Block a user