mirror of
https://github.com/openziti/zrok.git
synced 2024-11-22 08:03:49 +01:00
add tags to zrok-created objects (#60)
This commit is contained in:
parent
54b4161045
commit
0ceda88b4c
@ -13,6 +13,8 @@ import (
|
|||||||
|
|
||||||
var str *store.Store
|
var str *store.Store
|
||||||
|
|
||||||
|
const version = "v0.2.0"
|
||||||
|
|
||||||
func Run(cfg *Config) error {
|
func Run(cfg *Config) error {
|
||||||
swaggerSpec, err := loads.Embedded(rest_server_zrok.SwaggerJSON, rest_server_zrok.FlatSwaggerJSON)
|
swaggerSpec, err := loads.Embedded(rest_server_zrok.SwaggerJSON, rest_server_zrok.FlatSwaggerJSON)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -52,5 +54,5 @@ func Run(cfg *Config) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func versionHandler(_ metadata.VersionParams) middleware.Responder {
|
func versionHandler(_ metadata.VersionParams) middleware.Responder {
|
||||||
return metadata.NewVersionOK().WithPayload("v0.2.0")
|
return metadata.NewVersionOK().WithPayload(version)
|
||||||
}
|
}
|
||||||
|
@ -130,6 +130,7 @@ func (self *tunnelHandler) createConfig(svcName string, params tunnel.TunnelPara
|
|||||||
ConfigTypeID: &zrokProxyConfigId,
|
ConfigTypeID: &zrokProxyConfigId,
|
||||||
Data: cfg,
|
Data: cfg,
|
||||||
Name: &svcName,
|
Name: &svcName,
|
||||||
|
Tags: self.zrokTags(svcName),
|
||||||
}
|
}
|
||||||
cfgReq := &config.CreateConfigParams{
|
cfgReq := &config.CreateConfigParams{
|
||||||
Config: cfgCrt,
|
Config: cfgCrt,
|
||||||
@ -144,13 +145,14 @@ func (self *tunnelHandler) createConfig(svcName string, params tunnel.TunnelPara
|
|||||||
return cfgResp.Payload.Data.ID, nil
|
return cfgResp.Payload.Data.ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *tunnelHandler) createService(name, cfgId string, edge *rest_management_api_client.ZitiEdgeManagement) (serviceId string, err error) {
|
func (self *tunnelHandler) createService(svcName, cfgId string, edge *rest_management_api_client.ZitiEdgeManagement) (serviceId string, err error) {
|
||||||
configs := []string{cfgId}
|
configs := []string{cfgId}
|
||||||
encryptionRequired := true
|
encryptionRequired := true
|
||||||
svc := &rest_model.ServiceCreate{
|
svc := &rest_model.ServiceCreate{
|
||||||
Configs: configs,
|
Configs: configs,
|
||||||
EncryptionRequired: &encryptionRequired,
|
EncryptionRequired: &encryptionRequired,
|
||||||
Name: &name,
|
Name: &svcName,
|
||||||
|
Tags: self.zrokTags(svcName),
|
||||||
}
|
}
|
||||||
req := &service.CreateServiceParams{
|
req := &service.CreateServiceParams{
|
||||||
Service: svc,
|
Service: svc,
|
||||||
@ -179,6 +181,7 @@ func (self *tunnelHandler) createServicePolicyBind(svcName, svcId, envId string,
|
|||||||
Semantic: &semantic,
|
Semantic: &semantic,
|
||||||
ServiceRoles: serviceRoles,
|
ServiceRoles: serviceRoles,
|
||||||
Type: &dialBind,
|
Type: &dialBind,
|
||||||
|
Tags: self.zrokTags(svcName),
|
||||||
}
|
}
|
||||||
req := &service_policy.CreateServicePolicyParams{
|
req := &service_policy.CreateServicePolicyParams{
|
||||||
Policy: svcp,
|
Policy: svcp,
|
||||||
@ -211,6 +214,7 @@ func (self *tunnelHandler) createServicePolicyDial(svcName, svcId string, edge *
|
|||||||
Semantic: &semantic,
|
Semantic: &semantic,
|
||||||
ServiceRoles: serviceRoles,
|
ServiceRoles: serviceRoles,
|
||||||
Type: &dialBind,
|
Type: &dialBind,
|
||||||
|
Tags: self.zrokTags(svcName),
|
||||||
}
|
}
|
||||||
req := &service_policy.CreateServicePolicyParams{
|
req := &service_policy.CreateServicePolicyParams{
|
||||||
Policy: svcp,
|
Policy: svcp,
|
||||||
@ -234,6 +238,7 @@ func (self *tunnelHandler) createServiceEdgeRouterPolicy(svcName, svcId string,
|
|||||||
Name: &svcName,
|
Name: &svcName,
|
||||||
Semantic: &semantic,
|
Semantic: &semantic,
|
||||||
ServiceRoles: serviceRoles,
|
ServiceRoles: serviceRoles,
|
||||||
|
Tags: self.zrokTags(svcName),
|
||||||
}
|
}
|
||||||
serpParams := &service_edge_router_policy.CreateServiceEdgeRouterPolicyParams{
|
serpParams := &service_edge_router_policy.CreateServiceEdgeRouterPolicyParams{
|
||||||
Policy: serp,
|
Policy: serp,
|
||||||
@ -251,3 +256,12 @@ func (self *tunnelHandler) createServiceEdgeRouterPolicy(svcName, svcId string,
|
|||||||
func (self *tunnelHandler) proxyUrl(svcName string) string {
|
func (self *tunnelHandler) proxyUrl(svcName string) string {
|
||||||
return strings.Replace(self.cfg.Proxy.UrlTemplate, "{svcName}", svcName, -1)
|
return strings.Replace(self.cfg.Proxy.UrlTemplate, "{svcName}", svcName, -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *tunnelHandler) zrokTags(svcName string) *rest_model.Tags {
|
||||||
|
return &rest_model.Tags{
|
||||||
|
SubTags: map[string]interface{}{
|
||||||
|
"zrok": version,
|
||||||
|
"zrok-service-name": svcName,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user