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
|
||||
|
||||
const version = "v0.2.0"
|
||||
|
||||
func Run(cfg *Config) error {
|
||||
swaggerSpec, err := loads.Embedded(rest_server_zrok.SwaggerJSON, rest_server_zrok.FlatSwaggerJSON)
|
||||
if err != nil {
|
||||
@ -52,5 +54,5 @@ func Run(cfg *Config) error {
|
||||
}
|
||||
|
||||
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,
|
||||
Data: cfg,
|
||||
Name: &svcName,
|
||||
Tags: self.zrokTags(svcName),
|
||||
}
|
||||
cfgReq := &config.CreateConfigParams{
|
||||
Config: cfgCrt,
|
||||
@ -144,13 +145,14 @@ func (self *tunnelHandler) createConfig(svcName string, params tunnel.TunnelPara
|
||||
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}
|
||||
encryptionRequired := true
|
||||
svc := &rest_model.ServiceCreate{
|
||||
Configs: configs,
|
||||
EncryptionRequired: &encryptionRequired,
|
||||
Name: &name,
|
||||
Name: &svcName,
|
||||
Tags: self.zrokTags(svcName),
|
||||
}
|
||||
req := &service.CreateServiceParams{
|
||||
Service: svc,
|
||||
@ -179,6 +181,7 @@ func (self *tunnelHandler) createServicePolicyBind(svcName, svcId, envId string,
|
||||
Semantic: &semantic,
|
||||
ServiceRoles: serviceRoles,
|
||||
Type: &dialBind,
|
||||
Tags: self.zrokTags(svcName),
|
||||
}
|
||||
req := &service_policy.CreateServicePolicyParams{
|
||||
Policy: svcp,
|
||||
@ -211,6 +214,7 @@ func (self *tunnelHandler) createServicePolicyDial(svcName, svcId string, edge *
|
||||
Semantic: &semantic,
|
||||
ServiceRoles: serviceRoles,
|
||||
Type: &dialBind,
|
||||
Tags: self.zrokTags(svcName),
|
||||
}
|
||||
req := &service_policy.CreateServicePolicyParams{
|
||||
Policy: svcp,
|
||||
@ -234,6 +238,7 @@ func (self *tunnelHandler) createServiceEdgeRouterPolicy(svcName, svcId string,
|
||||
Name: &svcName,
|
||||
Semantic: &semantic,
|
||||
ServiceRoles: serviceRoles,
|
||||
Tags: self.zrokTags(svcName),
|
||||
}
|
||||
serpParams := &service_edge_router_policy.CreateServiceEdgeRouterPolicyParams{
|
||||
Policy: serp,
|
||||
@ -251,3 +256,12 @@ func (self *tunnelHandler) createServiceEdgeRouterPolicy(svcName, svcId string,
|
||||
func (self *tunnelHandler) proxyUrl(svcName string) string {
|
||||
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