mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-04 23:45:07 +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/spf13/cobra"
|
||||||
|
|
||||||
"github.com/zitadel/zitadel/cmd/admin/initialise"
|
"github.com/zitadel/zitadel/cmd/initialise"
|
||||||
"github.com/zitadel/zitadel/cmd/admin/key"
|
"github.com/zitadel/zitadel/cmd/key"
|
||||||
"github.com/zitadel/zitadel/cmd/admin/setup"
|
"github.com/zitadel/zitadel/cmd/setup"
|
||||||
"github.com/zitadel/zitadel/cmd/admin/start"
|
"github.com/zitadel/zitadel/cmd/start"
|
||||||
)
|
)
|
||||||
|
|
||||||
func New() *cobra.Command {
|
func New() *cobra.Command {
|
||||||
adminCMD := &cobra.Command{
|
adminCMD := &cobra.Command{
|
||||||
Use: "admin",
|
Use: "admin",
|
||||||
Short: "The ZITADEL admin CLI lets you interact with your instance",
|
Short: "The ZITADEL admin CLI lets you interact with your instance",
|
||||||
Long: `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 {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
return errors.New("no additional command provided")
|
return errors.New("no additional command provided")
|
||||||
},
|
},
|
||||||
|
@ -3,6 +3,7 @@ package initialise
|
|||||||
import (
|
import (
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/zitadel/logging"
|
"github.com/zitadel/logging"
|
||||||
|
|
||||||
"github.com/zitadel/zitadel/internal/database"
|
"github.com/zitadel/zitadel/internal/database"
|
||||||
"github.com/zitadel/zitadel/internal/id"
|
"github.com/zitadel/zitadel/internal/id"
|
||||||
)
|
)
|
@ -58,9 +58,9 @@ type encryptionKeyConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MustNewSteps(v *viper.Viper) *Steps {
|
func MustNewSteps(v *viper.Viper) *Steps {
|
||||||
viper.AutomaticEnv()
|
v.AutomaticEnv()
|
||||||
viper.SetEnvPrefix("ZITADEL")
|
v.SetEnvPrefix("ZITADEL")
|
||||||
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
|
||||||
v.SetConfigType("yaml")
|
v.SetConfigType("yaml")
|
||||||
err := v.ReadConfig(bytes.NewBuffer(defaultSteps))
|
err := v.ReadConfig(bytes.NewBuffer(defaultSteps))
|
||||||
logging.OnError(err).Fatal("unable to read setup steps")
|
logging.OnError(err).Fatal("unable to read setup steps")
|
@ -8,8 +8,8 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/zitadel/logging"
|
"github.com/zitadel/logging"
|
||||||
|
|
||||||
"github.com/zitadel/zitadel/cmd/admin/key"
|
"github.com/zitadel/zitadel/cmd/key"
|
||||||
"github.com/zitadel/zitadel/cmd/admin/tls"
|
"github.com/zitadel/zitadel/cmd/tls"
|
||||||
"github.com/zitadel/zitadel/internal/database"
|
"github.com/zitadel/zitadel/internal/database"
|
||||||
"github.com/zitadel/zitadel/internal/eventstore"
|
"github.com/zitadel/zitadel/internal/eventstore"
|
||||||
"github.com/zitadel/zitadel/internal/migration"
|
"github.com/zitadel/zitadel/internal/migration"
|
@ -4,8 +4,8 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
|
|
||||||
"github.com/zitadel/zitadel/cmd/admin/key"
|
"github.com/zitadel/zitadel/cmd/key"
|
||||||
"github.com/zitadel/zitadel/cmd/admin/tls"
|
"github.com/zitadel/zitadel/cmd/tls"
|
||||||
)
|
)
|
||||||
|
|
||||||
var tlsMode *string
|
var tlsMode *string
|
@ -21,8 +21,8 @@ import (
|
|||||||
"golang.org/x/net/http2"
|
"golang.org/x/net/http2"
|
||||||
"golang.org/x/net/http2/h2c"
|
"golang.org/x/net/http2/h2c"
|
||||||
|
|
||||||
"github.com/zitadel/zitadel/cmd/admin/key"
|
"github.com/zitadel/zitadel/cmd/key"
|
||||||
cmd_tls "github.com/zitadel/zitadel/cmd/admin/tls"
|
cmd_tls "github.com/zitadel/zitadel/cmd/tls"
|
||||||
admin_es "github.com/zitadel/zitadel/internal/admin/repository/eventsourcing"
|
admin_es "github.com/zitadel/zitadel/internal/admin/repository/eventsourcing"
|
||||||
"github.com/zitadel/zitadel/internal/api"
|
"github.com/zitadel/zitadel/internal/api"
|
||||||
"github.com/zitadel/zitadel/internal/api/assets"
|
"github.com/zitadel/zitadel/internal/api/assets"
|
@ -5,10 +5,10 @@ import (
|
|||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"github.com/zitadel/logging"
|
"github.com/zitadel/logging"
|
||||||
|
|
||||||
"github.com/zitadel/zitadel/cmd/admin/initialise"
|
"github.com/zitadel/zitadel/cmd/initialise"
|
||||||
"github.com/zitadel/zitadel/cmd/admin/key"
|
"github.com/zitadel/zitadel/cmd/key"
|
||||||
"github.com/zitadel/zitadel/cmd/admin/setup"
|
"github.com/zitadel/zitadel/cmd/setup"
|
||||||
"github.com/zitadel/zitadel/cmd/admin/tls"
|
"github.com/zitadel/zitadel/cmd/tls"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewStartFromInit() *cobra.Command {
|
func NewStartFromInit() *cobra.Command {
|
@ -12,6 +12,10 @@ import (
|
|||||||
"github.com/zitadel/logging"
|
"github.com/zitadel/logging"
|
||||||
|
|
||||||
"github.com/zitadel/zitadel/cmd/admin"
|
"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 (
|
var (
|
||||||
@ -41,7 +45,14 @@ func New(out io.Writer, in io.Reader, args []string) *cobra.Command {
|
|||||||
cobra.OnInitialize(initConfig)
|
cobra.OnInitialize(initConfig)
|
||||||
cmd.PersistentFlags().StringArrayVar(&configFiles, "config", nil, "path to config file to overwrite system defaults")
|
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
|
return cmd
|
||||||
}
|
}
|
||||||
|
@ -5,8 +5,8 @@ services:
|
|||||||
restart: always
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
- zitadel
|
- zitadel
|
||||||
image: ghcr.io/zitadel/zitadel:v2.0.0-v2-alpha.32-amd64
|
image: ghcr.io/zitadel/zitadel:v2.0.0-v2-alpha.33-amd64
|
||||||
command: admin start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled
|
command: start-from-init --masterkey "MasterkeyNeedsToHave32Characters" --tlsMode disabled
|
||||||
environment:
|
environment:
|
||||||
- ZITADEL_DATABASE_HOST=db
|
- ZITADEL_DATABASE_HOST=db
|
||||||
- ZITADEL_DEFAULTINSTANCE_CUSTOMDOMAIN=localhost
|
- ZITADEL_DEFAULTINSTANCE_CUSTOMDOMAIN=localhost
|
||||||
|
@ -36,5 +36,5 @@ DefaultInstance:
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Pass multiple config files using the --config argument
|
# 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
|
Download the zitadel binary
|
||||||
|
|
||||||
```bash
|
```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
|
Run the database and application containers
|
||||||
|
|
||||||
```bash
|
```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
|
... or download the binary from GitHub
|
||||||
|
|
||||||
```bash
|
```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
|
Run ZITADEL
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
zitadel admin start-from-init --tlsMode disabled --masterkey "MasterkeyNeedsToHave32Characters"
|
zitadel start-from-init --tlsMode disabled --masterkey "MasterkeyNeedsToHave32Characters"
|
||||||
```
|
```
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
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 {
|
type TLS struct {
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/cockroachdb/cockroach-go/v2/testserver"
|
"github.com/cockroachdb/cockroach-go/v2/testserver"
|
||||||
"github.com/zitadel/logging"
|
"github.com/zitadel/logging"
|
||||||
|
|
||||||
"github.com/zitadel/zitadel/cmd/admin/initialise"
|
"github.com/zitadel/zitadel/cmd/initialise"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/cockroachdb/cockroach-go/v2/testserver"
|
"github.com/cockroachdb/cockroach-go/v2/testserver"
|
||||||
"github.com/zitadel/logging"
|
"github.com/zitadel/logging"
|
||||||
|
|
||||||
"github.com/zitadel/zitadel/cmd/admin/initialise"
|
"github.com/zitadel/zitadel/cmd/initialise"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user