Skip to content

Commit

Permalink
feat(component): inject global secrets as environment variables (#786)
Browse files Browse the repository at this point in the history
Because

- Google Drive component will need the OAuth client secret and ID
injected
  as an environment variable.
- The number of component variables has grown enough as to have a
dedicated
  environment file.

This commit

- Defines the component global variables in an environment file and
injects
  them when running the docker container.
  • Loading branch information
jvallesm authored Oct 30, 2024
1 parent 9e0e575 commit 8d842a6
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
19 changes: 19 additions & 0 deletions .env.component
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Component global secrets

# Provide your API key for the AI vendors so that you can set the components up
# with default credentials.
CFG_CONNECTOR_SECRETS_OPENAI_APIKEY=
CFG_CONNECTOR_SECRETS_STABILITYAI_APIKEY=
CFG_CONNECTOR_SECRETS_ANTHROPIC_APIKEY=
CFG_CONNECTOR_SECRETS_COHERE_APIKEY=
CFG_CONNECTOR_SECRETS_MISTRALAI_APIKEY=
CFG_CONNECTOR_SECRETS_GROQ_APIKEY=
CFG_CONNECTOR_SECRETS_FIREWORKSAI_APIKEY=

# Numbers Protocol API key.
CFG_CONNECTOR_SECRETS_NUMBERS_XAPIKEY=

# OAuth secrets. When these are filled, the specified component will support
# OAuth integrations.
CFG_CONNECTOR_SECRETS_GOOGLEDRIVE_CLIENTID=
CFG_CONNECTOR_SECRETS_GOOGLEDRIVE_CLIENTSECRET=
20 changes: 14 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@ $ make build-dev && make dev
Now, you have the Go project set up in the container, in which you can compile
and run the binaries together with the integration test in each container shell.

##### Injecting component secrets

Some components can be configured with global secrets. This has several
applications:

- By accepting a global API key, some components have a default setup. When
the `setup` block is omitted in the recipe, this API key will be used.
- In order to connect to 3rd party vendors via OAuth, the application
client ID and secret must be injected.

You can set the values of these global secrets in
[`.env.component`](./.env.component) before running the Docker container in
order to add a global configuration to your components.

#### Run the server and the Temporal worker

```sh
Expand Down Expand Up @@ -91,12 +105,6 @@ At the end of the tests, some SQL queries are run to clean up the data.
`DB_HOST` points to the database host so the SQL connection can be established.
If empty, tests will try to connect to `localhost:5432`.

#### Stop the dev container

```bash
$ make stop
```

#### Remove the dev container

```bash
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dev: ## Run dev container
-v $(PWD):/${SERVICE_NAME} \
-p ${PUBLIC_SERVICE_PORT}:${PUBLIC_SERVICE_PORT} \
-p ${PRIVATE_SERVICE_PORT}:${PRIVATE_SERVICE_PORT} \
--env-file .env.component \
--network instill-network \
--name ${SERVICE_NAME} \
instill/${SERVICE_NAME}:dev >/dev/null 2>&1
Expand Down

0 comments on commit 8d842a6

Please sign in to comment.