You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* fix: rename keyvault inline with other az services
* fix: add errors to central place in package
* fix: clean up
* fix: genvars config
* fix: ParseMetadata use common generic
* fix: az app conf unit tests
+semver: feature
+semver: feat
* fix: update docs
e.g. `AWSSECRETS` the strategy identifier to choose at runtime
80
+
The `AWSSECRETS` the strategy identifier to choose the correct provider at runtime. Multiple providers can be referenced in a single run via a CLI or with the API.
81
+
82
+
This is not overrideable and must be exactly as it is in the provided list of providers.
75
83
76
84
### __Token Separator__
77
85
78
-
e.g.`#` - used for separating the implementation indicator and the look up value.
86
+
The`#` symbol from the [example token](#awssecretspathtomykeylookupinsideobjectmetadata) - used for separating the implementation indicator and the look up value.
79
87
80
-
> The default is currently `#` - it will change to `://` to allow for a more natural reading of the "token". you can achieve this behaviour now by either specifying the `-s` to the CLI or ConfigManager public methods, like below.
88
+
> The default is currently `#` - it will change to `://` to allow for a more natural reading of the "token". you can achieve this behaviour now by either specifying the `-s` to the CLI or ConfigManager Go API.
Alternatively you can use the helper methods for Yaml or Json tagged structs - see [examples](./examples/examples.go) for more details
94
+
### __Provider Secret/Config Path__
93
95
94
-
-`/path/to/parameter` the actual path to the secret or parameter in the target system e.g. AWS SecretsManager or ParameterStore (it does assume a path like pattern might throw a runtime error if not found)
96
+
The`/path/to/my/key` part from the [example token](#awssecretspathtomykeylookupinsideobjectmetadata) is the actual path to the item in the backing store.
95
97
96
-
If contents of the `AWSSECRETS#/appxyz/service1-password` are a string then `service1-password` will be the key and converted to UPPERCASE e.g. `SERVICE1_PASSWORD=som3V4lue`
98
+
See the different special considerations per provider as it different providers will require different implementations.
97
99
98
100
### __Key Separator__
99
101
100
-
Specifying a key seperator on token items that can be parsed as a K/V map will result in only retrieving the specific key from the map.
102
+
__THIS IS OPTIONAL__
103
+
104
+
The `|` symbol from the [example token](#awssecretspathtomykeylookupinsideobjectmetadata) is used to specify the key seperator.
105
+
106
+
If an item retrieved from a store is JSON parseable map it can be interrogated for further properties inside.
107
+
108
+
### __Look up key__
101
109
102
-
e.g. if contents of the `AWSSECRETS#/appxyz/service1-db-config` are parseable into the below object
110
+
__THIS IS OPTIONAL__
111
+
112
+
The `lookup.Inside.Object` from the [example token](#awssecretspathtomykeylookupinsideobjectmetadata) is used to perform a lookup inside the retrieved item IF it is parseable into a `map[string]any` structure.
113
+
114
+
Given the below response from a backing store
103
115
104
116
```json
105
117
{
106
-
"host": "db.internal",
107
-
"port": 3306,
108
-
"pass": "sUp3$ecr3T!",
118
+
"lookup": {
119
+
"Inside": {
120
+
"Object": {
121
+
"host": "db.internal",
122
+
"port": 3306,
123
+
"pass": "sUp3$ecr3T!",
124
+
}
125
+
}
126
+
}
109
127
}
110
128
```
111
129
112
-
Then you can access the single values like this `AWSSECRETS#/appxyz/service1-db-config|host` ==> `export SERVICE1_DB_CONFIG__HOST='db.internal'`
113
-
114
-
Alternatively if you are `configmanager`-ing a file via the fromstr command and the input is something like this:
115
-
116
-
(YAML)
130
+
The value returned for the [example token](#awssecretspathtomykeylookupinsideobjectmetadata) would be:
117
131
118
-
```yaml
119
-
app:
120
-
name: xyz
121
-
db:
122
-
host: AWSSECRETS#/appxyz/service1-db-config|host
123
-
port: AWSSECRETS#/appxyz/service1-db-config|port
124
-
pass: AWSSECRETS#/appxyz/service1-db-config|pass
132
+
```json
133
+
{
134
+
"host": "db.internal",
135
+
"port": 3306,
136
+
"pass": "sUp3$ecr3T!",
137
+
}
125
138
```
126
139
127
-
which would result in this
140
+
See [examples of working with files](docs/examples.md#working-with-files) for more details.
128
141
129
-
```yaml
130
-
app:
131
-
name: xyz
132
-
db:
133
-
host: db.internal
134
-
port: 3306
135
-
pass: sUp3$ecr3T!
136
-
```
142
+
### Token Metadata Config
137
143
138
-
If your config parameter matches the config interface, you can also leave the entire token to point to the `db` key
144
+
The `[meta=data]` from the [example token](#awssecretspathtomykeylookupinsideobjectmetadata) - is the optional metadata about the target in the backing provider
139
145
140
-
```yaml
141
-
app:
142
-
name: xyz
143
-
db: AWSSECRETS#/appxyz/service1-db-config
144
-
```
146
+
IT must have this format `[key=value]` - IT IS OPTIONAL
145
147
146
-
result:
148
+
The `key` and `value` would be provider specific. Meaning that different providers support different config, these values _CAN_ be safely omitted configmanager would just use the defaults where applicable or not specify the additional
147
149
148
-
```yaml
149
-
app:
150
-
name: xyz
151
-
db: {
152
-
"host": "db.internal",
153
-
"port": 3306,
154
-
"pass": "sUp3$ecr3T!",
155
-
}
156
-
```
150
+
- Hashicorp Vault (VAULT)
151
+
- `iam_role` - would be the value of an IAM role ARN to use with AWSClient Authentication.
152
+
- `version` - is the version of the secret/configitem to get (should be in an integer format)
157
153
158
-
### Additional Token Config
154
+
e.g. `VAULT://baz/bar/123|d88[role=arn:aws:iam::1111111:role/i-orchestration,version=1082313]`
159
155
160
-
Suffixed `[]` with `role:` or `version:` specified inside the brackets and comma separated
156
+
- Azure AppConfig (AZAPPCONF)
157
+
- `label` - the label to use whilst retrieving the item
158
+
- `etag` - etag value
161
159
162
-
order is not important, but the `role:` keyword must be followed by the role string
160
+
e.g. `AZAPPCONF://baz/bar/123|d88[label=dev,etag=aaaaa1082313]`
163
161
164
-
e.g. `VAULT://baz/bar/123|d88[role:arn:aws:iam::1111111:role/i-orchestration,version:1082313]`
Currently only supporting version and role but may be extended in the future.
165
+
e.g. `GCPSECRETS://baz/bar/123|d88[version=verUUID0000-1123zss]`
167
166
168
-
- role is used with `VAULT` `aws_iam` auth type. Specifying it on a token level as opposed to globally will ensure that multiple roles can be used provided that the caller has the ability to assume them.
167
+
## Special considerations
169
168
170
-
- version can be used within all implementations that support versioned config items e.g. `VAULT`, `GCPSECRETS` , `AWSSECRETS`, `AZKVSECRET`. If omitted it will default to the `LATEST`.
169
+
This section outlines the special consideration in token construction on a per provider basis
171
170
172
171
### Special consideration for AZKVSECRET
173
172
@@ -218,105 +217,9 @@ when using Vault in AWS - you can set the value of the `VAULT_TOKEN=aws_iam` thi
218
217
219
218
The Hashicorp Vault functions in the same exact way as the other implementations. It will retrieve the JSON object and can be looked up within it by using a key separator.
220
219
221
-
## Go API
222
-
223
-
latest api [here](https://pkg.go.dev/github.com/dnitsch/configmanager)
224
-
225
-
### Sample Use case
226
-
227
-
One of the sample use cases includes implementation in a K8s controller.
228
-
229
-
E.g. your Custom CRD stores some values in plain text that should really be secrets/nonpublic config parameters - something like this can be invoked from inside the controller code using the generator pkg API.
230
-
231
-
See [examples](./examples/examples.go) for more examples and tests for sample input/usage
Above example would ensure that you can safely store config/secret values on a CRD in plain text.
268
-
269
-
Or using go1.19+ [generics example](https://github.com/dnitsch/reststrategy/blob/d14ccec2b29bff646678ab9cf1775c0e93308569/controller/controller.go#L353).
270
-
271
-
> Beware logging out the CRD after tokens have been replaced.
272
-
273
-
Samlpe call to retrieve from inside an app/serverless function to only grab the relevant values from config.
Copy file name to clipboardExpand all lines: docs/adding-provider.md
+37-4Lines changed: 37 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# adding provider
1
+
# Adding a provider
2
2
3
3
Add Token Prefix
4
4
@@ -30,10 +30,43 @@ ensure your implementation satisfy the `genVarsStrategy` interface
30
30
31
31
```go
32
32
type genVarsStrategy interface {
33
-
getTokenValue(rs *retrieveStrategy) (s string, e error)
34
-
setToken(s string)
35
-
setValue(s string)
33
+
tokenVal(rs *retrieveStrategy) (s string, e error)
34
+
setTokenVal(s string)
36
35
}
37
36
```
38
37
39
38
Even if the native type is K/V return a marshalled version of the JSON as the rest of the flow will decide how to present it back to the final consumer.
39
+
40
+
Custom properties inside the GetValue request, you could specify your own Config struct for the provider, e.g. HashiVault implementation
41
+
42
+
```go
43
+
// VaultConfig holds the parseable metadata struct
44
+
typeVaultConfigstruct {
45
+
Versionstring`json:"version"`
46
+
Rolestring`json:"iam_role"`
47
+
}
48
+
```
49
+
50
+
You could then use it on the backingStore object
51
+
52
+
```go
53
+
typeVaultStorestruct {
54
+
svc hashiVaultApi
55
+
ctx context.Context
56
+
config *VaultConfig
57
+
token string
58
+
}
59
+
```
60
+
61
+
On initialize of the instance or in the setTokenVal method (see GCPSecrets or AWSSecrets/ParamStore examples).
62
+
63
+
```go
64
+
storeConf:= &VaultConfig{}
65
+
initialToken:=ParseMetadata(token, storeConf)
66
+
imp:= &VaultStore{
67
+
ctx: ctx,
68
+
config: storeConf,
69
+
}
70
+
```
71
+
72
+
Where the initialToken is the original Token without the metadata in brackets and the `storeConf` pointer will have been filled with any of the parsed metadata and used in the actual provider implementation, see any of the providers for a sample implementation.
0 commit comments