CreateShareService (#112)

This commit is contained in:
Michael Quigley 2022-12-14 14:11:50 -05:00
parent cc1f62e317
commit a77f39e97d
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
4 changed files with 14 additions and 14 deletions

View File

@ -10,22 +10,10 @@ import (
rest_model_edge "github.com/openziti/edge/rest_model" rest_model_edge "github.com/openziti/edge/rest_model"
sdk_config "github.com/openziti/sdk-golang/ziti/config" sdk_config "github.com/openziti/sdk-golang/ziti/config"
"github.com/openziti/sdk-golang/ziti/enroll" "github.com/openziti/sdk-golang/ziti/enroll"
"github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"time" "time"
) )
func createShareService(envZId, svcToken, cfgId string, edge *rest_management_api_client.ZitiEdgeManagement) (svcZId string, err error) {
configs := []string{cfgId}
tags := zrok_edge_sdk.ZrokServiceTags(svcToken)
svcZId, err = zrok_edge_sdk.CreateService(svcToken, configs, tags.SubTags, edge)
if err != nil {
return "", errors.Wrapf(err, "error creating service '%v'", svcToken)
}
logrus.Infof("created zrok service named '%v' (with ziti id '%v') for environment '%v'", svcToken, svcZId, envZId)
return svcZId, nil
}
func createEdgeRouterPolicy(name, zId string, edge *rest_management_api_client.ZitiEdgeManagement) error { func createEdgeRouterPolicy(name, zId string, edge *rest_management_api_client.ZitiEdgeManagement) error {
edgeRouterRoles := []string{"#all"} edgeRouterRoles := []string{"#all"}
identityRoles := []string{fmt.Sprintf("@%v", zId)} identityRoles := []string{fmt.Sprintf("@%v", zId)}

View File

@ -23,7 +23,7 @@ func (a *privateResourceAllocator) allocate(envZId, svcToken string, params serv
return "", nil, err return "", nil, err
} }
svcZId, err = createShareService(envZId, svcToken, cfgId, edge) svcZId, err = zrok_edge_sdk.CreateShareService(envZId, svcToken, cfgId, edge)
if err != nil { if err != nil {
return "", nil, err return "", nil, err
} }

View File

@ -23,7 +23,7 @@ func (a *publicResourceAllocator) allocate(envZId, svcToken string, frontendZIds
return "", nil, err return "", nil, err
} }
svcZId, err = createShareService(envZId, svcToken, cfgId, edge) svcZId, err = zrok_edge_sdk.CreateShareService(envZId, svcToken, cfgId, edge)
if err != nil { if err != nil {
return "", nil, err return "", nil, err
} }

View File

@ -5,10 +5,22 @@ import (
"github.com/openziti/edge/rest_management_api_client" "github.com/openziti/edge/rest_management_api_client"
edge_service "github.com/openziti/edge/rest_management_api_client/service" edge_service "github.com/openziti/edge/rest_management_api_client/service"
"github.com/openziti/edge/rest_model" "github.com/openziti/edge/rest_model"
"github.com/pkg/errors"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"time" "time"
) )
func CreateShareService(envZId, svcToken, cfgId string, edge *rest_management_api_client.ZitiEdgeManagement) (svcZId string, err error) {
configs := []string{cfgId}
tags := ZrokServiceTags(svcToken)
svcZId, err = CreateService(svcToken, configs, tags.SubTags, edge)
if err != nil {
return "", errors.Wrapf(err, "error creating service '%v'", svcToken)
}
logrus.Infof("created zrok service named '%v' (with ziti id '%v') for environment '%v'", svcToken, svcZId, envZId)
return svcZId, nil
}
func CreateService(name string, cfgIds []string, moreTags map[string]interface{}, edge *rest_management_api_client.ZitiEdgeManagement) (svcZId string, err error) { func CreateService(name string, cfgIds []string, moreTags map[string]interface{}, edge *rest_management_api_client.ZitiEdgeManagement) (svcZId string, err error) {
encryptionRequired := true encryptionRequired := true
svc := &rest_model.ServiceCreate{ svc := &rest_model.ServiceCreate{