mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 20:08:02 +00:00
c0878e4509
* docs: describe crd mode * docs: fix links * docs: fix commands and crdb resources * feat: add configure command * chore: use latest ORBOS * chore: use latest ORBOS * docs: start gitops docs * fix: compile * chore: fix build script path * chore: remove redundant prebuild * chore: add configure.go * docs: describe gitops mode * docs: point template links to main branch * docs: fix versions * feat: initialize empty keys * feat: reconfigure running ZITADEL * docs: describe crd mode * docs: fix links * docs: fix commands and crdb resources * feat: add configure command * chore: use latest ORBOS * chore: use latest ORBOS * docs: start gitops docs * fix: compile * chore: fix build script path * chore: remove redundant prebuild * chore: add configure.go * docs: describe gitops mode * docs: point template links to main branch * docs: fix versions * feat: initialize empty keys * feat: reconfigure running ZITADEL * test: fix * docs: keys are generated with configure * docs: remove keys from template * chore: pass compile time data * chore: use latest ORBOS * fix: when in-cluster, use in-cluster k8s client * fix: try in-cluster config if kubeconfig is empty * fix: reduce unneeded side effects for configure command * docs: boom version * chore: use latest ORBOS * chore: use latest ORBOS * initial commit * inital changes * commit WIP Information Architecture * commit a working state * add static assets and project * add org and fix img names * add plausible * remove img * change sidebar to easier mgmt * add openid oauth and domains * lint md * quickstarts * add auth flow * identity brokering * remove site * fix broken links * extend footer * extend readme * fix: styling * fix: zitadel logo on index * styling * border * fix: nav * fix: nav * fix: index * fix: corrected zitadelctl examples * fix: rename architecture to concepts * fix: introductions * fix: introductions * fix: introductions * docs: cli r/w secrets examples * docs: finish ZITADEL Enterprise Cloud * docs: mention ZITADEL Enterprise Cloud tier * docs: comment configuration options * docs: fix broken links * docs: move some introduction texts around * docs: twilio and email are mandatory * docs: download latest binaries Co-authored-by: Florian Forster <florian@caos.ch> Co-authored-by: fabi <fabienne.gerschwiler@gmail.com> Co-authored-by: Livio Amstutz <livio.a@gmail.com> Co-authored-by: Stefan Benz <stefan@caos.ch>
101 lines
2.8 KiB
Go
101 lines
2.8 KiB
Go
package cmds
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/orbos/mntr"
|
|
"github.com/caos/orbos/pkg/git"
|
|
"github.com/caos/orbos/pkg/orb"
|
|
"github.com/caos/zitadel/operator/helpers"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
type RootValues struct {
|
|
Ctx context.Context
|
|
Monitor mntr.Monitor
|
|
Version string
|
|
Gitops bool
|
|
OrbConfig *orb.Orb
|
|
GitClient *git.Client
|
|
Kubeconfig string
|
|
ErrFunc errFunc
|
|
}
|
|
|
|
type GetRootValues func() (*RootValues, error)
|
|
|
|
type errFunc func(err error) error
|
|
|
|
func RootCommand(version string) (*cobra.Command, GetRootValues) {
|
|
|
|
var (
|
|
ctx = context.Background()
|
|
monitor = mntr.Monitor{
|
|
OnInfo: mntr.LogMessage,
|
|
OnChange: mntr.LogMessage,
|
|
OnError: mntr.LogError,
|
|
}
|
|
rv = &RootValues{
|
|
Ctx: ctx,
|
|
Version: version,
|
|
ErrFunc: func(err error) error {
|
|
if err != nil {
|
|
monitor.Error(err)
|
|
}
|
|
return nil
|
|
},
|
|
}
|
|
orbConfigPath string
|
|
verbose bool
|
|
)
|
|
cmd := &cobra.Command{
|
|
Use: "zitadelctl [flags]",
|
|
Short: "Interact with your IAM orbs",
|
|
Long: `zitadelctl launches zitadel and simplifies common tasks such as deploying operators or reading and writing secrets.
|
|
Participate in our community on https://github.com/caos/orbos
|
|
and visit our website at https://caos.ch`,
|
|
Example: `$ # For being able to use the --gitops flag, you need to create an orbconfig and add an SSH deploy key to your github project
|
|
$ # Create an ssh key pair
|
|
$ ssh-keygen -b 2048 -t rsa -f ~/.ssh/myorbrepo -q -N ""
|
|
$ # Create the orbconfig
|
|
$ mkdir -p ~/.orb
|
|
$ cat > ~/.orb/myorb << EOF
|
|
> # this is the ssh URL to your git repository
|
|
> url: git@github.com:me/my-orb.git
|
|
> masterkey: "$(openssl rand -base64 21)" # used for encrypting and decrypting secrets
|
|
> # the repokey is used to connect to your git repository
|
|
> repokey: |
|
|
> $(cat ~/.ssh/myorbrepo | sed s/^/\ \ /g)
|
|
> EOF
|
|
$ zitadelctl --gitops -f ~/.orb/myorb [command]
|
|
`,
|
|
}
|
|
|
|
flags := cmd.PersistentFlags()
|
|
flags.BoolVar(&rv.Gitops, "gitops", false, "Run zitadelctl in gitops mode")
|
|
flags.StringVarP(&orbConfigPath, "orbconfig", "f", "~/.orb/config", "Path to the file containing the orbs git repo URL, deploy key and the master key for encrypting and decrypting secrets")
|
|
flags.StringVarP(&rv.Kubeconfig, "kubeconfig", "k", "~/.kube/config", "Path to the kubeconfig file to the cluster zitadelctl should target")
|
|
flags.BoolVar(&verbose, "verbose", false, "Print debug levelled logs")
|
|
|
|
return cmd, func() (*RootValues, error) {
|
|
|
|
if verbose {
|
|
monitor = monitor.Verbose()
|
|
}
|
|
|
|
rv.Monitor = monitor
|
|
rv.Kubeconfig = helpers.PruneHome(rv.Kubeconfig)
|
|
rv.GitClient = git.New(ctx, monitor, "zitadel", "orbos@caos.ch")
|
|
|
|
var err error
|
|
if rv.Gitops {
|
|
prunedPath := helpers.PruneHome(orbConfigPath)
|
|
rv.OrbConfig, err = orb.ParseOrbConfig(prunedPath)
|
|
if rv.OrbConfig == nil {
|
|
rv.OrbConfig = &orb.Orb{Path: prunedPath}
|
|
}
|
|
}
|
|
|
|
return rv, err
|
|
}
|
|
}
|