mirror of
https://github.com/openziti/zrok.git
synced 2025-08-18 19:58:28 +02:00
zrok proxy config v1 (#12)
This commit is contained in:
@@ -2,6 +2,8 @@ package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/openziti-test-kitchen/zrok/model"
|
||||
"github.com/openziti/edge/rest_management_api_client"
|
||||
"github.com/openziti/edge/rest_management_api_client/config"
|
||||
"github.com/openziti/edge/rest_model"
|
||||
@@ -10,7 +12,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var zrokAuthV1Id string
|
||||
var zrokProxyConfigId string
|
||||
|
||||
func controllerStartup(cfg *Config) error {
|
||||
if err := inspectZiti(cfg); err != nil {
|
||||
@@ -26,15 +28,15 @@ func inspectZiti(cfg *Config) error {
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error getting ziti edge client")
|
||||
}
|
||||
if err := ensureZrokAuthConfigType(edge); err != nil {
|
||||
if err := ensureZrokProxyConfigType(edge); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func ensureZrokAuthConfigType(edge *rest_management_api_client.ZitiEdgeManagement) error {
|
||||
filter := "name=\"zrok.auth.v1\""
|
||||
func ensureZrokProxyConfigType(edge *rest_management_api_client.ZitiEdgeManagement) error {
|
||||
filter := fmt.Sprintf("name=\"%v\"", model.ZrokProxyConfig)
|
||||
limit := int64(100)
|
||||
offset := int64(0)
|
||||
listReq := &config.ListConfigTypesParams{
|
||||
@@ -49,7 +51,7 @@ func ensureZrokAuthConfigType(edge *rest_management_api_client.ZitiEdgeManagemen
|
||||
return err
|
||||
}
|
||||
if len(listResp.Payload.Data) < 1 {
|
||||
name := "zrok.auth.v1"
|
||||
name := model.ZrokProxyConfig
|
||||
ct := &rest_model.ConfigTypeCreate{Name: &name}
|
||||
createReq := &config.CreateConfigTypeParams{ConfigType: ct}
|
||||
createReq.SetTimeout(30 * time.Second)
|
||||
@@ -57,13 +59,13 @@ func ensureZrokAuthConfigType(edge *rest_management_api_client.ZitiEdgeManagemen
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
logrus.Infof("created 'zrok.auth.v1' config type with id '%v'", createResp.Payload.Data.ID)
|
||||
zrokAuthV1Id = createResp.Payload.Data.ID
|
||||
logrus.Infof("created '%v' config type with id '%v'", model.ZrokProxyConfig, createResp.Payload.Data.ID)
|
||||
zrokProxyConfigId = createResp.Payload.Data.ID
|
||||
} else if len(listResp.Payload.Data) > 1 {
|
||||
return errors.Errorf("found %d 'zrok.auth.v1' config types; expected 0 or 1", len(listResp.Payload.Data))
|
||||
return errors.Errorf("found %d '%v' config types; expected 0 or 1", len(listResp.Payload.Data), model.ZrokProxyConfig)
|
||||
} else {
|
||||
logrus.Infof("found 'zrok.auth.v1' config type with id '%v'", *(listResp.Payload.Data[0].ID))
|
||||
zrokAuthV1Id = *(listResp.Payload.Data[0].ID)
|
||||
logrus.Infof("found '%v' config type with id '%v'", model.ZrokProxyConfig, *(listResp.Payload.Data[0].ID))
|
||||
zrokProxyConfigId = *(listResp.Payload.Data[0].ID)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user