diff --git a/cmd/zrok/adminBootstrap.go b/cmd/zrok/adminBootstrap.go index 2501d17c..e2e8416d 100644 --- a/cmd/zrok/adminBootstrap.go +++ b/cmd/zrok/adminBootstrap.go @@ -14,7 +14,6 @@ func init() { type adminBootstrap struct { cmd *cobra.Command - skipCtrl bool skipFrontend bool } @@ -26,7 +25,6 @@ func newAdminBootstrap() *adminBootstrap { } command := &adminBootstrap{cmd: cmd} cmd.Run = command.run - cmd.Flags().BoolVar(&command.skipCtrl, "skip-ctrl", false, "Skip controller (ctrl) identity bootstrapping") cmd.Flags().BoolVar(&command.skipFrontend, "skip-frontend", false, "Skip frontend identity bootstrapping") return command } @@ -38,7 +36,7 @@ func (cmd *adminBootstrap) run(_ *cobra.Command, args []string) { panic(err) } logrus.Infof(cf.Dump(inCfg, cf.DefaultOptions())) - if err := controller.Bootstrap(cmd.skipCtrl, cmd.skipFrontend, inCfg); err != nil { + if err := controller.Bootstrap(cmd.skipFrontend, inCfg); err != nil { panic(err) } logrus.Info("bootstrap complete!") diff --git a/controller/bootstrap.go b/controller/bootstrap.go index 2ee0be15..290fe330 100644 --- a/controller/bootstrap.go +++ b/controller/bootstrap.go @@ -6,12 +6,12 @@ import ( "encoding/json" "fmt" "github.com/openziti/edge-api/rest_management_api_client" - "github.com/openziti/edge-api/rest_management_api_client/config" + restMgmtEdgeConfig "github.com/openziti/edge-api/rest_management_api_client/config" "github.com/openziti/edge-api/rest_management_api_client/edge_router_policy" "github.com/openziti/edge-api/rest_management_api_client/identity" - rest_model_edge "github.com/openziti/edge-api/rest_model" + restModelEdge "github.com/openziti/edge-api/rest_model" "github.com/openziti/sdk-golang/ziti" - zrok_config "github.com/openziti/zrok/controller/config" + "github.com/openziti/zrok/controller/config" "github.com/openziti/zrok/controller/store" "github.com/openziti/zrok/controller/zrokEdgeSdk" "github.com/openziti/zrok/environment" @@ -21,7 +21,7 @@ import ( "time" ) -func Bootstrap(skipCtrl, skipFrontend bool, inCfg *zrok_config.Config) error { +func Bootstrap(skipFrontend bool, inCfg *config.Config) error { cfg = inCfg if v, err := store.Open(cfg.Store); err == nil { @@ -36,26 +36,6 @@ func Bootstrap(skipCtrl, skipFrontend bool, inCfg *zrok_config.Config) error { return errors.Wrap(err, "error connecting to the ziti edge management api") } - var ctrlZId string - if !skipCtrl { - logrus.Info("creating identity for controller ziti access") - - if ctrlZId, err = getIdentityId("ctrl"); err == nil { - logrus.Infof("controller identity: %v", ctrlZId) - } else { - ctrlZId, err = bootstrapIdentity("ctrl", edge) - if err != nil { - panic(err) - } - } - if err := assertIdentity(ctrlZId, edge); err != nil { - panic(err) - } - if err := assertErpForIdentity("ctrl", ctrlZId, edge); err != nil { - panic(err) - } - } - var frontendZId string if !skipFrontend { logrus.Info("creating identity for frontend ziti access") @@ -103,7 +83,7 @@ func assertZrokProxyConfigType(edge *rest_management_api_client.ZitiEdgeManageme filter := fmt.Sprintf("name=\"%v\"", model.ZrokProxyConfig) limit := int64(100) offset := int64(0) - listReq := &config.ListConfigTypesParams{ + listReq := &restMgmtEdgeConfig.ListConfigTypesParams{ Filter: &filter, Limit: &limit, Offset: &offset, @@ -116,8 +96,8 @@ func assertZrokProxyConfigType(edge *rest_management_api_client.ZitiEdgeManageme } if len(listResp.Payload.Data) < 1 { name := model.ZrokProxyConfig - ct := &rest_model_edge.ConfigTypeCreate{Name: &name} - createReq := &config.CreateConfigTypeParams{ConfigType: ct} + ct := &restModelEdge.ConfigTypeCreate{Name: &name} + createReq := &restMgmtEdgeConfig.CreateConfigTypeParams{ConfigType: ct} createReq.SetTimeout(30 * time.Second) createResp, err := edge.Config.CreateConfigType(createReq, nil) if err != nil { @@ -186,7 +166,7 @@ func bootstrapIdentity(name string, edge *rest_management_api_client.ZitiEdgeMan return "", errors.Wrap(err, "error loading environment root") } - idc, err := zrokEdgeSdk.CreateIdentity(name, rest_model_edge.IdentityTypeDevice, nil, edge) + idc, err := zrokEdgeSdk.CreateIdentity(name, restModelEdge.IdentityTypeDevice, nil, edge) if err != nil { return "", errors.Wrapf(err, "error creating '%v' identity", name) } diff --git a/environment/api.go b/environment/api.go index 71ee4261..a9bd95ee 100644 --- a/environment/api.go +++ b/environment/api.go @@ -2,25 +2,31 @@ package environment import ( "github.com/openziti/zrok/environment/env_core" + "github.com/openziti/zrok/environment/env_v0_3" "github.com/openziti/zrok/rest_client_zrok" "github.com/pkg/errors" ) +// Root is the primary interface encapsulating the on-disk environment data. type Root interface { Metadata() *env_core.Metadata + Obliterate() error + HasConfig() (bool, error) Config() *env_core.Config SetConfig(cfg *env_core.Config) error + Client() (*rest_client_zrok.Zrok, error) ApiEndpoint() (string, string) + + IsEnabled() bool Environment() *env_core.Environment SetEnvironment(env *env_core.Environment) error DeleteEnvironment() error - IsEnabled() bool + ZitiIdentityFile(name string) (string, error) SaveZitiIdentity(name, data string) error DeleteZitiIdentity(name string) error - Obliterate() error } func LoadRoot() (Root, error) {