From 4b7e2a6707d2e57fdfd16d1cbf3a118059646cf1 Mon Sep 17 00:00:00 2001 From: Kenneth Bingham Date: Thu, 1 Apr 2021 14:18:37 -0400 Subject: [PATCH 1/4] use ziti-tunnel:latest container image tag; remove tun compose service --- ziti-tunnel/docker/docker-compose.yml | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/ziti-tunnel/docker/docker-compose.yml b/ziti-tunnel/docker/docker-compose.yml index 396f012fc..3555e67f0 100644 --- a/ziti-tunnel/docker/docker-compose.yml +++ b/ziti-tunnel/docker/docker-compose.yml @@ -1,13 +1,13 @@ version: "3.3" services: ziti-test: - image: netfoundry/ziti-tunnel:0.18.2 + image: netfoundry/ziti-tunnel:latest network_mode: host cap_add: - NET_ADMIN entrypoint: ["sh", "-c", "while true; do sleep 11; done"] ziti-tproxy: - image: netfoundry/ziti-tunnel:0.18.2 + image: netfoundry/ziti-tunnel:latest network_mode: host cap_add: - NET_ADMIN @@ -18,7 +18,7 @@ services: command: tproxy # command: tproxy --resolver udp://127.0.0.123:53 ziti-iproxy: - image: netfoundry/ziti-tunnel:0.18.2 + image: netfoundry/ziti-tunnel:latest volumes: - .:/netfoundry network_mode: host @@ -27,20 +27,8 @@ services: environment: - NF_REG_NAME command: tproxy --resolver none - ziti-tun: - image: netfoundry/ziti-tunnel:0.18.2 - volumes: - - .:/netfoundry - network_mode: host - cap_add: - - NET_ADMIN - environment: - - NF_REG_NAME - command: tun - devices: - - "/dev/net/tun:/dev/net/tun" ziti-proxy: - image: netfoundry/ziti-tunnel:0.18.2 + image: netfoundry/ziti-tunnel:latest volumes: - .:/netfoundry environment: @@ -50,7 +38,7 @@ services: - "9999:9999" command: proxy "my example service":8888 "my other example service":9999 ziti-host: - image: netfoundry/ziti-tunnel:0.18.2 + image: netfoundry/ziti-tunnel:latest volumes: - .:/netfoundry environment: From 999dbfde44a0b107e1c1fbb6b08b809e9034e5e3 Mon Sep 17 00:00:00 2001 From: ziti-ci Date: Fri, 2 Apr 2021 16:22:37 -0400 Subject: [PATCH 2/4] checkpoint --- go.mod | 8 +-- go.sum | 11 ++-- ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go | 3 + ziti-tunnel/cmd/ziti-tunnel/subcmd/run.go | 14 +---- ziti-tunnel/cmd/ziti-tunnel/subcmd/tproxy.go | 2 +- ziti-tunnel/cmd/ziti-tunnel/subcmd/tun.go | 58 -------------------- 6 files changed, 14 insertions(+), 82 deletions(-) delete mode 100644 ziti-tunnel/cmd/ziti-tunnel/subcmd/tun.go diff --git a/go.mod b/go.mod index 274810902..ae8c5cfab 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ go 1.16 //replace github.com/openziti/sdk-golang => ../sdk-golang -//replace github.com/openziti/edge => ../edge +replace github.com/openziti/edge => ../edge replace go.etcd.io/bbolt => github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e @@ -27,10 +27,10 @@ require ( github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19 github.com/michaelquigley/pfxlog v0.3.7 - github.com/openziti/edge v0.19.55 - github.com/openziti/fabric v0.16.44 + github.com/openziti/edge v0.19.59 + github.com/openziti/fabric v0.16.47 github.com/openziti/foundation v0.15.44 - github.com/openziti/sdk-golang v0.15.31 + github.com/openziti/sdk-golang v0.15.32 github.com/pborman/uuid v1.2.0 github.com/pkg/errors v0.9.1 github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 diff --git a/go.sum b/go.sum index 7679fd54a..ff3d119f0 100644 --- a/go.sum +++ b/go.sum @@ -65,7 +65,6 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/achanda/go-sysctl v0.0.0-20160222034550-6be7678c45d2 h1:NYoPVh1XuUB5VBWLXRKoqzQhl4bajIxh+XuURbJ0uwc= github.com/achanda/go-sysctl v0.0.0-20160222034550-6be7678c45d2/go.mod h1:DCNKSpXhum14Y258jSbRmJvcesbzEdBPincz7yJUx3k= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/akamai/AkamaiOPEN-edgegrid-golang v0.9.18/go.mod h1:L+HB2uBoDgi3+r1pJEJcbGwyyHhd2QXaGsKLbDwtm8Q= @@ -611,14 +610,12 @@ github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e h1:ST9+54UtCr96S5 github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= github.com/openziti/dilithium v0.3.3 h1:PLgQ6PMNLSTzCFbX/h98cmudgz/cU6TmjdSv5NAPD8k= github.com/openziti/dilithium v0.3.3/go.mod h1:vsCjI2AU/hon9e+dLhUFbCNGesJDj2ASgkySOcpmvjo= -github.com/openziti/edge v0.19.55 h1:FZntwcmgTw2GcX6Hib+l4UkHSsCe1mEUPJVDpQpi4cg= -github.com/openziti/edge v0.19.55/go.mod h1:Ga0sP83HV0dtMAAZG5WcFZvqqdyPD2vpj4AV2b2BD+c= -github.com/openziti/fabric v0.16.44 h1:pMEXl8uSdgd/Dj7d4F0qK5TnlLuse5uCpZs3Ah6fPbM= -github.com/openziti/fabric v0.16.44/go.mod h1:soU2ImwCdNOnLDM5JUqpk5wAvrN9LaslZL02oThJQUM= +github.com/openziti/fabric v0.16.47 h1:K8S2ZghskZce5d3AUv5WV2Y91/48+vryVA/TFDmbRHc= +github.com/openziti/fabric v0.16.47/go.mod h1:soU2ImwCdNOnLDM5JUqpk5wAvrN9LaslZL02oThJQUM= github.com/openziti/foundation v0.15.44 h1:+XMOMaog+ABBvxgmDhk70H0buhw2RtpeDClxk+TJ3qQ= github.com/openziti/foundation v0.15.44/go.mod h1:kYCUttsGO/GjoD7BSNhVOeyYDXHYMAfz59YeLoEyhHY= -github.com/openziti/sdk-golang v0.15.31 h1:vo+/wRbNtYBvkxHrAo9Is32SAJQjlhIS+9gHoajB1g0= -github.com/openziti/sdk-golang v0.15.31/go.mod h1:jrvkpxP7U1ejSKEj4J9/UTNWlt6nJaofUGKkTx7afvM= +github.com/openziti/sdk-golang v0.15.32 h1:Mr0kGpsP53ebBxye9kSBeVevW71xS+brVzduSjataXc= +github.com/openziti/sdk-golang v0.15.32/go.mod h1:jrvkpxP7U1ejSKEj4J9/UTNWlt6nJaofUGKkTx7afvM= github.com/oracle/oci-go-sdk v24.2.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231 h1:fa50YL1pzKW+1SsBnJDOHppJN9stOEwS+CRWyUtyYGU= diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go b/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go index 5c9eefe64..b04bd9fda 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go +++ b/ziti-tunnel/cmd/ziti-tunnel/subcmd/root.go @@ -114,6 +114,9 @@ func rootPostRun(cmd *cobra.Command, _ []string) { zitiCfg.ConfigTypes = []string{ entities.ClientConfigV1, entities.ServerConfigV1, + entities.InterceptV1, + entities.HostConfigV1, + entities.HostConfigV2, } resolverConfig := cmd.Flag("resolver").Value.String() diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/run.go b/ziti-tunnel/cmd/ziti-tunnel/subcmd/run.go index 018aa5a37..200f2e54d 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/run.go +++ b/ziti-tunnel/cmd/ziti-tunnel/subcmd/run.go @@ -22,7 +22,6 @@ import ( "github.com/michaelquigley/pfxlog" "github.com/openziti/edge/tunnel/intercept" "github.com/openziti/edge/tunnel/intercept/tproxy" - "github.com/openziti/edge/tunnel/intercept/tun" "github.com/spf13/cobra" ) @@ -42,13 +41,13 @@ func init() { func run(cmd *cobra.Command, args []string) { log := pfxlog.Logger() var err error - var tProxyInterceptor, tunInterceptor intercept.Interceptor + var tProxyInterceptor intercept.Interceptor if len(args) != 0 { _ = cmd.Flag("identity").Value.Set(args[0]) } - tProxyInterceptor, err = tproxy.New() + tProxyInterceptor, err = tproxy.New("") if err != nil { log.Infof("tproxy initialization failed: %v", err) } else { @@ -57,15 +56,6 @@ func run(cmd *cobra.Command, args []string) { return } - tunInterceptor, err = tun.New("", tunMtuDefault) - if err != nil { - log.Infof("tun initialization failed: %v", err) - } else { - log.Info("using tun interceptor") - interceptor = tunInterceptor - return - } - if interceptor == nil { log.Fatal("failed to initialize an interceptor") } diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/tproxy.go b/ziti-tunnel/cmd/ziti-tunnel/subcmd/tproxy.go index 58408cd17..36900999a 100644 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/tproxy.go +++ b/ziti-tunnel/cmd/ziti-tunnel/subcmd/tproxy.go @@ -40,7 +40,7 @@ func init() { func runTProxy(cmd *cobra.Command, args []string) error { var err error lanIf, err := cmd.Flags().GetString("lanIf") - interceptor, err = tproxy.NewWithLanIf(lanIf) + interceptor, err = tproxy.New(lanIf) if err != nil { return fmt.Errorf("failed to initialize tproxy interceptor: %v", err) } diff --git a/ziti-tunnel/cmd/ziti-tunnel/subcmd/tun.go b/ziti-tunnel/cmd/ziti-tunnel/subcmd/tun.go deleted file mode 100644 index be145547e..000000000 --- a/ziti-tunnel/cmd/ziti-tunnel/subcmd/tun.go +++ /dev/null @@ -1,58 +0,0 @@ -// +build linux - -/* - Copyright NetFoundry, Inc. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - https://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package subcmd - -import ( - "fmt" - "github.com/michaelquigley/pfxlog" - "github.com/openziti/edge/tunnel/intercept/tun" - "github.com/spf13/cobra" -) - -const ( - tunMtuFlag = "mtu" - tunMtuDefault = 65535 -) - -func init() { - tunCmd.PersistentFlags().Uint(tunMtuFlag, tunMtuDefault, "Set MTU of ephemeral tun interface") - root.AddCommand(tunCmd) -} - -var tunCmd = &cobra.Command{ - Use: "tun ", - Short: "Intercept packets with tun interface", - Args: cobra.NoArgs, - RunE: runTun, - PostRun: rootPostRun, -} - -func runTun(cmd *cobra.Command, args []string) error { - log := pfxlog.Logger() - mtu, err := cmd.Flags().GetUint(tunMtuFlag) - if err != nil { - log.WithError(err).Warn("error getting MTU") - } - - interceptor, err = tun.New("", mtu) - if err != nil { - return fmt.Errorf("failed to initialize tun interceptor: %v", err) - } - return nil -} From c80166a1c644d65677fa91c80214071b703b3995 Mon Sep 17 00:00:00 2001 From: ziti-ci Date: Tue, 6 Apr 2021 11:03:11 -0400 Subject: [PATCH 3/4] Update deps and changelog --- CHANGELOG.md | 72 +++++++++++++++ go.mod | 12 +-- go.sum | 43 ++++++--- .../cmd/edge_controller/create_edge_router.go | 17 ++-- .../cmd/edge_controller/create_identity.go | 49 ++++++++++- .../cmd/edge_controller/update_edge_router.go | 15 ++++ .../cmd/edge_controller/update_identity.go | 87 ++++++++++++++++++- 7 files changed, 268 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f798b516..6f39eb44a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,75 @@ +# Release 0.19.9 + +## What's New + +* Converged Tunneler/Router (Beta 2) + * intercept.v1 support (also in ziti-tunnel) + * support for setting per-service hosting cost/precedence on identity +* Identites and edge routers now support appData, which is tag data consumable by sdks +* Edge Router Policies now expose the `isSystem` flag for system managed policies +* ziti-tunnel no longer supports tun mode. It has been superceded by tproxy mode + +## Fixes + +* Fix deadlock in ziti-router which would stop new connections from being established after an api session is removed +* Fix id extraction for data plane link latency metrics +* Fix id extraction for ctrl plane link latency metrics +* ziti-tunnel wasn't asking for host.v1/host.v2 configs + +## Per-service Cost/Precedence + +Previously support was adding for setting the default cost and precedence that an identity would use when hosting services. Now, in addition to setting default values, costs and precedences can be set per-service. These are exposed as maps keyed by service. There is one map for costs and another for precedences. There is also CLI support for setting these values. + +Example creating an identity: + +``` +ziti edge create identity service test2 --default-hosting-cost 10 --default-hosting-precedence failed --service-costs loop=20,echo=30 --service-precedences loop=default,echo=required + +``` + +When viewing the identity, these values can be seen: + +``` + "id": "-qJRZFqV8t", + "tags": {}, + "updatedAt": "2021-04-05T16:54:42.763Z", + "authenticators": {}, + "defaultHostingCost": 10, + "defaultHostingPrecedence": "failed", + "envInfo": {}, + "hasApiSession": false, + "hasEdgeRouterConnection": false, + "isAdmin": false, + "isDefaultAdmin": false, + "isMfaEnabled": false, + "name": "test2", + "roleAttributes": null, + "sdkInfo": {}, + "serviceHostingCosts": { + "vH3QndzRYt": 20, + "wAnuyO3PmI": 30 + }, + "serviceHostingPrecedences": { + "vH3QndzRYt": "default", + "wAnuyO3PmI": "required" + }, + +``` + +Note that this mechanism replaces setting cost and precedence via the host.v1/host.v2 config types `listenOptions`. Those values will be ignored, and may in future be removed from the schemas. + +## Identity/Edge Router app data + +We have an existing tags mechanism, which can be used by system administrators to annotate ziti entities in whatever is useful to them. Tags are an administrator function and are not meant to be visible to SDKs and SDK applications. If an administrator wants to provide custom data for services to the SDK they can use config types and configs for that purpose. Up until now however, there hasn't been a means to annotate identities and edge routers, which are the other two entities visible to SDKs, with data that the SDKs can consume. +0.19.9 introduces `appData` on identities and edge-routers. `appData` has the same structure as `tags`, but is intended to allow administrators to push custom data on identities and edge routers to SDKs. An example use is for tunnelers. The `sourceIp` can contain template information, which can refer back to the `appData` for the tunneler's identity. + +The CLI supports setting appData on identities and edge routers. + +``` +ziti edge create identity service myIdentity --tags office=Regional5,device=Laptop --app-data ip=1.1.1.1,QoS=voip + +``` + # Release 0.19.8 ## What's New diff --git a/go.mod b/go.mod index ae8c5cfab..63dec45aa 100644 --- a/go.mod +++ b/go.mod @@ -10,7 +10,7 @@ go 1.16 //replace github.com/openziti/sdk-golang => ../sdk-golang -replace github.com/openziti/edge => ../edge +//replace github.com/openziti/edge => ../edge replace go.etcd.io/bbolt => github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e @@ -21,16 +21,16 @@ require ( github.com/fatih/color v1.7.0 github.com/go-acme/lego/v4 v4.2.0 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b - github.com/golang/protobuf v1.4.3 + github.com/golang/protobuf v1.5.2 github.com/google/go-cmp v0.5.5 github.com/gorilla/mux v1.8.0 github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19 github.com/michaelquigley/pfxlog v0.3.7 - github.com/openziti/edge v0.19.59 - github.com/openziti/fabric v0.16.47 - github.com/openziti/foundation v0.15.44 - github.com/openziti/sdk-golang v0.15.32 + github.com/openziti/edge v0.19.68 + github.com/openziti/fabric v0.16.48 + github.com/openziti/foundation v0.15.45 + github.com/openziti/sdk-golang v0.15.36 github.com/pborman/uuid v1.2.0 github.com/pkg/errors v0.9.1 github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 diff --git a/go.sum b/go.sum index ff3d119f0..834c70e35 100644 --- a/go.sum +++ b/go.sum @@ -65,7 +65,6 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk= github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/achanda/go-sysctl v0.0.0-20160222034550-6be7678c45d2/go.mod h1:DCNKSpXhum14Y258jSbRmJvcesbzEdBPincz7yJUx3k= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/akamai/AkamaiOPEN-edgegrid-golang v0.9.18/go.mod h1:L+HB2uBoDgi3+r1pJEJcbGwyyHhd2QXaGsKLbDwtm8Q= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -253,8 +252,9 @@ github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6 github.com/go-openapi/strfmt v0.19.4/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= github.com/go-openapi/strfmt v0.19.11/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= -github.com/go-openapi/strfmt v0.20.0 h1:l2omNtmNbMc39IGptl9BuXBEKcZfS8zjrTsPKTiJiDM= github.com/go-openapi/strfmt v0.20.0/go.mod h1:UukAYgTaQfqJuAFlNxxMWNvMYiwiXtLsF2VwmoFtbtc= +github.com/go-openapi/strfmt v0.20.1 h1:1VgxvehFne1mbChGeCmZ5pc0LxUf6yaACVSIYAR91Xc= +github.com/go-openapi/strfmt v0.20.1/go.mod h1:43urheQI9dNtE5lTZQfuFJvjYJKPrxicATpEfZwHUNk= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= @@ -263,8 +263,9 @@ github.com/go-openapi/swag v0.19.7/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfT github.com/go-openapi/swag v0.19.9/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= github.com/go-openapi/swag v0.19.12/go.mod h1:eFdyEBkTdoAf/9RXBvj4cr1nH7GD8Kzo5HTt47gr72M= github.com/go-openapi/swag v0.19.13/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= -github.com/go-openapi/swag v0.19.14 h1:gm3vOOXfiuw5i9p5N9xJvfjvuofpyvLA9Wr6QfK5Fng= github.com/go-openapi/swag v0.19.14/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= github.com/go-openapi/validate v0.19.3/go.mod h1:90Vh6jjkTn+OT1Eefm0ZixWNFjhtOH7vS9k0lo6zwJo= @@ -334,8 +335,10 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM= github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y= @@ -424,8 +427,8 @@ github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d h1:/WZ github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo= github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= -github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= -github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/jessevdk/go-flags v1.5.0 h1:1jKYvbxEjfUl0fmqTCOfonvskHHXMjBySTLW4y9LFvc= +github.com/jessevdk/go-flags v1.5.0/go.mod h1:Fw0T6WPc1dYxT4mKEZRfG5kJhaTDP9pj1c2EWnYs/m4= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= @@ -592,6 +595,7 @@ github.com/nrdcg/goinwx v0.8.1/go.mod h1:tILVc10gieBp/5PMvbcYeXM6pVQ+c9jxDZnpaR1 github.com/nrdcg/namesilo v0.2.1/go.mod h1:lwMvfQTyYq+BbjJd30ylEG4GPSS6PII0Tia4rRpRiyw= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= +github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.4/go.mod h1:zq6QwlOf5SlnkVbMSr5EoBv3636FWnp+qbPhuoO21uA= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -610,12 +614,16 @@ github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e h1:ST9+54UtCr96S5 github.com/openziti/bbolt v1.3.6-0.20210317142109-547da822475e/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= github.com/openziti/dilithium v0.3.3 h1:PLgQ6PMNLSTzCFbX/h98cmudgz/cU6TmjdSv5NAPD8k= github.com/openziti/dilithium v0.3.3/go.mod h1:vsCjI2AU/hon9e+dLhUFbCNGesJDj2ASgkySOcpmvjo= -github.com/openziti/fabric v0.16.47 h1:K8S2ZghskZce5d3AUv5WV2Y91/48+vryVA/TFDmbRHc= +github.com/openziti/edge v0.19.68 h1:LDF4UmElo08j1M+y3QPb9Icme35kE5KFao5BzSVQMGA= +github.com/openziti/edge v0.19.68/go.mod h1:Ezv55jngUC7tADADytBPSgoMlj2g2Rd+NQIb0om8Jm4= github.com/openziti/fabric v0.16.47/go.mod h1:soU2ImwCdNOnLDM5JUqpk5wAvrN9LaslZL02oThJQUM= -github.com/openziti/foundation v0.15.44 h1:+XMOMaog+ABBvxgmDhk70H0buhw2RtpeDClxk+TJ3qQ= +github.com/openziti/fabric v0.16.48 h1:tSI/5ekpCukN3qltSTM48yEHT0QopJWUrSbF13JwTuk= +github.com/openziti/fabric v0.16.48/go.mod h1:HLM9JhrqCwB1uM7DLIwA98XU8cCsQDHjs2zs4tf1ASk= github.com/openziti/foundation v0.15.44/go.mod h1:kYCUttsGO/GjoD7BSNhVOeyYDXHYMAfz59YeLoEyhHY= -github.com/openziti/sdk-golang v0.15.32 h1:Mr0kGpsP53ebBxye9kSBeVevW71xS+brVzduSjataXc= -github.com/openziti/sdk-golang v0.15.32/go.mod h1:jrvkpxP7U1ejSKEj4J9/UTNWlt6nJaofUGKkTx7afvM= +github.com/openziti/foundation v0.15.45 h1:fJDXAq/Bd2/n58MggJeFhE4IIwe0YsF+kIZcAkv664c= +github.com/openziti/foundation v0.15.45/go.mod h1:NnSBTp9ZkcYsv6nYxZR0/NzoHfkIo6tjpBHDvBsPFqw= +github.com/openziti/sdk-golang v0.15.36 h1:FBH+lAl8JFze0ZqJqKRyVQ/YAF0sXTX7f6WolcRQLCk= +github.com/openziti/sdk-golang v0.15.36/go.mod h1:i+h3rd5INCvJPBBGXTGZba5eJLznV4AHrZAa88cf6II= github.com/oracle/oci-go-sdk v24.2.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888= github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI= github.com/orcaman/concurrent-map v0.0.0-20210106121528-16402b402231 h1:fa50YL1pzKW+1SsBnJDOHppJN9stOEwS+CRWyUtyYGU= @@ -772,6 +780,9 @@ github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= github.com/vultr/govultr/v2 v2.0.0/go.mod h1:2PsEeg+gs3p/Fo5Pw8F9mv+DUBEOlrNZ8GmCTGmhOhs= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.0.2/go.mod h1:1WAq6h33pAW+iRreB34OORO2Nf7qel3VV3fjBj+hCSs= +github.com/xdg-go/stringprep v1.0.2/go.mod h1:8F9zXuvzgwmyT5DUm4GUfZGDdT3W+LCvS6+da4O5kxM= github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= @@ -781,14 +792,16 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1: github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA= go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.1.1/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= go.mongodb.org/mongo-driver v1.3.0/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= go.mongodb.org/mongo-driver v1.3.4/go.mod h1:MSWZXKOynuguX+JSvwP8i+58jYCXxbia8HS3gZBapIE= go.mongodb.org/mongo-driver v1.4.3/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= go.mongodb.org/mongo-driver v1.4.4/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= -go.mongodb.org/mongo-driver v1.4.6 h1:rh7GdYmDrb8AQSkF8yteAus8qYOgOASWDOv1BWqBXkU= go.mongodb.org/mongo-driver v1.4.6/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= +go.mongodb.org/mongo-driver v1.5.1 h1:9nOVLGDfOaZ9R0tBumx/BcuqkbFpyTCU2r/Po7A2azI= +go.mongodb.org/mongo-driver v1.5.1/go.mod h1:gRXCHX4Jo7J0IJ1oDQyUxF7jfy19UfxniMS4xxMmUqw= go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1 h1:A/5uWzF44DlIgdm/PQFwfMkW0JX+cIcQi/SwLAmZP5M= go.mozilla.org/pkcs7 v0.0.0-20200128120323-432b2356ecb1/go.mod h1:SNgMg+EgDFwmvSmLRTNKC5fegJjB7v23qTQ0XLGUNHk= go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= @@ -827,6 +840,7 @@ golang.org/x/crypto v0.0.0-20191112222119-e1110fd1c708/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20191202143827-86a70503ff7e/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200221231518-2aa609cf4a9d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -985,8 +999,9 @@ golang.org/x/sys v0.0.0-20210110051926-789bb1bd4061/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210123111255-9b0068b26619/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210216163648-f7da38b97c65/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210303074136-134d130e1a04 h1:cEhElsAv9LUt9ZUUocxzWe05oFLVd+AA2nstydTeI8g= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4 h1:EZ2mChiOa8udjfp6rRmswTbtZN/QzUQp4ptM4rnjHvc= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1116,8 +1131,10 @@ google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzi google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= gopkg.in/AlecAivazis/survey.v1 v1.8.7 h1:oBJqtgsyBLg9K5FK9twNUbcPnbCPoh+R9a+7nag3qJM= gopkg.in/AlecAivazis/survey.v1 v1.8.7/go.mod h1:iBNOmqKz/NUbZx3bA+4hAGLRC7fSK7tgtVDT4tB22XA= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= diff --git a/ziti/cmd/ziti/cmd/edge_controller/create_edge_router.go b/ziti/cmd/ziti/cmd/edge_controller/create_edge_router.go index f440525b7..ced6f6375 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/create_edge_router.go +++ b/ziti/cmd/ziti/cmd/edge_controller/create_edge_router.go @@ -33,6 +33,8 @@ type createEdgeRouterOptions struct { isTunnelerEnabled bool roleAttributes []string jwtOutputFile string + tags map[string]string + appData map[string]string } func newCreateEdgeRouterCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { @@ -62,6 +64,9 @@ func newCreateEdgeRouterCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) cmd.Flags().StringSliceVarP(&options.roleAttributes, "role-attributes", "a", nil, "Role attributes of the new edge router") cmd.Flags().BoolVarP(&options.isTunnelerEnabled, "tunneler-enabled", "t", false, "Can this edge router be used as a tunneler") cmd.Flags().StringVarP(&options.jwtOutputFile, "jwt-output-file", "o", "", "File to which to output the JWT used for enrolling the edge router") + cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags") + cmd.Flags().StringToStringVar(&options.appData, "app-Data", nil, "Custom application data") + options.AddCommonFlags(cmd) return cmd @@ -69,12 +74,14 @@ func newCreateEdgeRouterCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) // runCreateEdgeRouter implements the command to create a gateway on the edge controller func runCreateEdgeRouter(o *createEdgeRouterOptions) error { - routerData := gabs.New() - setJSONValue(routerData, o.Args[0], "name") - setJSONValue(routerData, o.isTunnelerEnabled, "isTunnelerEnabled") - setJSONValue(routerData, o.roleAttributes, "roleAttributes") + entityData := gabs.New() + setJSONValue(entityData, o.Args[0], "name") + setJSONValue(entityData, o.isTunnelerEnabled, "isTunnelerEnabled") + setJSONValue(entityData, o.roleAttributes, "roleAttributes") + setJSONValue(entityData, o.tags, "tags") + setJSONValue(entityData, o.appData, "appData") - result, err := createEntityOfType("edge-routers", routerData.String(), &o.edgeOptions) + result, err := createEntityOfType("edge-routers", entityData.String(), &o.edgeOptions) if err != nil { return err diff --git a/ziti/cmd/ziti/cmd/edge_controller/create_identity.go b/ziti/cmd/ziti/cmd/edge_controller/create_identity.go index ee8b53fc2..fc040bf6c 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/create_identity.go +++ b/ziti/cmd/ziti/cmd/edge_controller/create_identity.go @@ -18,8 +18,10 @@ package edge_controller import ( "fmt" + "github.com/pkg/errors" "io" "io/ioutil" + "math" "reflect" "strings" @@ -38,6 +40,10 @@ type createIdentityOptions struct { username string defaultHostingPrecedence string defaultHostingCost uint16 + serviceCosts map[string]int + servicePrecedences map[string]string + tags map[string]string + appData map[string]string } // newCreateIdentityCmd creates the 'edge controller create identity' command @@ -86,6 +92,10 @@ func newCreateIdentityOfTypeCmd(idType string, options *createIdentityOptions) * cmd.Flags().StringVarP(&options.jwtOutputFile, "jwt-output-file", "o", "", "File to which to output the JWT used for enrolling the identity") cmd.Flags().StringVarP(&options.defaultHostingPrecedence, "default-hosting-precedence", "p", "", "Default precedence to use when hosting services using this identity [default,required,failed]") cmd.Flags().Uint16VarP(&options.defaultHostingCost, "default-hosting-cost", "c", 0, "Default cost to use when hosting services using this identity") + cmd.Flags().StringToIntVar(&options.serviceCosts, "service-costs", map[string]int{}, "Per-service hosting costs") + cmd.Flags().StringToStringVar(&options.servicePrecedences, "service-precedences", map[string]string{}, "Per-service hosting precedences") + cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags") + cmd.Flags().StringToStringVar(&options.appData, "app-data", nil, "Custom application data") options.AddCommonFlags(cmd) @@ -105,12 +115,49 @@ func runCreateIdentity(idType string, o *createIdentityOptions) error { } setJSONValue(entityData, o.isAdmin, "isAdmin") setJSONValue(entityData, o.roleAttributes, "roleAttributes") + setJSONValue(entityData, o.tags, "tags") + setJSONValue(entityData, o.appData, "appData") if o.defaultHostingPrecedence != "" { - setJSONValue(entityData, o.defaultHostingPrecedence, "defaultHostingPrecedence") + prec, err := normalizeAndValidatePrecedence(o.defaultHostingPrecedence) + if err != nil { + return err + } + + setJSONValue(entityData, prec, "defaultHostingPrecedence") } + setJSONValue(entityData, o.defaultHostingCost, "defaultHostingCost") + for k, v := range o.serviceCosts { + if v < 0 || v > math.MaxUint16 { + return errors.Errorf("hosting costs must be in the range %v-%v", 0, math.MaxUint16) + } + id, err := mapNameToID("services", k, o.edgeOptions) + if err != nil { + return err + } + delete(o.serviceCosts, k) + o.serviceCosts[id] = v + } + setJSONValue(entityData, o.serviceCosts, "serviceHostingCosts") + + for k, v := range o.servicePrecedences { + id, err := mapNameToID("services", k, o.edgeOptions) + if err != nil { + return err + } + + prec, err := normalizeAndValidatePrecedence(v) + if err != nil { + return err + } + + delete(o.servicePrecedences, k) + o.servicePrecedences[id] = prec + } + setJSONValue(entityData, o.servicePrecedences, "serviceHostingPrecedences") + result, err := createEntityOfType("identities", entityData.String(), &o.edgeOptions) if err != nil { diff --git a/ziti/cmd/ziti/cmd/edge_controller/update_edge_router.go b/ziti/cmd/ziti/cmd/edge_controller/update_edge_router.go index 9e61b499d..a6c412d4f 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/update_edge_router.go +++ b/ziti/cmd/ziti/cmd/edge_controller/update_edge_router.go @@ -34,6 +34,8 @@ type updateEdgeRouterOptions struct { name string isTunnelerEnabled bool roleAttributes []string + tags map[string]string + appData map[string]string } func newUpdateEdgeRouterCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { @@ -63,6 +65,9 @@ func newUpdateEdgeRouterCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) cmd.Flags().BoolVarP(&options.isTunnelerEnabled, "tunneler-enabled", "t", false, "Can this edge router be used as a tunneler") cmd.Flags().StringSliceVarP(&options.roleAttributes, "role-attributes", "a", nil, "Set role attributes of the edge router. Use --role-attributes '' to set an empty list") + cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags") + cmd.Flags().StringToStringVar(&options.appData, "app-data", nil, "Custom application data") + options.AddCommonFlags(cmd) return cmd @@ -92,6 +97,16 @@ func runUpdateEdgeRouter(o *updateEdgeRouterOptions) error { change = true } + if o.Cmd.Flags().Changed("tags") { + setJSONValue(entityData, o.tags, "tags") + change = true + } + + if o.Cmd.Flags().Changed("app-data") { + setJSONValue(entityData, o.appData, "appData") + change = true + } + if !change { return errors.New("no change specified. must specify at least one attribute to change") } diff --git a/ziti/cmd/ziti/cmd/edge_controller/update_identity.go b/ziti/cmd/ziti/cmd/edge_controller/update_identity.go index c7bbf38db..68821d669 100644 --- a/ziti/cmd/ziti/cmd/edge_controller/update_identity.go +++ b/ziti/cmd/ziti/cmd/edge_controller/update_identity.go @@ -18,7 +18,10 @@ package edge_controller import ( "fmt" + "github.com/openziti/sdk-golang/ziti" "io" + "math" + "strings" "github.com/pkg/errors" @@ -31,8 +34,14 @@ import ( type updateIdentityOptions struct { edgeOptions - name string - roleAttributes []string + name string + roleAttributes []string + defaultHostingPrecedence string + defaultHostingCost uint16 + serviceCosts map[string]int + servicePrecedences map[string]string + tags map[string]string + appData map[string]string } func newUpdateIdentityCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command { @@ -62,6 +71,12 @@ func newUpdateIdentityCmd(f cmdutil.Factory, out io.Writer, errOut io.Writer) *c cmd.Flags().StringVarP(&options.name, "name", "n", "", "Set the name of the identity") cmd.Flags().StringSliceVarP(&options.roleAttributes, "role-attributes", "a", nil, "Set role attributes of the identity. Use --role-attributes '' to set an empty list") + cmd.Flags().StringVarP(&options.defaultHostingPrecedence, "default-hosting-precedence", "p", "", "Default precedence to use when hosting services using this identity [default,required,failed]") + cmd.Flags().Uint16VarP(&options.defaultHostingCost, "default-hosting-cost", "c", 0, "Default cost to use when hosting services using this identity") + cmd.Flags().StringToIntVar(&options.serviceCosts, "service-costs", map[string]int{}, "Per-service hosting costs") + cmd.Flags().StringToStringVar(&options.servicePrecedences, "service-precedences", map[string]string{}, "Per-service hosting precedences") + cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags") + cmd.Flags().StringToStringVar(&options.appData, "app-data", nil, "Custom application data") return cmd } @@ -85,6 +100,65 @@ func runUpdateIdentity(o *updateIdentityOptions) error { change = true } + if o.Cmd.Flags().Changed("defaultHostingCost") { + setJSONValue(entityData, o.defaultHostingCost, "defaultHostingCost") + change = true + } + + if o.Cmd.Flags().Changed("defaultHostingPrecedence") { + prec, err := normalizeAndValidatePrecedence(o.defaultHostingPrecedence) + if err != nil { + return err + } + setJSONValue(entityData, prec, "defaultHostingPrecedence") + change = true + } + + if o.Cmd.Flags().Changed("service-costs") { + for k, v := range o.serviceCosts { + if v < 0 || v > math.MaxUint16 { + return errors.Errorf("hosting costs must be in the range %v-%v", 0, math.MaxUint16) + } + id, err := mapNameToID("services", k, o.edgeOptions) + if err != nil { + return err + } + delete(o.serviceCosts, k) + o.serviceCosts[id] = v + } + setJSONValue(entityData, o.serviceCosts, "serviceHostingCosts") + change = true + } + + if o.Cmd.Flags().Changed("service-precedences") { + for k, v := range o.servicePrecedences { + id, err := mapNameToID("services", k, o.edgeOptions) + if err != nil { + return err + } + + prec, err := normalizeAndValidatePrecedence(v) + if err != nil { + return err + } + + delete(o.servicePrecedences, k) + o.servicePrecedences[id] = prec + } + setJSONValue(entityData, o.servicePrecedences, "serviceHostingPrecedences") + change = true + } + + if o.Cmd.Flags().Changed("tags") { + setJSONValue(entityData, o.tags, "tags") + change = true + } + + if o.Cmd.Flags().Changed("app-data") { + setJSONValue(entityData, o.appData, "appData") + change = true + } + if !change { return errors.New("no change specified. must specify at least one attribute to change") } @@ -92,3 +166,12 @@ func runUpdateIdentity(o *updateIdentityOptions) error { _, err = patchEntityOfType(fmt.Sprintf("identities/%v", id), entityData.String(), &o.edgeOptions) return err } + +func normalizeAndValidatePrecedence(val string) (string, error) { + normalized := strings.ToLower(val) + prec := ziti.GetPrecedenceForLabel(normalized) + if prec.String() != normalized { + return "", errors.Errorf("invalid precedence %v. valid valids [default, required, failed]", val) + } + return normalized, nil +} From 33a94de916660067e229dd5ed967a4b2a2417472 Mon Sep 17 00:00:00 2001 From: ziti-ci Date: Tue, 6 Apr 2021 11:55:43 -0400 Subject: [PATCH 4/4] Update awscli install --- .github/workflows/main.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 14abf628d..c56dca947 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -83,6 +83,11 @@ jobs: with: go-version: '^1.16.1' + - name: Install Python + uses: actions/setup-python@v2 + with: + python-version: '3.7' + - name: Install Ziti CI uses: netfoundry/ziti-ci@v1 @@ -91,7 +96,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | sudo apt-get -yq install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf - pip install --upgrade --user pip + python -m pip install --upgrade pip pip install awscli $(go env GOPATH)/bin/ziti-ci configure-git $(go env GOPATH)/bin/ziti-ci generate-build-info common/version/info_generated.go version