Merge pull request #838 from openziti/release-next

Release 0.26.8
This commit is contained in:
Paul Lorenz
2022-09-19 10:19:09 -04:00
committed by GitHub
17 changed files with 560 additions and 79 deletions
+224
View File
@@ -1,3 +1,227 @@
# Release 0.26.8
## What's New
- General
- Allow filtering model entities by tag
- Fabric
- Usage v3 metrics
- Edge
- Bug Fixes
- Ziti CLI
- `ziti edge create|update ca` now supports `externalIdClaim`
- Improved List CAs
- Identity
- Automatic File Reloads
## General
Model entities can now be filtered by tags. This works via the fabric and edge REST APIs and can be
used from the `ziti` CLI.
Example:
```
$ ziti edge update service demo --tags location=PA
$ ziti edge update service echo --tags location=NY
$ ziti edge ls services 'limit 4'
╭────────────────────────┬──────────────┬────────────┬─────────────────────┬────────────╮
│ ID │ NAME │ ENCRYPTION │ TERMINATOR STRATEGY │ ATTRIBUTES │
│ │ │ REQUIRED │ │ │
├────────────────────────┼──────────────┼────────────┼─────────────────────┼────────────┤
│ 1WztJ.YuMY │ demo │ true │ smartrouting │ │
│ 68kYZOS54kAbU4hEhKHgHT │ echo │ true │ smartrouting │ echo │
│ EjaiJkYuMY │ project.mgmt │ true │ smartrouting │ │
│ F0JVJkY40Y │ mattermost │ true │ smartrouting │ │
╰────────────────────────┴──────────────┴────────────┴─────────────────────┴────────────╯
results: 1-4 of 13
$ ziti edge ls services 'tags.location != null'
╭────────────────────────┬──────┬────────────┬─────────────────────┬────────────╮
│ ID │ NAME │ ENCRYPTION │ TERMINATOR STRATEGY │ ATTRIBUTES │
│ │ │ REQUIRED │ │ │
├────────────────────────┼──────┼────────────┼─────────────────────┼────────────┤
│ 1WztJ.YuMY │ demo │ true │ smartrouting │ │
│ 68kYZOS54kAbU4hEhKHgHT │ echo │ true │ smartrouting │ echo │
╰────────────────────────┴──────┴────────────┴─────────────────────┴────────────╯
results: 1-2 of 2
$ ziti edge ls services 'tags.location = "NY"'
╭────────────────────────┬──────┬────────────┬─────────────────────┬────────────╮
│ ID │ NAME │ ENCRYPTION │ TERMINATOR STRATEGY │ ATTRIBUTES │
│ │ │ REQUIRED │ │ │
├────────────────────────┼──────┼────────────┼─────────────────────┼────────────┤
│ 68kYZOS54kAbU4hEhKHgHT │ echo │ true │ smartrouting │ echo │
╰────────────────────────┴──────┴────────────┴─────────────────────┴────────────╯
results: 1-1 of 1
```
## Fabric
### Usage v3
This a new version of usage events available. The existing v2 version events can still be used. The version
is selected in the events configuration.
Here is a config showing how to get both sets of events:
```
events:
jsonLogger:
subscriptions:
- type: fabric.usage
version: 2
- type: fabric.usage
versin: 3
```
If no version is provided for usage, then v2 events will still be outputted by default.
### Event Consolidation
V3 events consolidate multiple usage metrics together to minimize the number of events.
Example:
```
{
"namespace": "fabric.usage",
"version": 3,
"source_id": "cjc.1kYu0",
"circuit_id": "CwbENl.lW",
"usage": {
"egress.rx": 47,
"egress.tx": 47
},
"interval_start_utc": 1663342500,
"interval_length": 60,
"tags": {
"clientId": "XtYOStBYgd",
"hostId": "f3ltEI8Iok",
"serviceId": "fclVFecdgakAoHyBvtIGy"
}
}
```
Ingress and egress usage for a given circuit will consolidated into a single event per router. Fabric usage
will also be consolided into a single, separate event.
### Event tagging
Usage events for ingress and egress usage will be annotated with edge information for both v2 and v3.
In the example above the event has tags for `clientId`, `hostId` and `serviceId`.
* `clientId` - The id of the edge identity using the service
* `hostId` - The id of the edge identity hosting the service (will be blank if not applicable, such as for router hosted)
* `serviceId` - The id of the service being used
## Edge
### Bug Fixes
* [Issue 1176](https://github.com/openziti/edge/issues/1176): Patching CA `externalIdClaim` Does Not Work
## Ziti CLI
### `ziti edge create|update ca` now support `externalIdClaim
Identities now have a field named `externalId` that can be used with 3rd Party CAs in addition to the existing
External JWT Signer support. 3rd Party CAs now support the following optional fields:
- `externalIdClaim.index` - if multiple externalId claims are located, the index will be used to select one, default 0
- `externalIdClaim.location` - extracts values from one of the following locations on a x509 certificate: `SAN_URI`, `SAN_EMAIL`, `COMMON_NAME`
- `externalIdClaim.matcher` - matches values in one of the following ways `PREFIX`, `SUFFIX`, `SCHEME` in conjunction with `matcherCriteria` or select all values via `ALL`
- `externalIdClaim.matcherCriteria` - `matcher` values of `PREFIX`, `SUFFIX`, and `SCHEME` will use `matcherCriteria` as a matching value
- `externalIdClaim.parser`: - supports parsing values from all matched externalIds via `SPLIT` or `NONE`
- `externalIdClaim.parserCriteria` - for a `parser` value of `SPLIT`, `parserCriteria` will be used to split values
When defined the `externalIdClaim` configuration will be used to locate any `externalId`s present in the client
supplied x509 certificate. If an `externalId` is located, it will be used to associate the authentication request
with an identity. If found, authentication is considered successful if not the authentication request fails. If the
client certificate does not contain an `externalId` then identities will be searched for that have a certificate
authenticator that matches the supplied client certificate. Should that fail, the authentication request fails.
This functionality can be used to support SPIFFE provisioned identities. For any specific SPIFFE ID, assign it to an
identity's `externalId` and then use the following `externalIdClaim` configurations.
#### CA Create/Update REST API
```json
{
...
"externalIdClaim": {
"location": "SAN_URI",
"index": 0,
"matcher": "SCHEME",
"matcherCriteria": "spiffe",
"parser": "NONE",
"parserCriteria": ""
}
}
```
#### Ziti CLI
```
ziti edge create ca myCa ca.pem -l SAN_URI -m SCHEME -x spiffe -p "NONE"
```
```
ziti edge update ca myCa -l SAN_URI -m SCHEME -x spiffe -p "NONE"
```
### Improved List CAs Output
The output for listing CAs in non-JSON format has been improved.
Example:
```text
╭────────────────────────┬─────────┬────────┬────────────┬─────────────┬─────────────────────────────────────────────────────────────────╮
│ ID │ NAME │ FLAGS │ TOKEN │ FINGERPRINT │ CONFIGURATION │
├────────────────────────┼─────────┼────────┼────────────┼─────────────┼─────────────────┬──────────────────────┬────────────────────────┤
│ 1tu6CbXT18Dd9rybjCW5eX │ 2 │ [AOE] │ KaPxRiKbk │ - │ AutoCA │ Identity Name Format │ [caName]-[commonName] │
│ │ │ │ │ │ ├──────────────────────┼────────────────────────┤
│ │ │ │ │ │ │ Identity Roles │ a,b,c │
│ │ │ │ │ ├─────────────────┼──────────────────────┼────────────────────────┤
│ │ │ │ │ │ ExternalIdClaim │ Index │ 2 │
│ │ │ │ │ │ ├──────────────────────┼────────────────────────┤
│ │ │ │ │ │ │ Location │ SAN_URI │
│ │ │ │ │ │ ├──────────────────────┼────────────────────────┤
│ │ │ │ │ │ │ Matcher │ ALL │
│ │ │ │ │ │ ├──────────────────────┼────────────────────────┤
│ │ │ │ │ │ │ Matcher Criteria │ │
│ │ │ │ │ │ ├──────────────────────┼────────────────────────┤
│ │ │ │ │ │ │ Parser │ NONE │
│ │ │ │ │ │ ├──────────────────────┼────────────────────────┤
│ │ │ │ │ │ │ Parser Criteria │ │
├────────────────────────┼─────────┼────────┼────────────┼─────────────┼─────────────────┼──────────────────────┼────────────────────────┤
│ 7AGp9vUttJHKA1JWujNtpR │ test-ca │ [VAOE] │ - │ 315e...ba │ AutoCA │ Identity Name Format │ [caName]-[commonName] │
│ │ │ │ │ │ ├──────────────────────┼────────────────────────┤
│ │ │ │ │ │ │ Identity Roles │ three, two,one │
╰────────────────────────┴─────────┴────────┴────────────┴─────────────┴─────────────────┴──────────────────────┴────────────────────────╯
```
## Ziti Library Updates
* github.com/openziti/channel: [v1.0.2 -> v1.0.3](https://github.com/openziti/channel/compare/v1.0.2...v1.0.3)
* github.com/openziti/edge: [v0.22.91 -> v0.23.0](https://github.com/openziti/edge/compare/v0.22.91...v0.23.0)
* [Issue #1173](https://github.com/openziti/edge/issues/1173) - Add session_type and service_id to edge session events
* [Issue #1176](https://github.com/openziti/edge/issues/1176) - Patching CA ExternalIdClaim Does Not Work
* [Issue #1174](https://github.com/openziti/edge/issues/1174) - Fix patching tags on services and transit routers
* [Issue #1154](https://github.com/openziti/edge/issues/1154) - Additional filters for service list endpoint
* github.com/openziti/fabric: [v0.19.67 -> v0.20.0](https://github.com/openziti/fabric/compare/v0.19.67...v0.20.0)
* [Issue #496](https://github.com/openziti/fabric/issues/496) - Reduce utiliztion messages by combining directionality
* [Issue #499](https://github.com/openziti/fabric/issues/499) - Fix tag patching tags on service and router
* github.com/openziti/identity: [v1.0.11 -> v1.0.12](https://github.com/openziti/identity/compare/v1.0.11...v1.0.12)
* github.com/openziti/metrics: [v1.0.7 -> v1.1.0](https://github.com/openziti/metrics/compare/v1.0.7...v1.1.0)
* [Issue #15](https://github.com/openziti/metrics/issues/15) - Support tags and multiple values on usage
* github.com/openziti/sdk-golang: [v0.16.119 -> v0.16.121](https://github.com/openziti/sdk-golang/compare/v0.16.119...v0.16.121)
* github.com/openziti/storage: [v0.1.20 -> v0.1.21](https://github.com/openziti/storage/compare/v0.1.20...v0.1.21)
* [Issue #21](https://github.com/openziti/storage/issues/21) - Support querying tags by default
* github.com/openziti/transport/v2: [v2.0.28 -> v2.0.29](https://github.com/openziti/transport/compare/v2.0.28...v2.0.29)
* github.com/openziti/ziti: [0.26.7 -> 0.26.8](https://github.com/openziti/ziti/compare/0.26.7...0.26.8)
* [Issue #835](https://github.com/openziti/ziti/issues/835) - Ensure model entity tags can be updated via CLI where appropriate
# Release 0.26.7
## What's New
+10 -10
View File
@@ -23,15 +23,15 @@ require (
github.com/keybase/go-ps v0.0.0-20190827175125-91aafc93ba19
github.com/michaelquigley/pfxlog v0.6.9
github.com/openziti/agent v1.0.3
github.com/openziti/channel v1.0.2
github.com/openziti/edge v0.22.91
github.com/openziti/fabric v0.19.67
github.com/openziti/channel v1.0.3
github.com/openziti/edge v0.23.0
github.com/openziti/fabric v0.20.0
github.com/openziti/foundation/v2 v2.0.4
github.com/openziti/identity v1.0.11
github.com/openziti/metrics v1.0.7
github.com/openziti/sdk-golang v0.16.119
github.com/openziti/storage v0.1.20
github.com/openziti/transport/v2 v2.0.28
github.com/openziti/identity v1.0.12
github.com/openziti/metrics v1.1.0
github.com/openziti/sdk-golang v0.16.121
github.com/openziti/storage v0.1.21
github.com/openziti/transport/v2 v2.0.29
github.com/openziti/xweb/v2 v2.0.2
github.com/openziti/ziti-db-explorer v1.1.1
github.com/pborman/uuid v1.2.0
@@ -78,7 +78,7 @@ require (
github.com/eliukblau/pixterm/pkg/ansimage v0.0.0-20191210081756-9fb6cf8c2f75 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/felixge/httpsnoop v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-openapi/analysis v0.21.4 // indirect
github.com/go-openapi/errors v0.20.3 // indirect
@@ -161,7 +161,7 @@ require (
golang.org/x/image v0.0.0-20191206065243-da761ea9ff43 // indirect
golang.org/x/mod v0.5.1 // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2 // indirect
golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 // indirect
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/tools v0.1.7 // indirect
+21 -20
View File
@@ -230,8 +230,8 @@ github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHqu
github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI=
github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU=
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa h1:RDBNVkRviHZtvDvId8XSGPu3rmpmSe+wKRcEWNgsfWU=
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa/go.mod h1:KnogPXtdwXqoenmZCw6S+25EAm2MkxbG0deNDu4cbSA=
github.com/getkin/kin-openapi v0.13.0/go.mod h1:WGRs2ZMM1Q8LR1QBEwUxC6RJEfaBcD0s+pcEVXFuAjw=
@@ -675,28 +675,28 @@ github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTm
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
github.com/openziti/agent v1.0.3 h1:FtVIl5vu+xk0uwlXTqWnGHp7RqSFAzuBa1YuCPZkTsk=
github.com/openziti/agent v1.0.3/go.mod h1:k9gQv82hTTxdVSfMmD0LyWzCEy+9fWh2ISsg1llgRqU=
github.com/openziti/channel v1.0.2 h1:hNnmIHDb3RY7B0wX9TOn+XqObjfoTPWDBNjTa42nvxA=
github.com/openziti/channel v1.0.2/go.mod h1:vb2IonzG4uLmFj7UTIHTKViI2W8tHE+skFTeynZ+hJE=
github.com/openziti/channel v1.0.3 h1:WlM3DYTWxfGslct1jnUUgOHbm0wYS1LRCVwdfx8mBzU=
github.com/openziti/channel v1.0.3/go.mod h1:/te3/V0rq3r9hM0JIAlL8dlg+SynzkVE7uL6ntaYlik=
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.22.91 h1:/55k3noqvY5CYJlY8ySC17Q2mEcI5/nbj1/6+HS7EA0=
github.com/openziti/edge v0.22.91/go.mod h1:GE3iyHd1VCY7NU10RQaFSTWi+9GrDN84eyarWAIzW7A=
github.com/openziti/fabric v0.19.67 h1:rH2EEwo6y7th0HXdjhkHJeIYq8il6Z3Fu/5Qh2icSZ8=
github.com/openziti/fabric v0.19.67/go.mod h1:xYVUbDJA1NZae+Wpo5Lc1N1XF+cnLnqaYwi+KiEXUMs=
github.com/openziti/edge v0.23.0 h1:B5z5MPvtBV6TE6818rSyOodzdkz9bT0l64Fw2QMg/gQ=
github.com/openziti/edge v0.23.0/go.mod h1:+gCC6YBEs9eiKL0buzN+AydDbIvfRChIVNuntRMvBBo=
github.com/openziti/fabric v0.20.0 h1:kWE3Lb8xLS3Rcwwmzh4Jb0bSjgubcll7+ntx0mO76no=
github.com/openziti/fabric v0.20.0/go.mod h1:zJnnBUS8eXELmrBIyOi4x/Wyo2mslQ47+cqpAmmuJyY=
github.com/openziti/foundation/v2 v2.0.4 h1:QnpbNgRzPTnbu/QIqdNhYJl4nrhxrX7VXiIF5yIqQhc=
github.com/openziti/foundation/v2 v2.0.4/go.mod h1:L75kwCC5WTUPqxuAd3G+WMBompaElMb/nYlJjR1sJ9Q=
github.com/openziti/identity v1.0.11 h1:66tdzw5gillevcTNXZGbLxB03d/l2KTGbS4mrDJg7WY=
github.com/openziti/identity v1.0.11/go.mod h1:ScEYhB5F5FfBmTEHmfATBlbzMIpMJwDF8CcJbNuO5ic=
github.com/openziti/identity v1.0.12 h1:Y6adirthFBpMSI0fyWWGR/fUFtaMOIWQIvyr2yTeIcM=
github.com/openziti/identity v1.0.12/go.mod h1:ScEYhB5F5FfBmTEHmfATBlbzMIpMJwDF8CcJbNuO5ic=
github.com/openziti/jwks v1.0.1 h1:+BtBzDWFVUlJfCbBhQR0BZI3YNtoBvfhfdCUSSB0G+0=
github.com/openziti/jwks v1.0.1/go.mod h1:KwO0x9FBG0aoJS5f6nH5xeHoplyR1H143SMI9kF0mC8=
github.com/openziti/metrics v1.0.7 h1:gI1Vk2HIPUwIgS42bZJ0MZx+ATfIU1Pnv5troch8R5c=
github.com/openziti/metrics v1.0.7/go.mod h1:x+2e9YQyZjf94KFWW3rr9hx+agfk50kP53vMP/6eMzo=
github.com/openziti/sdk-golang v0.16.119 h1:B51X/3/qpSNYJIF9D903nvPVR0suGw/fZvw6aNzF/bo=
github.com/openziti/sdk-golang v0.16.119/go.mod h1:ln61i+bB/Qy8IsjDzu8iw8V//PFefCY9UuhCsz60fPk=
github.com/openziti/storage v0.1.20 h1:6wYIwtNeymni4bVSznelVQ4WIkSPzYjh6ybIO704QVY=
github.com/openziti/storage v0.1.20/go.mod h1:onJ7mLnnB2nfKdNCJHZlVRnPZSSPUJvuu3gzZ8vR2Mo=
github.com/openziti/transport/v2 v2.0.28 h1:ptfqproXYToJR2QncsbdlRjHh7OGBlo2Jgmk+dFpNsc=
github.com/openziti/transport/v2 v2.0.28/go.mod h1:I0JnNq899+rwArGlSq9sVqCCD5c805FUv0VQgFhWNYI=
github.com/openziti/metrics v1.1.0 h1:V3stVSxGz0Rq3GXxQz+ahMH8D3jR8yVT+IrJZNWdFxA=
github.com/openziti/metrics v1.1.0/go.mod h1:N3ffH3Vp7czCpyDSk1hFE3DZ3bTEUSiubHWHZFUuP2g=
github.com/openziti/sdk-golang v0.16.121 h1:fhjkrUnQZxC3hz9pR6zN2jkTmnzEyv8AGNyQlI1QQZU=
github.com/openziti/sdk-golang v0.16.121/go.mod h1:cdv9FOrj3XuOQR/B54OrUwaAvrd1Wwpbl1KxwJvTC2k=
github.com/openziti/storage v0.1.21 h1:m8ny8AuCqjZQRpiHUhQlmZjUGAW1LCRjrPA93WQsjP0=
github.com/openziti/storage v0.1.21/go.mod h1:onJ7mLnnB2nfKdNCJHZlVRnPZSSPUJvuu3gzZ8vR2Mo=
github.com/openziti/transport/v2 v2.0.29 h1:lT9FyDUF3bxkMYjFACW909LSc7sonLK86ghRDXN05Ug=
github.com/openziti/transport/v2 v2.0.29/go.mod h1:vYXp00wBXxq3s5ffSJEfkscOBH2+/d29FK1l7yMid4g=
github.com/openziti/x509-claims v1.0.2 h1:PSv/xRfejIAcPc16A902k08rSBs3R8bjtL4qq6WEwCI=
github.com/openziti/x509-claims v1.0.2/go.mod h1:Z0WIpBm6c4ecrpRKrou6Gk2wrLWxJO/+tuUwKh8VewE=
github.com/openziti/xweb/v2 v2.0.2 h1:XYlVFriTq/U1wcUrc+XPnWJGhXh9NJPhtQ7+r3aC0cU=
@@ -1189,12 +1189,13 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2 h1:wM1k/lXfpc5HdkJJyW9GELpd8ERGdnh8sMGL6Gzq3Ho=
golang.org/x/sys v0.0.0-20220909162455-aba9fc2a8ff2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41 h1:ohgcoMbSofXygzo6AD2I1kz3BFmW1QArPYTtwEM3UXc=
golang.org/x/sys v0.0.0-20220915200043-7b5979e65e41/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
+94 -34
View File
@@ -18,26 +18,22 @@ package edge
import (
"fmt"
"github.com/Jeffail/gabs"
"github.com/openziti/edge/rest_management_api_client/certificate_authority"
"github.com/openziti/edge/rest_model"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/common"
cmdhelper "github.com/openziti/ziti/ziti/cmd/ziti/cmd/helpers"
"github.com/openziti/ziti/ziti/cmd/ziti/util"
"github.com/spf13/cobra"
"io"
"io/ioutil"
"os"
)
type createCaOptions struct {
api.Options
tags map[string]string
name string
caPath string
caPemBytes []byte
autoCaEnrollment bool
ottCaEnrollment bool
authEnabled bool
identityRoles []string
identityNameFormat string
Ca rest_model.CaCreate
TagsFromFlags map[string]string
IdentityRolesFromFlags []string
}
// newCreateCaCmd creates the 'edge controller create ca local' command for the given entity type
@@ -49,7 +45,27 @@ func newCreateCaCmd(out io.Writer, errOut io.Writer) *cobra.Command {
Err: errOut,
},
},
tags: make(map[string]string),
Ca: rest_model.CaCreate{
CertPem: S(""),
ExternalIDClaim: &rest_model.ExternalIDClaim{
Index: I64(0),
Location: S(""),
Matcher: S(""),
MatcherCriteria: S(""),
Parser: S(""),
ParserCriteria: S(""),
},
IdentityNameFormat: "",
IdentityRoles: []string{},
IsAuthEnabled: B(false),
IsAutoCaEnrollmentEnabled: B(false),
IsOttCaEnrollmentEnabled: B(false),
Name: S(""),
Tags: &rest_model.Tags{
SubTags: map[string]interface{}{},
},
},
TagsFromFlags: map[string]string{},
}
cmd := &cobra.Command{
@@ -61,11 +77,13 @@ func newCreateCaCmd(out io.Writer, errOut io.Writer) *cobra.Command {
return fmt.Errorf("requires at least %d arg(s), only received %d", 2, len(args))
}
options.name = args[0]
options.caPath = args[1]
options.Ca.Name = &args[0]
var err error
options.caPemBytes, err = ioutil.ReadFile(options.caPath)
caFile := args[1]
pemBytes, err := os.ReadFile(caFile)
options.Ca.CertPem = S(string(pemBytes))
if err != nil {
return fmt.Errorf("could not read CA certificate file: %s", err)
@@ -85,30 +103,72 @@ func newCreateCaCmd(out io.Writer, errOut io.Writer) *cobra.Command {
// allow interspersing positional args and flags
cmd.Flags().SetInterspersed(true)
cmd.Flags().StringToStringVarP(&options.tags, "tags", "t", nil, "Add tags to service definition")
cmd.Flags().BoolVarP(&options.authEnabled, "auth", "e", false, "Whether the CA can be used for authentication or not")
cmd.Flags().BoolVarP(&options.ottCaEnrollment, "ottca", "o", false, "Whether the CA can be used for one-time-token CA enrollment")
cmd.Flags().BoolVarP(&options.autoCaEnrollment, "autoca", "u", false, "Whether the CA can be used for auto CA enrollment")
cmd.Flags().StringSliceVarP(&options.identityRoles, "role-attributes", "a", []string{}, "A csv string of role attributes enrolling identities receive")
cmd.Flags().StringVarP(&options.identityNameFormat, "identity-name-format", "f", "", "The naming format to use for identities enrolling via the CA")
cmd.Flags().StringToStringVarP(&options.TagsFromFlags, "tags", "t", nil, "Add tags to service definition")
cmd.Flags().BoolVarP(options.Ca.IsAuthEnabled, "auth", "e", false, "Whether the CA can be used for authentication or not")
cmd.Flags().BoolVarP(options.Ca.IsOttCaEnrollmentEnabled, "ottca", "o", false, "Whether the CA can be used for one-time-token CA enrollment")
cmd.Flags().BoolVarP(options.Ca.IsAutoCaEnrollmentEnabled, "autoca", "u", false, "Whether the CA can be used for auto CA enrollment")
cmd.Flags().StringSliceVarP(&options.IdentityRolesFromFlags, "role-attributes", "a", []string{}, "A csv string of role attributes enrolling identities receive")
cmd.Flags().StringVarP(&options.Ca.IdentityNameFormat, "identity-name-format", "f", "", "The naming format to use for identities enrolling via the CA")
//ExternalIdClaim
cmd.Flags().Int64VarP(options.Ca.ExternalIDClaim.Index, "index", "d", 0, "the index to use if multiple external ids are found, default 0")
cmd.Flags().StringVarP(options.Ca.ExternalIDClaim.Location, "location", "l", "", "the location to search for external ids")
cmd.Flags().StringVarP(options.Ca.ExternalIDClaim.Matcher, "matcher", "m", "", "the matcher to use at the given location")
cmd.Flags().StringVarP(options.Ca.ExternalIDClaim.MatcherCriteria, "matcher-criteria", "x", "", "criteria used with the given matcher")
cmd.Flags().StringVarP(options.Ca.ExternalIDClaim.Parser, "parser", "p", "", "the parser to use on found external ids")
cmd.Flags().StringVarP(options.Ca.ExternalIDClaim.ParserCriteria, "parser-criteria", "z", "", "criteria used with the given parser")
options.AddCommonFlags(cmd)
return cmd
}
func runCreateCa(options *createCaOptions) (err error) {
data := gabs.New()
api.SetJSONValue(data, options.name, "name")
api.SetJSONValue(data, options.autoCaEnrollment, "isAutoCaEnrollmentEnabled")
api.SetJSONValue(data, options.ottCaEnrollment, "isOttCaEnrollmentEnabled")
api.SetJSONValue(data, options.authEnabled, "isAuthEnabled")
api.SetJSONValue(data, string(options.caPemBytes), "certPem")
api.SetJSONValue(data, options.identityRoles, "identityRoles")
func S(s string) *string {
return &s
}
if options.Cmd.Flag("identity-name-format").Changed {
api.SetJSONValue(data, options.identityNameFormat, "identityNameFormat")
func B(b bool) *bool {
return &b
}
func I64(i int64) *int64 {
return &i
}
func runCreateCa(options *createCaOptions) (err error) {
managementClient, err := util.NewEdgeManagementClient(options)
if err != nil {
return err
}
result, err := CreateEntityOfType("cas", data.String(), &options.Options)
return options.LogCreateResult("ca", result, err)
params := certificate_authority.NewCreateCaParams()
params.Ca = &options.Ca
for _, attr := range options.IdentityRolesFromFlags {
params.Ca.IdentityRoles = append(params.Ca.IdentityRoles, attr)
}
for k, v := range options.TagsFromFlags {
params.Ca.Tags.SubTags[k] = v
}
//clear external id claims if location is not set
if params.Ca.ExternalIDClaim.Location == nil || *params.Ca.ExternalIDClaim.Location == "" {
params.Ca.ExternalIDClaim = nil
}
resp, err := managementClient.CertificateAuthority.CreateCa(params, nil)
if err != nil {
return util.WrapIfApiError(err)
}
checkId := resp.GetPayload().Data.ID
if _, err = fmt.Fprintf(options.Out, "%v\n", checkId); err != nil {
panic(err)
}
return err
}
+64 -13
View File
@@ -1050,8 +1050,8 @@ func outputPostureChecks(options *api.Options, children []*gabs.Container, pagin
return nil
}
func runListCAs(o *api.Options) error {
client, err := util.NewEdgeManagementClient(o)
func runListCAs(options *api.Options) error {
client, err := util.NewEdgeManagementClient(options)
if err != nil {
return err
@@ -1059,11 +1059,11 @@ func runListCAs(o *api.Options) error {
var filter *string = nil
if len(o.Args) > 0 {
filter = &o.Args[0]
if len(options.Args) > 0 {
filter = &options.Args[0]
}
context, cancelContext := o.TimeoutContext()
context, cancelContext := options.TimeoutContext()
defer cancelContext()
result, err := client.CertificateAuthority.ListCas(&certificate_authority.ListCasParams{
@@ -1075,7 +1075,7 @@ func runListCAs(o *api.Options) error {
return util.WrapIfApiError(err)
}
if o.OutputJSONResponse {
if options.OutputJSONResponse {
return nil
}
@@ -1085,7 +1085,26 @@ func runListCAs(o *api.Options) error {
return errors.New("unexpected empty response payload")
}
for _, entity := range result.GetPayload().Data {
outTable := table.NewWriter()
outTable.SetStyle(table.StyleRounded)
outTable.Style().Options.SeparateRows = true
rowConfigAutoMerge := table.RowConfig{AutoMerge: true, AutoMergeAlign: text.AlignLeft}
outTable.AppendHeader(table.Row{"ID", "Name", "Flags", "Token", "Fingerprint", "Configuration", "Configuration", "Configuration"}, rowConfigAutoMerge)
outTable.SetColumnConfigs([]table.ColumnConfig{
{Number: 1, AutoMerge: true, Align: text.AlignLeft},
{Number: 2, AutoMerge: true, Align: text.AlignLeft},
{Number: 3, AutoMerge: true, WidthMax: 20, WidthMaxEnforcer: WrapHardEllipses, Align: text.AlignLeft},
{Number: 4, AutoMerge: true, WidthMax: 20, WidthMaxEnforcer: WrapHardEllipses, Align: text.AlignLeft},
{Number: 5, AutoMerge: true, WidthMax: 20, WidthMaxEnforcer: WrapHardEllipses, Align: text.AlignLeft},
{Number: 6, AutoMerge: true, WidthMax: 20, WidthMaxEnforcer: WrapHardEllipses, Align: text.AlignLeft},
{Number: 7, WidthMax: 50, WidthMaxEnforcer: WrapHardEllipses, Align: text.AlignLeft},
{Number: 8, WidthMax: 50, WidthMaxEnforcer: WrapHardEllipses, Align: text.AlignLeft},
})
for i, entity := range result.GetPayload().Data {
id := *entity.ID
name := *entity.Name
identityRoles := make([]string, 0)
@@ -1125,21 +1144,53 @@ func runListCAs(o *api.Options) error {
flags = "[" + flags + "]"
if _, err := fmt.Fprintf(o.Out, "id: %v name: %v token: %v identityRoles: %v flags: %s identityNameFormat: %v fingerprint: %v\n",
id, name, token, identityRoles, flags, identityNameFormat, getEllipsesString(fingerprint, 4, 2),
); err != nil {
return err
identityRolesStr := strings.Join(identityRoles, ",")
shortFingerprint := getEllipsesString(fingerprint, 4, 2)
if token == "" {
token = "-"
}
if shortFingerprint == "" {
shortFingerprint = "-"
}
if i%2 == 0 {
flags = flags + " "
token = token + " "
identityNameFormat = identityNameFormat + " "
identityRolesStr = identityRolesStr + " "
shortFingerprint = shortFingerprint + " "
}
outTable.AppendRow(table.Row{id, name, flags, token, shortFingerprint, "AutoCA", "Identity Name Format", identityNameFormat})
outTable.AppendRow(table.Row{id, name, flags, token, shortFingerprint, "AutoCA", "Identity Roles", identityRolesStr})
if entity.ExternalIDClaim != nil {
outTable.AppendRow(table.Row{id, name, flags, token, shortFingerprint, "ExternalIdClaim", "Index", int64OrDefault(entity.ExternalIDClaim.Index)})
outTable.AppendRow(table.Row{id, name, flags, token, shortFingerprint, "ExternalIdClaim", "Location", stringz.OrEmpty(entity.ExternalIDClaim.Location)})
outTable.AppendRow(table.Row{id, name, flags, token, shortFingerprint, "ExternalIdClaim", "Matcher", stringz.OrEmpty(entity.ExternalIDClaim.Matcher)})
outTable.AppendRow(table.Row{id, name, flags, token, shortFingerprint, "ExternalIdClaim", "Matcher Criteria", stringz.OrEmpty(entity.ExternalIDClaim.MatcherCriteria)})
outTable.AppendRow(table.Row{id, name, flags, token, shortFingerprint, "ExternalIdClaim", "Parser", stringz.OrEmpty(entity.ExternalIDClaim.Parser)})
outTable.AppendRow(table.Row{id, name, flags, token, shortFingerprint, "ExternalIdClaim", "Parser Criteria", stringz.OrEmpty(entity.ExternalIDClaim.ParserCriteria)})
}
}
pagingInfo := newPagingInfo(payload.Meta)
pagingInfo.Output(o)
api.RenderTable(options, outTable, pagingInfo)
_, _ = fmt.Fprint(o.Out, "\nFlags: (V) Verified, (A) AutoCa Enrollment, (O) OttCA Enrollment, (E) Authentication Enabled\n\n")
_, _ = fmt.Fprint(options.Out, "\nFlags: (V) Verified, (A) AutoCa Enrollment, (O) OttCA Enrollment, (E) Authentication Enabled\n\n")
return nil
}
func int64OrDefault(i *int64) int64 {
if i == nil {
return 0
}
return *i
}
func runListConfigTypes(o *api.Options) error {
children, pagingInfo, err := listEntitiesWithOptions("config-types", o)
if err != nil {
+61
View File
@@ -43,6 +43,9 @@ type updateCaOptions struct {
authEnabled bool
identityAttributes []string
identityNameFormat string
tags map[string]string
externalIDClaim rest_model.ExternalIDClaimPatch
}
// newUpdateAuthenticatorCmd creates the 'edge controller update authenticator' command
@@ -53,6 +56,14 @@ func newUpdateCaCmd(out io.Writer, errOut io.Writer) *cobra.Command {
OutputJSONResponse: false,
},
verify: false,
externalIDClaim: rest_model.ExternalIDClaimPatch{
Index: I64(0),
Location: S(""),
Matcher: S(""),
MatcherCriteria: S(""),
Parser: S(""),
ParserCriteria: S(""),
},
}
cmd := &cobra.Command{
@@ -106,6 +117,15 @@ func newUpdateCaCmd(out io.Writer, errOut io.Writer) *cobra.Command {
cmd.Flags().BoolVarP(&options.autoCaEnrollment, "autoca", "u", false, "Whether the CA can be used for auto CA enrollment")
cmd.Flags().StringSliceVarP(&options.identityAttributes, "identity-attributes", "a", nil, "The roles to give to identities enrolled via the CA")
cmd.Flags().StringVarP(&options.identityNameFormat, "identity-name-format", "f", "", "The naming format to use for identities enrolling via the CA")
cmd.Flags().Int64VarP(options.externalIDClaim.Index, "index", "d", 0, "the index to use if multiple external ids are found, default 0")
cmd.Flags().StringVarP(options.externalIDClaim.Location, "location", "l", "", "the location to search for external ids")
cmd.Flags().StringVarP(options.externalIDClaim.Matcher, "matcher", "m", "", "the matcher to use at the given location")
cmd.Flags().StringVarP(options.externalIDClaim.MatcherCriteria, "matcher-criteria", "x", "", "criteria used with the given matcher")
cmd.Flags().StringVarP(options.externalIDClaim.Parser, "parser", "p", "", "the parser to use on found external ids")
cmd.Flags().StringVarP(options.externalIDClaim.ParserCriteria, "parser-criteria", "z", "", "criteria used with the given parser")
cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags")
options.AddCommonFlags(cmd)
return cmd
}
@@ -160,6 +180,47 @@ func runUpdateCa(options updateCaOptions) error {
changed = true
}
ca.ExternalIDClaim = &rest_model.ExternalIDClaimPatch{}
if options.Cmd.Flag("location").Changed {
ca.ExternalIDClaim.Location = options.externalIDClaim.Location
changed = true
}
if options.Cmd.Flag("index").Changed {
ca.ExternalIDClaim.Index = options.externalIDClaim.Index
changed = true
}
if options.Cmd.Flag("matcher").Changed {
ca.ExternalIDClaim.Matcher = options.externalIDClaim.Matcher
changed = true
}
if options.Cmd.Flag("matcher-criteria").Changed {
ca.ExternalIDClaim.MatcherCriteria = options.externalIDClaim.MatcherCriteria
changed = true
}
if options.Cmd.Flag("parser").Changed {
ca.ExternalIDClaim.Parser = options.externalIDClaim.Parser
changed = true
}
if options.Cmd.Flag("parser-criteria").Changed {
ca.ExternalIDClaim.ParserCriteria = options.externalIDClaim.ParserCriteria
changed = true
}
if options.Cmd.Flags().Changed("tags") {
ca.Tags = &rest_model.Tags{
SubTags: rest_model.SubTags{},
}
for k, v := range options.tags {
ca.Tags.SubTags[k] = v
}
changed = true
}
if !changed {
return errors.New("no values changed")
}
+8
View File
@@ -36,6 +36,7 @@ type updateConfigOptions struct {
name string
data string
jsonFile string
tags map[string]string
}
// newUpdateConfigCmd updates the 'edge controller update service-policy' command
@@ -65,6 +66,8 @@ func newUpdateConfigCmd(out io.Writer, errOut io.Writer) *cobra.Command {
cmd.Flags().StringVarP(&options.name, "name", "n", "", "Set the name of the config")
cmd.Flags().StringVarP(&options.data, "data", "d", "", "Set the data of the config")
cmd.Flags().StringVarP(&options.jsonFile, "json-file", "f", "", "Read config JSON from a file instead of the command line")
cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags")
options.AddCommonFlags(cmd)
return cmd
@@ -100,6 +103,11 @@ func runUpdateConfig(o *updateConfigOptions) error {
}
}
if o.Cmd.Flags().Changed("tags") {
api.SetJSONValue(entityData, o.tags, "tags")
change = true
}
if len(jsonBytes) > 0 {
dataMap := map[string]interface{}{}
if err := json.Unmarshal(jsonBytes, &dataMap); err != nil {
+10 -2
View File
@@ -21,7 +21,7 @@ import (
"fmt"
"github.com/openziti/ziti/ziti/cmd/ziti/cmd/api"
"io"
"io/ioutil"
"os"
"github.com/pkg/errors"
@@ -36,6 +36,7 @@ type updateConfigTypeAction struct {
name string
data string
jsonFile string
tags map[string]string
}
func newUpdateConfigTypeCmd(out io.Writer, errOut io.Writer) *cobra.Command {
@@ -63,6 +64,8 @@ func newUpdateConfigTypeCmd(out io.Writer, errOut io.Writer) *cobra.Command {
cmd.Flags().StringVarP(&action.name, "name", "n", "", "Set the name of the config")
cmd.Flags().StringVarP(&action.data, "data", "d", "", "Set the data of the config")
cmd.Flags().StringVarP(&action.jsonFile, "json-file", "f", "", "Read config JSON from a file instead of the command line")
cmd.Flags().StringToStringVar(&action.tags, "tags", nil, "Custom management tags")
action.AddCommonFlags(cmd)
return cmd
@@ -93,11 +96,16 @@ func (self *updateConfigTypeAction) run() error {
return errors.New("only one of --data and --json-file is allowed")
}
var err error
if jsonBytes, err = ioutil.ReadFile(self.jsonFile); err != nil {
if jsonBytes, err = os.ReadFile(self.jsonFile); err != nil {
return fmt.Errorf("failed to read config json file %v: %w", self.jsonFile, err)
}
}
if self.Cmd.Flags().Changed("tags") {
api.SetJSONValue(entityData, self.tags, "tags")
change = true
}
if len(jsonBytes) > 0 {
dataMap := map[string]interface{}{}
if err := json.Unmarshal(jsonBytes, &dataMap); err != nil {
@@ -34,6 +34,7 @@ type updateEdgeRouterPolicyOptions struct {
name string
edgeRouterRoles []string
identityRoles []string
tags map[string]string
}
func newUpdateEdgeRouterPolicyCmd(out io.Writer, errOut io.Writer) *cobra.Command {
@@ -63,6 +64,8 @@ func newUpdateEdgeRouterPolicyCmd(out io.Writer, errOut io.Writer) *cobra.Comman
cmd.Flags().StringVarP(&options.name, "name", "n", "", "Set the name of the edge router policy")
cmd.Flags().StringSliceVar(&options.edgeRouterRoles, "edge-router-roles", nil, "Edge router roles of the edge router policy")
cmd.Flags().StringSliceVar(&options.identityRoles, "identity-roles", nil, "Identity roles of the edge router policy")
cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags")
options.AddCommonFlags(cmd)
return cmd
@@ -102,6 +105,11 @@ func runUpdateEdgeRouterPolicy(o *updateEdgeRouterPolicyOptions) error {
change = true
}
if o.Cmd.Flags().Changed("tags") {
api.SetJSONValue(entityData, o.tags, "tags")
change = true
}
if !change {
return errors.New("no change specified. must specify at least one attribute to change")
}
@@ -113,6 +113,8 @@ func newUpdatePostureCheckMacCmd(out io.Writer, errOut io.Writer) *cobra.Command
"Set role attributes of the posture check. Use --role-attributes '' to set an empty list")
cmd.Flags().StringSliceVarP(&options.addresses, "mac-addresses", "m", nil,
"Set MAC addresses of the posture check")
cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags")
return cmd
}
@@ -140,6 +142,11 @@ func runUpdatePostureCheckMac(o *updatePostureCheckMacOptions) error {
change = true
}
if o.Cmd.Flags().Changed("tags") {
api.SetJSONValue(entityData, o.tags, "tags")
change = true
}
if !change {
return errors.New("no change specified. must specify at least one attribute to change")
}
+8
View File
@@ -36,6 +36,7 @@ type updateServiceOptions struct {
roleAttributes []string
encryption encryptionVar
configs []string
tags map[string]string
}
func newUpdateServiceCmd(out io.Writer, errOut io.Writer) *cobra.Command {
@@ -68,6 +69,8 @@ func newUpdateServiceCmd(out io.Writer, errOut io.Writer) *cobra.Command {
options.encryption.Set("ON")
cmd.Flags().VarP(&options.encryption, "encryption", "e", "Controls end-to-end encryption for the service")
cmd.Flags().StringSliceVarP(&options.configs, "configs", "c", nil, "Configuration id or names to be associated with the new service")
cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags")
options.AddCommonFlags(cmd)
return cmd
@@ -111,6 +114,11 @@ func runUpdateService(o *updateServiceOptions) error {
change = true
}
if o.Cmd.Flags().Changed("tags") {
api.SetJSONValue(entityData, o.tags, "tags")
change = true
}
if !change {
return errors.New("no change specified. must specify at least one attribute to change")
}
@@ -34,6 +34,7 @@ type updateServiceEdgeRouterPolicyOptions struct {
name string
edgeRouterRoles []string
serviceRoles []string
tags map[string]string
}
func newUpdateServiceEdgeRouterPolicyCmd(out io.Writer, errOut io.Writer) *cobra.Command {
@@ -63,6 +64,8 @@ func newUpdateServiceEdgeRouterPolicyCmd(out io.Writer, errOut io.Writer) *cobra
cmd.Flags().StringVarP(&options.name, "name", "n", "", "Set the name of the edge router policy")
cmd.Flags().StringSliceVar(&options.edgeRouterRoles, "edge-router-roles", nil, "Edge router roles of the service edge router policy")
cmd.Flags().StringSliceVar(&options.serviceRoles, "service-roles", nil, "Service roles of the service edge router policy")
cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags")
options.AddCommonFlags(cmd)
return cmd
@@ -102,6 +105,11 @@ func runUpdateServiceEdgeRouterPolicy(o *updateServiceEdgeRouterPolicyOptions) e
change = true
}
if o.Cmd.Flags().Changed("tags") {
api.SetJSONValue(entityData, o.tags, "tags")
change = true
}
if !change {
return errors.New("no change specified. must specify at least one attribute to change")
}
@@ -35,6 +35,7 @@ type updateServicePolicyOptions struct {
serviceRoles []string
identityRoles []string
postureCheckRoles []string
tags map[string]string
}
func newUpdateServicePolicyCmd(out io.Writer, errOut io.Writer) *cobra.Command {
@@ -65,6 +66,8 @@ func newUpdateServicePolicyCmd(out io.Writer, errOut io.Writer) *cobra.Command {
cmd.Flags().StringSliceVar(&options.serviceRoles, "service-roles", nil, "Service roles of the service policy")
cmd.Flags().StringSliceVar(&options.identityRoles, "identity-roles", nil, "Identity roles of the service policy")
cmd.Flags().StringSliceVarP(&options.postureCheckRoles, "posture-check-roles", "p", nil, "Posture Check roles of the service policy")
cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags")
options.AddCommonFlags(cmd)
return cmd
@@ -114,6 +117,11 @@ func runUpdateServicePolicy(o *updateServicePolicyOptions) error {
change = true
}
if o.Cmd.Flags().Changed("tags") {
api.SetJSONValue(entityData, o.tags, "tags")
change = true
}
if !change {
return errors.New("no change specified. must specify at least one attribute to change")
}
@@ -37,6 +37,7 @@ type updateTerminatorOptions struct {
binding string
cost int32
precedence string
tags map[string]string
}
func newUpdateTerminatorCmd(out io.Writer, errOut io.Writer) *cobra.Command {
@@ -69,6 +70,8 @@ func newUpdateTerminatorCmd(out io.Writer, errOut io.Writer) *cobra.Command {
cmd.Flags().StringVar(&options.binding, "binding", "", "Set the terminator binding")
cmd.Flags().Int32VarP(&options.cost, "cost", "c", 0, "Set the terminator cost")
cmd.Flags().StringVarP(&options.precedence, "precedence", "p", "", "Set the terminator precedence ('default', 'required' or 'failed')")
cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags")
options.AddCommonFlags(cmd)
return cmd
@@ -116,6 +119,11 @@ func runUpdateTerminator(o *updateTerminatorOptions) (err error) {
change = true
}
if o.Cmd.Flags().Changed("tags") {
api.SetJSONValue(entityData, o.tags, "tags")
change = true
}
if !change {
return errors.New("no change specified. must specify at least one attribute to change")
}
@@ -35,6 +35,7 @@ type updateRouterOptions struct {
fingerprint string
cost uint16
noTraversal bool
tags map[string]string
}
func newUpdateRouterCmd(p common.OptionsProvider) *cobra.Command {
@@ -61,6 +62,7 @@ func newUpdateRouterCmd(p common.OptionsProvider) *cobra.Command {
cmd.Flags().StringVar(&options.fingerprint, "fingerprint", "", "Sets the router fingerprint")
cmd.Flags().Uint16Var(&options.cost, "cost", 0, "Specifies the router cost. Default 0.")
cmd.Flags().BoolVar(&options.noTraversal, "no-traversal", false, "Disallow traversal for this edge router. Default to allowed(false).")
cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags")
options.AddCommonFlags(cmd)
@@ -96,6 +98,11 @@ func runUpdateRouter(o *updateRouterOptions) error {
change = true
}
if o.Cmd.Flags().Changed("tags") {
api.SetJSONValue(entityData, o.tags, "tags")
change = true
}
if !change {
return errors.New("no change specified. must specify at least one attribute to change")
}
@@ -32,6 +32,7 @@ type updateServiceOptions struct {
api.Options
name string
terminatorStrategy string
tags map[string]string
}
func newUpdateServiceCmd(p common.OptionsProvider) *cobra.Command {
@@ -56,6 +57,7 @@ func newUpdateServiceCmd(p common.OptionsProvider) *cobra.Command {
cmd.Flags().SetInterspersed(true)
cmd.Flags().StringVarP(&options.name, "name", "n", "", "Set the name of the service")
cmd.Flags().StringVar(&options.terminatorStrategy, "terminator-strategy", "", "Specifies the terminator strategy for the service")
cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags")
options.AddCommonFlags(cmd)
return cmd
@@ -80,6 +82,11 @@ func runUpdateService(o *updateServiceOptions) error {
change = true
}
if o.Cmd.Flags().Changed("tags") {
api.SetJSONValue(entityData, o.tags, "tags")
change = true
}
if !change {
return errors.New("no change specified. must specify at least one attribute to change")
}
@@ -37,6 +37,7 @@ type updateTerminatorOptions struct {
binding string
cost int32
precedence string
tags map[string]string
}
func newUpdateTerminatorCmd(p common.OptionsProvider) *cobra.Command {
@@ -64,6 +65,7 @@ func newUpdateTerminatorCmd(p common.OptionsProvider) *cobra.Command {
cmd.Flags().StringVar(&options.binding, "binding", "", "Set the terminator binding")
cmd.Flags().Int32VarP(&options.cost, "cost", "c", 0, "Set the terminator cost")
cmd.Flags().StringVarP(&options.precedence, "precedence", "p", "", "Set the terminator precedence ('default', 'required' or 'failed')")
cmd.Flags().StringToStringVar(&options.tags, "tags", nil, "Custom management tags")
options.AddCommonFlags(cmd)
return cmd
@@ -111,6 +113,11 @@ func runUpdateTerminator(o *updateTerminatorOptions) (err error) {
change = true
}
if o.Cmd.Flags().Changed("tags") {
api.SetJSONValue(entityData, o.tags, "tags")
change = true
}
if !change {
return errors.New("no change specified. must specify at least one attribute to change")
}