From 47b2ab376031d782f7c23d63c1c91569ddd129f6 Mon Sep 17 00:00:00 2001 From: Jack LaFond Date: Tue, 4 Oct 2022 15:52:26 -0400 Subject: [PATCH 1/4] Create environment_variables.mdx --- pages/ignite/environment_variables.mdx | 48 ++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 pages/ignite/environment_variables.mdx diff --git a/pages/ignite/environment_variables.mdx b/pages/ignite/environment_variables.mdx new file mode 100644 index 0000000..565740f --- /dev/null +++ b/pages/ignite/environment_variables.mdx @@ -0,0 +1,48 @@ +--- +title: Environment Variables +description: Manage your Hop Project's Environment Variables +--- + +import Image from 'next/future/image'; +import hopEnv1 from '../../assets/images/hop-deploy-env-1.png'; +import {Bleed} from '../../components/bleed'; + +# Environment Variables + +Environment variables act as a variable set outside your Ignite deployment on Hop. Environment variables can be referenced in Ignite deployment configs and will automatically be populated when a container starts. + +Environment variables can be **created** on deployment, **deleted** with the console, and **viewed** with the CLI, console, and API. + +## Environment Variable Names + +Environment variables are limited to 64 characters in length, must be alphanumeric (with underscores) and are automatically uppercased. + +📝 Environment variables regex, for your convenience: `^[a-zA-Z0-9_]{1,64}$` + +## Using Environment Variables + +### In Hop Deployments + +When creating a deployment or individual container, you can set environment variables - the values will then automatically be updated. + +#### Usage with `hop deploy` + +When using `hop deploy`, you can specify environment variables with `-e` or `--env`, so: for example, if I wanted to reference an environment variable named `TOKEN` in my deployment, I'd execute the following command: + +```bash +hop deploy --env TOKEN="${env.TOKEN}" +``` + +#### Usage with Console + +When creating a deployment, or when using the **Environment** tab in your deployment, you can set environment variable values: + +
+ + + +#### Usage with API + +You can set environment variables on an API request: `${env.NAME}` From fbae5a1b0b383290cd191c6fbbd8cc673a60df3b Mon Sep 17 00:00:00 2001 From: Jack LaFond Date: Thu, 6 Oct 2022 16:04:35 -0400 Subject: [PATCH 2/4] update --- pages/ignite/environment_variables.mdx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pages/ignite/environment_variables.mdx b/pages/ignite/environment_variables.mdx index 565740f..918c410 100644 --- a/pages/ignite/environment_variables.mdx +++ b/pages/ignite/environment_variables.mdx @@ -9,10 +9,12 @@ import {Bleed} from '../../components/bleed'; # Environment Variables -Environment variables act as a variable set outside your Ignite deployment on Hop. Environment variables can be referenced in Ignite deployment configs and will automatically be populated when a container starts. +Environment variables act as a variable set outside your Ignite deployment on Hop. Environment variables can be referenced in Ignite deployment configs and will automatically be populated when a container starts. Environment variables can be **created** on deployment, **deleted** with the console, and **viewed** with the CLI, console, and API. +Environment variables can be any string, in addition to a secret. For example, a Secret can be used as an environment variable. + ## Environment Variable Names Environment variables are limited to 64 characters in length, must be alphanumeric (with underscores) and are automatically uppercased. @@ -30,18 +32,12 @@ When creating a deployment or individual container, you can set environment vari When using `hop deploy`, you can specify environment variables with `-e` or `--env`, so: for example, if I wanted to reference an environment variable named `TOKEN` in my deployment, I'd execute the following command: ```bash -hop deploy --env TOKEN="${env.TOKEN}" +hop deploy --env TOKEN=VALUE ``` #### Usage with Console -When creating a deployment, or when using the **Environment** tab in your deployment, you can set environment variable values: - -
- - +When creating a deployment, or when using the **Environment** tab in your deployment, you can set environment variable values. #### Usage with API From d61a5b3e77037f39b434ff2edebaa6dae8bb9bb6 Mon Sep 17 00:00:00 2001 From: Jack LaFond Date: Thu, 6 Oct 2022 18:47:12 -0400 Subject: [PATCH 3/4] add example --- pages/ignite/environment_variables.mdx | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/pages/ignite/environment_variables.mdx b/pages/ignite/environment_variables.mdx index 918c410..6e5cdb0 100644 --- a/pages/ignite/environment_variables.mdx +++ b/pages/ignite/environment_variables.mdx @@ -42,3 +42,29 @@ When creating a deployment, or when using the **Environment** tab in your deploy #### Usage with API You can set environment variables on an API request: `${env.NAME}` + +Using [Hop's JS SDK](https://docs.hop.io/sdks/client/js): +```tsx +import {API} from '@onehop/js'; + +await hop.ignite.deployments.create({ + version: '2022-05-17', + name: 'redis', + image: { + name: 'redis', + auth: null, + gh_repo: null, + }, + container_strategy: 'manual', + type: API.Ignite.RuntimeType.PERSISTENT, + env: { + TOKEN: 'VALUE', + }, + resources: { + vcpu: 0.5, + ram: '128MB', + vgpu: [], + }, + restart_policy: API.Ignite.RestartPolicy.ALWAYS, + }); +``` From d72d8850a348bab94d5ae83f87cc003109d727c0 Mon Sep 17 00:00:00 2001 From: Alistair Smith Date: Thu, 6 Oct 2022 23:51:54 +0100 Subject: [PATCH 4/4] fix: wrap codeblock in --- pages/ignite/environment_variables.mdx | 50 ++++++++++++++------------ 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/pages/ignite/environment_variables.mdx b/pages/ignite/environment_variables.mdx index 6e5cdb0..e58c6f1 100644 --- a/pages/ignite/environment_variables.mdx +++ b/pages/ignite/environment_variables.mdx @@ -6,6 +6,7 @@ description: Manage your Hop Project's Environment Variables import Image from 'next/future/image'; import hopEnv1 from '../../assets/images/hop-deploy-env-1.png'; import {Bleed} from '../../components/bleed'; +import {Code} from '../../components/code'; # Environment Variables @@ -44,27 +45,32 @@ When creating a deployment, or when using the **Environment** tab in your deploy You can set environment variables on an API request: `${env.NAME}` Using [Hop's JS SDK](https://docs.hop.io/sdks/client/js): + + + ```tsx -import {API} from '@onehop/js'; - -await hop.ignite.deployments.create({ - version: '2022-05-17', - name: 'redis', - image: { - name: 'redis', - auth: null, - gh_repo: null, - }, - container_strategy: 'manual', - type: API.Ignite.RuntimeType.PERSISTENT, - env: { - TOKEN: 'VALUE', - }, - resources: { - vcpu: 0.5, - ram: '128MB', - vgpu: [], - }, - restart_policy: API.Ignite.RestartPolicy.ALWAYS, - }); +import {RestartPolicy, RuntimeType} from '@onehop/js'; + +const deployment = await hop.ignite.deployments.create({ + version: '2022-05-17', + name: 'redis', + image: { + name: 'redis', + auth: null, + gh_repo: null, + }, + container_strategy: 'manual', + type: RuntimeType.PERSISTENT, + env: { + TOKEN: 'VALUE', + }, + resources: { + vcpu: 0.5, + ram: '128MB', + vgpu: [], + }, + restart_policy: RestartPolicy.ALWAYS, +}); ``` + +