Skip to content

Commit

Permalink
even better names for the common identities in the 'environment' (#34,
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelquigley committed Jul 17, 2023
1 parent 6629171 commit 141c9ae
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 26 deletions.
6 changes: 3 additions & 3 deletions cmd/zrok/accessPrivate.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
case "tcpTunnel":
fe, err := tcpTunnel.NewFrontend(&tcpTunnel.FrontendConfig{
BindAddress: cmd.bindAddress,
IdentityName: env.ShareIdentityName(),
IdentityName: env.EnvironmentIdentityName(),
ShrToken: args[0],
RequestsChan: requests,
})
Expand All @@ -123,7 +123,7 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
case "udpTunnel":
fe, err := udpTunnel.NewFrontend(&udpTunnel.FrontendConfig{
BindAddress: cmd.bindAddress,
IdentityName: env.ShareIdentityName(),
IdentityName: env.EnvironmentIdentityName(),
ShrToken: args[0],
RequestsChan: requests,
IdleTime: time.Minute,
Expand All @@ -144,7 +144,7 @@ func (cmd *accessPrivateCommand) run(_ *cobra.Command, args []string) {
}()

default:
cfg := proxy.DefaultFrontendConfig(env.ShareIdentityName())
cfg := proxy.DefaultFrontendConfig(env.EnvironmentIdentityName())
cfg.ShrToken = shrToken
cfg.Address = cmd.bindAddress
cfg.RequestsChan = requests
Expand Down
2 changes: 1 addition & 1 deletion cmd/zrok/disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (cmd *disableCommand) run(_ *cobra.Command, _ []string) {
}
panic(err)
}
if err := env.DeleteZitiIdentityNamed(env.ShareIdentityName()); err != nil {
if err := env.DeleteZitiIdentityNamed(env.EnvironmentIdentityName()); err != nil {
if !panicInstead {
tui.Error("error removing zrok backend identity", err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/zrok/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
}
os.Exit(1)
}
if err := env.SaveZitiIdentityNamed(env.ShareIdentityName(), resp.Payload.Cfg); err != nil {
if err := env.SaveZitiIdentityNamed(env.EnvironmentIdentityName(), resp.Payload.Cfg); err != nil {
if !cmd.headless && prg != nil {
prg.Send(fmt.Sprintf("there was an error writing the environment: %v", err))
prg.Quit()
Expand Down
2 changes: 1 addition & 1 deletion cmd/zrok/sharePrivate.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (cmd *sharePrivateCommand) run(_ *cobra.Command, args []string) {
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
}

zif, err := env.ZitiIdentityNamed(env.ShareIdentityName())
zif, err := env.ZitiIdentityNamed(env.EnvironmentIdentityName())
if err != nil {
if !panicInstead {
tui.Error("unable to load ziti identity configuration", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/zrok/sharePublic.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (cmd *sharePublicCommand) run(_ *cobra.Command, args []string) {
tui.Error("unable to load environment; did you 'zrok enable'?", nil)
}

zif, err := env.ZitiIdentityNamed(env.ShareIdentityName())
zif, err := env.ZitiIdentityNamed(env.EnvironmentIdentityName())
if err != nil {
if !panicInstead {
tui.Error("unable to load ziti identity configuration", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/zrok/shareReserved.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) {
target = resp.Payload.BackendProxyEndpoint
}

zif, err := env.ZitiIdentityNamed(env.ShareIdentityName())
zif, err := env.ZitiIdentityNamed(env.EnvironmentIdentityName())
if err != nil {
if !panicInstead {
tui.Error("unable to load ziti identity configuration", err)
Expand Down
2 changes: 1 addition & 1 deletion cmd/zrok/testLoopPublic.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (l *looper) startup() {
}
l.env = env.Environment()

l.zif, err = env.ZitiIdentityNamed(env.ShareIdentityName())
l.zif, err = env.ZitiIdentityNamed(env.EnvironmentIdentityName())
if err != nil {
panic(err)
}
Expand Down
8 changes: 4 additions & 4 deletions controller/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ func Bootstrap(skipFrontend bool, inCfg *config.Config) error {

var frontendZId string
if !skipFrontend {
logrus.Info("creating identity for frontend ziti access")
logrus.Info("creating identity for public frontend access")

if frontendZId, err = getIdentityId(env.AccessIdentityName()); err == nil {
if frontendZId, err = getIdentityId(env.PublicIdentityName()); err == nil {
logrus.Infof("frontend identity: %v", frontendZId)
} else {
frontendZId, err = bootstrapIdentity(env.AccessIdentityName(), edge)
frontendZId, err = bootstrapIdentity(env.PublicIdentityName(), edge)
if err != nil {
panic(err)
}
}
if err := assertIdentity(frontendZId, edge); err != nil {
panic(err)
}
if err := assertErpForIdentity(env.AccessIdentityName(), frontendZId, edge); err != nil {
if err := assertErpForIdentity(env.PublicIdentityName(), frontendZId, edge); err != nil {
panic(err)
}

Expand Down
2 changes: 1 addition & 1 deletion endpoints/publicProxy/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Config struct {

func DefaultConfig() *Config {
return &Config{
Identity: "frontend",
Identity: "public",
Address: "0.0.0.0:8080",
}
}
Expand Down
4 changes: 2 additions & 2 deletions environment/env_core/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ type Root interface {
SetEnvironment(env *Environment) error
DeleteEnvironment() error

AccessIdentityName() string
ShareIdentityName() string
PublicIdentityName() string
EnvironmentIdentityName() string

ZitiIdentityNamed(name string) (string, error)
SaveZitiIdentityNamed(name, data string) error
Expand Down
4 changes: 2 additions & 2 deletions environment/env_v0_3/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ func (r *Root) IsEnabled() bool {
return r.env != nil
}

func (r *Root) AccessIdentityName() string {
func (r *Root) PublicIdentityName() string {
return "frontend"
}

func (r *Root) ShareIdentityName() string {
func (r *Root) EnvironmentIdentityName() string {
return "backend"
}

Expand Down
8 changes: 4 additions & 4 deletions environment/env_v0_4/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ func (r *Root) IsEnabled() bool {
return r.env != nil
}

func (r *Root) AccessIdentityName() string {
return "access"
func (r *Root) PublicIdentityName() string {
return "public"
}

func (r *Root) ShareIdentityName() string {
return "share"
func (r *Root) EnvironmentIdentityName() string {
return "environment"
}

func (r *Root) ZitiIdentityNamed(name string) (string, error) {
Expand Down
8 changes: 4 additions & 4 deletions environment/env_v0_4/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@ func Update(r env_core.Root) (env_core.Root, error) {

newR := &Root{meta: r.Metadata(), cfg: r.Config(), env: r.Environment()}

oldAccessF, err := r.ZitiIdentityNamed(r.AccessIdentityName())
oldAccessF, err := r.ZitiIdentityNamed(r.PublicIdentityName())
if err != nil {
return nil, err
}
_, err = os.Stat(oldAccessF)
if err == nil {
newAccessF, err := newR.ZitiIdentityNamed(newR.AccessIdentityName())
newAccessF, err := newR.ZitiIdentityNamed(newR.PublicIdentityName())
if err != nil {
return nil, err
}
Expand All @@ -95,13 +95,13 @@ func Update(r env_core.Root) (env_core.Root, error) {
return nil, err
}

oldShareF, err := r.ZitiIdentityNamed(r.ShareIdentityName())
oldShareF, err := r.ZitiIdentityNamed(r.EnvironmentIdentityName())
if err != nil {
return nil, err
}
_, err = os.Stat(oldShareF)
if err == nil {
newShareF, err := newR.ZitiIdentityNamed(newR.ShareIdentityName())
newShareF, err := newR.ZitiIdentityNamed(newR.EnvironmentIdentityName())
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 141c9ae

Please sign in to comment.