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
Copy file name to clipboardExpand all lines: packages/varlock-website/src/content/docs/env-spec/reference.mdx
+30-5Lines changed: 30 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ BAZ= # @dec # this is @ignored too
57
57
58
58
### Decorators
59
59
60
-
Decorators are used within comments to attach structured data to specific config items, or within a standalone comment blockto alter a group of items or the entire document and loading process.
60
+
Decorators are used within comments to attach structured data to specific config items, or within a standalone comment block to alter a group of items or the entire document and loading process.
61
61
62
62
- Each decorator has a name and optional value (`@name=value`) or is a bare function call `@func()`
63
63
- Decorators with values may only be used once per comment block, while function calls may be used multiple times
@@ -91,7 +91,7 @@ A divider is a comment that serves as a separator, like a `<hr/>` in HTML.
91
91
# ---
92
92
ITEM1=
93
93
ITEM2=
94
-
# --- another divider ---
94
+
# --- another divider ---
95
95
ITEM3=
96
96
```
97
97
@@ -100,9 +100,9 @@ ITEM3=
100
100
### Config Item Comments
101
101
Comment lines directly preceeding an item will be attached to that item, along with the decorators contained within.
102
102
103
-
- A blank line or a divider will break the above comments from being attached to the item
103
+
- A blank line or a divider will break the above comments from being attached to the item below
104
104
- Both decorator and regular comment lines may be interspersed
105
-
- Post-value comments may also contain decorators, but is not recommended
105
+
- Post-value comments may also contain decorators, but should be used sparingly
106
106
107
107
```env-spec
108
108
# these comments are attached to ITEM1 below
@@ -162,6 +162,7 @@ Values are interpreted similarly for config item values, decorator values, and v
162
162
- A value in quotes is _always_ treated as a string -- `@d1="with spaces"`, `@trueString="true"`, `@numStr="123"`
163
163
- All quote styles ``[`'"]`` are ok -- ``@dq="c" @bt=`b` @sq='a'``
164
164
- Escaped quotes matching the wrapping quote style are ok -- `@ok="escaped\"quote"`
165
+
- Single quote wrapped strings do not support [expansion (see below)](#expansion)
165
166
- In `"` or `` ` `` wrapped values, the string `\n` will be converted to an actual newline
166
167
- Multi-line strings may be wrapped in ``(```|"""|"|')``
167
168
- only available for config item values, not decorators or within function args
@@ -175,7 +176,7 @@ In each case, much of the handling is the same.
175
176
- a value must not be wrapped in quotes to be interpreted as a function call
176
177
- function names must start with a letter, and can then contain letters, numbers, and underscores `/[a-ZA-Z][a-ZA-Z0-9_]*/`
177
178
- you can pass no args, a single arg, or multiple args
178
-
- you may also pass key value pairs at the end of the list, and they will be combined into a single object at the end of the array
179
+
- you may also pass key value pairs at the end of the list
179
180
- each value will be interpreted using common value-handling rules (see above)
While the parser itself does not include any implemention of specific functions, it does handle _expansion_ of strings - and it uses several function calls under the hood to do so. This means a few basic function calls, while not implemented, have specific inherent meaning and must be implemented similarly across all tools that support this spec.
193
+
194
+
Expansion can be used within item values, decorator values, and function call arguments.
195
+
196
+
_Note that single quote wrapped strings are NOT expanded._
We recommend using expansion only for simple refs `$ITEM`/`${ITEM}` and skipping the rest.
207
+
208
+
- Use bracketed version within a larger string - `fn("${ENV}_db")`
209
+
- Skip the brackets otherwise - `fn($ENV)`
210
+
211
+
The rest is implemented to match other popular tools, but we do not recommend using them, as intent can be more clearly expressed using function calls directly.
Copy file name to clipboardExpand all lines: packages/varlock-website/src/content/docs/guides/import.mdx
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ For now, all imported files must be `.env` files (and may contain @env-spec deco
22
22
23
23
### Single file
24
24
25
-
- Path must begin with `./` or `../`
25
+
- Path must begin with `./` or `../` or `/`
26
26
- Imported file name must be begin with `.env.`
27
27
28
28
```env-spec
@@ -31,7 +31,7 @@ For now, all imported files must be `.env` files (and may contain @env-spec deco
31
31
32
32
### Directory
33
33
34
-
- Path must begin with `./` or `../`
34
+
- Path must begin with `./` or `../` or `/`
35
35
- Path must end with a trailing `/`
36
36
- Multiple `.env.*` files will be detected and loaded, based on the current environment flag, similar to what happens in the current directory (see [environments guide](/guides/environments#loading-environment-specific-env-files))
37
37
- The environment flag value will be inherited, unless another `@currentEnv` is defined within the directory's `.env.schema`
Copy file name to clipboardExpand all lines: packages/varlock-website/src/content/docs/guides/plugins.mdx
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,9 @@ description: Using plugins with varlock
5
5
6
6
Plugins allow extending the functionality of Varlock. Specifically they may introduce new [root decorators](/reference/root-decorators/), [item decorators](/reference/item-decorators/), [data types](/reference/data-types/), and [resolver functions](/reference/functions/).
# @initOpVault(allowAppAuth=true) # init via custom root decorator
10
+
# @initOp(allowAppAuth=true) # init via custom root decorator
11
11
# ---
12
12
# @type=opServiceAccountToken # custom data type
13
13
OP_TOKEN=
@@ -66,8 +66,8 @@ Plugins are initialized using custom root decorators that they introduce. In som
66
66
67
67
A plugin initialization root decorator is used to set IDs, toggle features, and wire up auth. Note that sensitive data should be passed in via references to config items within your schema.
@@ -80,10 +80,10 @@ In secret storage tools, you should segment your data to follow the [_principle
80
80
We cannot always assume that you won't need access to multiple segments at the same time. In these cases, a plugin may be designed to be initialized multiple times with some kind of id parameter. Resolver functions and decorators can then accept an additional parameter to specify which instance to use.
`varlock` supports _expansion_ like other .env tools - such as [dotenv-expand](https://github.com/motdotla/dotenv-expand). However unlike other tools, it uses [function calls](/reference/functions/) to implement this.
97
+
Within values and function args, you often need to reference other env vars within your schema.
You may use [`ref()`](/reference/functions/#ref) but we support _expansion_ syntax (like many other .env tools) for convenience.
104
100
105
-
While you could call those functions directly, in many cases it will be more clear to use expansion, or a mix of function calls and expansion. For example:
101
+
Both `$ITEM` and `${ITEM}` are equivalent to `ref(ITEM)`.
# 3. Add a service account token config item (if applicable)
29
29
# @type=opServiceAccountToken @sensitive
30
30
OP_TOKEN=
31
31
```
32
32
33
-
### Vault & service account setup
33
+
### Vault setup
34
34
35
-
If you already use 1Password and your secrets live in a vault that holds other sensitive data, you should create a new vault and move your secrets to it, because **the access system of 1Password is based on vaults, not individual items**.
35
+
If your secrets are already stored in 1Password, you may not need to do anything. However, if secrets live in a vault that holds other sensitive data, you should create a new vault and move your secrets to it, because **the access system of 1Password is based on vaults, not individual items**.
36
36
37
-
<Steps>
37
+
You can create multiple vaults to segment access to different environments, services, etc. This can be done using any 1Password app, the web app, or the CLI. [link](https://support.1password.com/create-share-vaults/#create-a-vault)
38
+
39
+
Remember to grant access to necessary team members, particularly if you plan on using the desktop app auth method during local development, as they will be authenticating as themselves.
40
+
41
+
:::tip[Vault organization best practices]
42
+
Consider how you want to organize your vaults and service accounts, keeping in mind [best practices](https://support.1password.com/business-security-practices/#access-management-and-the-principle-of-least-privilege). At a minimum, we recommend having a vault for highly sensitive production secrets and another for everything else.
43
+
:::
44
+
45
+
### Service account setup (for deployed environments)
46
+
47
+
If you plan on using data from 1Password in deployed environments (CI/CD, production, etc), you will need to create a [service account](https://developer.1password.com/docs/service-accounts/get-started/) to allow machine-to-machine authentication. You could also use a service account for local development, although we recommend using the desktop app auth method described below for convenience.
38
48
39
-
1.**Create a vault** in your 1Password account which will be used to hold your secrets. You can create multiple vaults to segment access to different environments, services, etc. This can be done using any 1Password app, the web app, or the CLI. [link](https://support.1password.com/create-share-vaults/#create-a-vault)
49
+
This service account token will now serve as your _secret-zero_ - which grants access to the rest of your sensitive data stored in 1Password.
40
50
41
-
2.**Create a new service account** and grant access to necessary vault(s). This is a special account used for machine-to-machine communication. This can only be done in the 1Password web interface. Be sure to save the new service account token in another vault so you can find it later. [link](https://developer.1password.com/docs/service-accounts/get-started/)
51
+
<Steps>
52
+
1.**Create a new service account** and grant access to necessary vault(s). This is a special account used for machine-to-machine communication. This can only be done in the 1Password web interface. Be sure to save the new service account token in another vault so you can find it later. [link](https://developer.1password.com/docs/service-accounts/get-started/)
42
53
:::note[Vault access is set during creation only]
43
54
Vault access rules cannot be edited after creation, so if your vault setup changes, you will need to create new service account(s) and update the tokens.
44
55
:::
45
56
46
-
3.**Grant vault access to users/teams (optional)**. Your developers may need access to at least some of your vaults, especially if using the app based auth mentioned below. [link](https://support.1password.com/create-share-vaults-teams/#share-a-vault)
47
-
48
-
4.**Ensure vault service account access is enabled (optional)**. Each vault has a toggle to disable service account access _in general_. It is on by default, so you will likely not need to do anything. [link](https://developer.1password.com/docs/service-accounts/manage-service-accounts/#manage-access)
57
+
2.**Wire up the service account token in your config**. Add a config item of type `opServiceAccountToken` to hold the token value, and reference it when initializing the plugin.
3.**Set your service account token in deployed environments**. Copy the token value from where you saved it earlier, and set it in deployed environments using your platform's env var management UI. Be sure to use the same name as you defined in your schema (e.g. `OP_TOKEN`).
50
67
</Steps>
51
68
52
-
This service account token will now serve as your _secret-zero_ - which grants access to the rest of your sensitive data stored in 1Password. It must be set locally (unless relying on app-based auth) and in any deployed environments, usually as an environment variable with your platform's env var management UI.
53
-
54
-
:::tip[Vault organization best practices]
55
-
Consider how you want to organize your vaults and service accounts, keeping in mind [best practices](https://support.1password.com/business-security-practices/#access-management-and-the-principle-of-least-privilege). At a minimum, we recommend having a vault for highly sensitive production secrets and another for everything else.
69
+
:::caution[Ensure service account access is enabled]
70
+
Each vault has a toggle to disable service account access _in general_. It is on by default, so you will likely not need to do anything. [link](https://developer.1password.com/docs/service-accounts/manage-service-accounts/#manage-access)
56
71
:::
57
72
58
73
59
-
### Desktop app auth (optional)
74
+
### Desktop app auth (for local dev)
60
75
61
76
During local development, you may find it convenient to skip the service account tokens and instead rely on your local 1Password desktop app (via the [CLI integration](https://developer.1password.com/docs/cli/get-started/#step-2-turn-on-the-1password-desktop-app-integration)), including using its biometric unlocking features.
This value is passed through under the `--account` flag to the `op` CLI, and accepts account shorthand, sign-in address, account ID, or user ID.
@@ -111,8 +126,8 @@ The secret reference for invidivual fields within an item can be found by clicki
111
126
If you used the `id` param during initialization and have multiple instances, the `op()` function accepts an optional first parameter to specify which instance id to use.
0 commit comments