mirror of
https://github.com/openziti/zrok.git
synced 2024-12-22 06:40:50 +01:00
CreateShareService (#112)
This commit is contained in:
parent
cc1f62e317
commit
a77f39e97d
@ -10,22 +10,10 @@ import (
|
||||
rest_model_edge "github.com/openziti/edge/rest_model"
|
||||
sdk_config "github.com/openziti/sdk-golang/ziti/config"
|
||||
"github.com/openziti/sdk-golang/ziti/enroll"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"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 {
|
||||
edgeRouterRoles := []string{"#all"}
|
||||
identityRoles := []string{fmt.Sprintf("@%v", zId)}
|
||||
|
@ -23,7 +23,7 @@ func (a *privateResourceAllocator) allocate(envZId, svcToken string, params serv
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
svcZId, err = createShareService(envZId, svcToken, cfgId, edge)
|
||||
svcZId, err = zrok_edge_sdk.CreateShareService(envZId, svcToken, cfgId, edge)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ func (a *publicResourceAllocator) allocate(envZId, svcToken string, frontendZIds
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
svcZId, err = createShareService(envZId, svcToken, cfgId, edge)
|
||||
svcZId, err = zrok_edge_sdk.CreateShareService(envZId, svcToken, cfgId, edge)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
@ -5,10 +5,22 @@ import (
|
||||
"github.com/openziti/edge/rest_management_api_client"
|
||||
edge_service "github.com/openziti/edge/rest_management_api_client/service"
|
||||
"github.com/openziti/edge/rest_model"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"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) {
|
||||
encryptionRequired := true
|
||||
svc := &rest_model.ServiceCreate{
|
||||
|
Loading…
Reference in New Issue
Block a user