mirror of
https://github.com/openziti/zrok.git
synced 2025-06-21 10:17:51 +02:00
more naming simplification
This commit is contained in:
parent
2d75181483
commit
887db1d2b6
@ -43,10 +43,10 @@ func (cmd *disableCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
auth := httptransport.APIKeyAuth("X-TOKEN", "header", env.ZrokToken)
|
auth := httptransport.APIKeyAuth("X-TOKEN", "header", env.Token)
|
||||||
req := identity.NewDisableParams()
|
req := identity.NewDisableParams()
|
||||||
req.Body = &rest_model_zrok.DisableRequest{
|
req.Body = &rest_model_zrok.DisableRequest{
|
||||||
Identity: env.ZitiIdentityId,
|
Identity: env.ZId,
|
||||||
}
|
}
|
||||||
_, err = zrok.Identity.Disable(req, auth)
|
_, err = zrok.Identity.Disable(req, auth)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -66,5 +66,5 @@ func (cmd *disableCommand) run(_ *cobra.Command, args []string) {
|
|||||||
showError("error removing zrok backend identity", err)
|
showError("error removing zrok backend identity", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fmt.Printf("zrok environment '%v' disabled for '%v'\n", env.ZitiIdentityId, env.ZrokToken)
|
fmt.Printf("zrok environment '%v' disabled for '%v'\n", env.ZId, env.Token)
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ func newEnableCommand() *enableCommand {
|
|||||||
func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
|
func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
|
||||||
env, err := zrokdir.LoadEnvironment()
|
env, err := zrokdir.LoadEnvironment()
|
||||||
if err == nil {
|
if err == nil {
|
||||||
showError(fmt.Sprintf("you already have an environment '%v' for '%v'", env.ZitiIdentityId, env.ZrokToken), nil)
|
showError(fmt.Sprintf("you already have an environment '%v' for '%v'", env.ZId, env.Token), nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
token := args[0]
|
token := args[0]
|
||||||
@ -73,7 +73,7 @@ func (cmd *enableCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
if err := zrokdir.SaveEnvironment(&zrokdir.Environment{ZrokToken: token, ZitiIdentityId: resp.Payload.Identity, ApiEndpoint: apiEndpoint}); err != nil {
|
if err := zrokdir.SaveEnvironment(&zrokdir.Environment{Token: token, ZId: resp.Payload.Identity, ApiEndpoint: apiEndpoint}); err != nil {
|
||||||
if !panicInstead {
|
if !panicInstead {
|
||||||
showError("there was an error saving the new environment", err)
|
showError("there was an error saving the new environment", err)
|
||||||
}
|
}
|
||||||
|
@ -88,10 +88,10 @@ func (self *httpBackendCommand) run(_ *cobra.Command, args []string) {
|
|||||||
}
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
auth := httptransport.APIKeyAuth("X-TOKEN", "header", env.ZrokToken)
|
auth := httptransport.APIKeyAuth("X-TOKEN", "header", env.Token)
|
||||||
req := tunnel.NewTunnelParams()
|
req := tunnel.NewTunnelParams()
|
||||||
req.Body = &rest_model_zrok.TunnelRequest{
|
req.Body = &rest_model_zrok.TunnelRequest{
|
||||||
ZitiIdentityID: env.ZitiIdentityId,
|
ZitiIdentityID: env.ZId,
|
||||||
Endpoint: cfg.EndpointAddress,
|
Endpoint: cfg.EndpointAddress,
|
||||||
AuthScheme: string(model.None),
|
AuthScheme: string(model.None),
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ func (self *httpBackendCommand) run(_ *cobra.Command, args []string) {
|
|||||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||||
go func() {
|
go func() {
|
||||||
<-c
|
<-c
|
||||||
self.destroy(env.ZitiIdentityId, cfg, zrok, auth)
|
self.destroy(env.ZId, cfg, zrok, auth)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ func (self *httpBackendCommand) run(_ *cobra.Command, args []string) {
|
|||||||
switch e.ID {
|
switch e.ID {
|
||||||
case "q", "<C-c>":
|
case "q", "<C-c>":
|
||||||
ui.Close()
|
ui.Close()
|
||||||
self.destroy(env.ZitiIdentityId, cfg, zrok, auth)
|
self.destroy(env.ZId, cfg, zrok, auth)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,10 +163,10 @@ func (l *looper) startup() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
l.auth = httptransport.APIKeyAuth("x-token", "header", l.env.ZrokToken)
|
l.auth = httptransport.APIKeyAuth("x-token", "header", l.env.Token)
|
||||||
tunnelReq := tunnel.NewTunnelParams()
|
tunnelReq := tunnel.NewTunnelParams()
|
||||||
tunnelReq.Body = &rest_model_zrok.TunnelRequest{
|
tunnelReq.Body = &rest_model_zrok.TunnelRequest{
|
||||||
ZitiIdentityID: l.env.ZitiIdentityId,
|
ZitiIdentityID: l.env.ZId,
|
||||||
Endpoint: fmt.Sprintf("looper#%d", l.id),
|
Endpoint: fmt.Sprintf("looper#%d", l.id),
|
||||||
AuthScheme: string(model.None),
|
AuthScheme: string(model.None),
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ func (l *looper) shutdown() {
|
|||||||
|
|
||||||
untunnelReq := tunnel.NewUntunnelParams()
|
untunnelReq := tunnel.NewUntunnelParams()
|
||||||
untunnelReq.Body = &rest_model_zrok.UntunnelRequest{
|
untunnelReq.Body = &rest_model_zrok.UntunnelRequest{
|
||||||
ZitiIdentityID: l.env.ZitiIdentityId,
|
ZitiIdentityID: l.env.ZId,
|
||||||
Service: l.service,
|
Service: l.service,
|
||||||
}
|
}
|
||||||
if _, err := l.zrok.Tunnel.Untunnel(untunnelReq, l.auth); err != nil {
|
if _, err := l.zrok.Tunnel.Untunnel(untunnelReq, l.auth); err != nil {
|
||||||
|
@ -63,7 +63,7 @@ func (self *disableHandler) checkZitiIdentity(id string, principal *rest_model_z
|
|||||||
return -1, err
|
return -1, err
|
||||||
}
|
}
|
||||||
for _, env := range envs {
|
for _, env := range envs {
|
||||||
if env.ZitiIdentityId == id {
|
if env.ZId == id {
|
||||||
return env.Id, nil
|
return env.Id, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ func (self *enableHandler) Handle(params identity.EnableParams, principal *rest_
|
|||||||
Description: params.Body.Description,
|
Description: params.Body.Description,
|
||||||
Host: params.Body.Host,
|
Host: params.Body.Host,
|
||||||
Address: realRemoteAddress(params.HTTPRequest),
|
Address: realRemoteAddress(params.HTTPRequest),
|
||||||
ZitiIdentityId: ident.Payload.Data.ID,
|
ZId: ident.Payload.Data.ID,
|
||||||
}, tx)
|
}, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("error storing created identity: %v", err)
|
logrus.Errorf("error storing created identity: %v", err)
|
||||||
|
@ -23,7 +23,7 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ
|
|||||||
for _, env := range envs {
|
for _, env := range envs {
|
||||||
svcs, err := str.FindServicesForEnvironment(env.Id, tx)
|
svcs, err := str.FindServicesForEnvironment(env.Id, tx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("error finding services for environment '%v': %v", env.ZitiIdentityId, err)
|
logrus.Errorf("error finding services for environment '%v': %v", env.ZId, err)
|
||||||
return metadata.NewOverviewInternalServerError()
|
return metadata.NewOverviewInternalServerError()
|
||||||
}
|
}
|
||||||
es := &rest_model_zrok.EnvironmentServices{
|
es := &rest_model_zrok.EnvironmentServices{
|
||||||
@ -34,7 +34,7 @@ func overviewHandler(_ metadata.OverviewParams, principal *rest_model_zrok.Princ
|
|||||||
Description: env.Description,
|
Description: env.Description,
|
||||||
Host: env.Host,
|
Host: env.Host,
|
||||||
UpdatedAt: env.UpdatedAt.String(),
|
UpdatedAt: env.UpdatedAt.String(),
|
||||||
ZitiIdentityID: env.ZitiIdentityId,
|
ZitiIdentityID: env.ZId,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _, svc := range svcs {
|
for _, svc := range svcs {
|
||||||
|
@ -11,16 +11,16 @@ type Environment struct {
|
|||||||
Description string
|
Description string
|
||||||
Host string
|
Host string
|
||||||
Address string
|
Address string
|
||||||
ZitiIdentityId string
|
ZId string
|
||||||
Active bool
|
Active bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *Store) CreateEnvironment(accountId int, i *Environment, tx *sqlx.Tx) (int, error) {
|
func (self *Store) CreateEnvironment(accountId int, i *Environment, tx *sqlx.Tx) (int, error) {
|
||||||
stmt, err := tx.Prepare("insert into environments (account_id, description, host, address, ziti_identity_id, active) values (?, ?, ?, ?, ?, true)")
|
stmt, err := tx.Prepare("insert into environments (account_id, description, host, address, z_id, active) values (?, ?, ?, ?, ?, true)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, errors.Wrap(err, "error preparing environments insert statement")
|
return 0, errors.Wrap(err, "error preparing environments insert statement")
|
||||||
}
|
}
|
||||||
res, err := stmt.Exec(accountId, i.Description, i.Host, i.Address, i.ZitiIdentityId)
|
res, err := stmt.Exec(accountId, i.Description, i.Host, i.Address, i.ZId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, errors.Wrap(err, "error executing environments insert statement")
|
return 0, errors.Wrap(err, "error executing environments insert statement")
|
||||||
}
|
}
|
||||||
|
@ -37,12 +37,12 @@ create table environments (
|
|||||||
description string,
|
description string,
|
||||||
host string,
|
host string,
|
||||||
address string,
|
address string,
|
||||||
ziti_identity_id string not null unique,
|
z_id string not null unique,
|
||||||
active boolean not null,
|
active boolean not null,
|
||||||
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
|
created_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
|
||||||
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
|
updated_at datetime not null default(strftime('%Y-%m-%d %H:%M:%f', 'now')),
|
||||||
|
|
||||||
constraint chk_ziti_identity_id check (ziti_identity_id <> '')
|
constraint chk_z_id check (z_id <> '')
|
||||||
);
|
);
|
||||||
|
|
||||||
--
|
--
|
||||||
|
@ -42,7 +42,7 @@ func (self *tunnelHandler) Handle(params tunnel.TunnelParams, principal *rest_mo
|
|||||||
if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil {
|
if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil {
|
||||||
found := false
|
found := false
|
||||||
for _, env := range envs {
|
for _, env := range envs {
|
||||||
if env.ZitiIdentityId == envId {
|
if env.ZId == envId {
|
||||||
logrus.Infof("found identity '%v' for user '%v'", envId, principal.Email)
|
logrus.Infof("found identity '%v' for user '%v'", envId, principal.Email)
|
||||||
envIdDb = env.Id
|
envIdDb = env.Id
|
||||||
found = true
|
found = true
|
||||||
|
@ -46,7 +46,7 @@ func (self *untunnelHandler) Handle(params tunnel.UntunnelParams, principal *res
|
|||||||
var senv *store.Environment
|
var senv *store.Environment
|
||||||
if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil {
|
if envs, err := str.FindEnvironmentsForAccount(int(principal.ID), tx); err == nil {
|
||||||
for _, env := range envs {
|
for _, env := range envs {
|
||||||
if env.ZitiIdentityId == params.Body.ZitiIdentityID {
|
if env.ZId == params.Body.ZitiIdentityID {
|
||||||
senv = env
|
senv = env
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Environment struct {
|
type Environment struct {
|
||||||
ZrokToken string `json:"zrok_token"`
|
Token string `json:"zrok_token"`
|
||||||
ZitiIdentityId string `json:"ziti_identity"`
|
ZId string `json:"ziti_identity"`
|
||||||
ApiEndpoint string `json:"api_endpoint"`
|
ApiEndpoint string `json:"api_endpoint"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user