Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh: add documentation for snap-in build config #41

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions fern/docs/pages/references/build-config.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
The build configuration is used to configure the build process of the snap-in. For example, it can be used to set the environment variables used during the build process.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The definition is tautological: build configuration configures builds. The intro paragraph should have comprehensive statements, not an example. What else does it do besides set environment variables? I don't see anything else covered in this doc.


This is useful if the developer wants to import libraries from a different registry or wants to use private packages that
requires an authentication token.
starlightknown marked this conversation as resolved.
Show resolved Hide resolved

## Specifying the Config

Build config is defined as:

```yaml
build_config:
environment_variables:
- name: <Name of the environment variable>
description: <Description of what the environment variable does>
type: <Whether the value is a `constant` or in a developer `keyring`>
value: <variable value or developer keyring name>
```

For example, to import a library that uses the GitHub NPM registry, add
the following variables to the build config

```yaml
build_config:
environment_variables:
- name: REGISTRY_NAME
description: Name of the GitHub registry to import the library.
type: constant
value: npm.pkg.github.com
- name: AUTH_TOKEN
description: Token to access the registry
type: keyring
value: access_token
```

Since "AUTH_TOKEN" is sensitive information that should not be hardcoded in the manifest,
the developer can instead mention the name of the developer keyring and during snap-in version creation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the developer can instead mention the name of the developer keyring and during snap-in version creation
the developer can instead mention the name of the developer keyring and during snap-in version creation

and during?

time, provide the developer keyring to take the value from.

```yaml
developer_keyrings:
- name: access_token
description: Access token for the GitHub registry
display_name: Access Token
```

## Using the variables defined in config

If the package is present in private registries, the developer can update the `.npmrc` file in the `code` folder from the template to include the URL of the registry and the token.

For example, to use variables defined in the manifest defined in the previous section, the `.npmrc` file will look something like this:

```.npmrc
@githubReg:registry=https://${REGISTRY_NAME}
//${REGISTRY_NAME}/:_authToken=${AUTH_TOKEN}
```

To ensure that the `.npmrc` file is valid and can be used to install the libraries, export the variables defined in the manifest locally with the correct values and install the library

```
npm install @githubReg/<YOUR_LIBRARY>
```
35 changes: 31 additions & 4 deletions fern/docs/pages/references/manifest.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<Callout intent="note">
The following section is for version 2 of the manifest specification. For the previous version, see [Manifest V1](/snap-in-development/references/snap-in-v-1-manifest).
The following section is for version 2 of the manifest specification. For the
previous version, see [Manifest
V1](/snap-in-development/references/snap-in-v-1-manifest).
</Callout>

The snap-in manifest is what the developers write to define a snap-in. The manifest has the following sections:
Expand Down Expand Up @@ -57,11 +59,12 @@ keyrings:
- snap_in_secret
display_name: Your secret token
```

Keyrings defined in the manifest can be provided in the snap-in configuration screens and are made available to the function. The keyring type is used to determine the type of the keyring and restricts selection on the configuration screen to valid types.

Organization keyrings are common to the organization, while user keyrings are set per user. User keyrings are optional, so the developer must correctly handle cases where the keyring isn't found.

To view the supported connection types, see [Keyrings](/snap-in-development/references/keyrings).
To view the supported connection types, see [Keyrings](/references/keyrings).

## Developer keyrings

Expand Down Expand Up @@ -679,7 +682,8 @@ inputs:
ui:
display_name: <Input field display name.>
```
Inputs of type `timestamp`, `date` and `array` of `booleans` aren't supported.

Inputs of type `timestamp`, `date` and `array` of `booleans` aren't supported.

## Tags

Expand All @@ -706,7 +710,7 @@ commands:
- surface: discussions
object_types:
- conversation
usage_hint: "number of tokens to generate"
usage_hint: 'number of tokens to generate'
function: generate_summary
```

Expand Down Expand Up @@ -743,3 +747,26 @@ automations:
```

For custom event sources, whatever event key you emit from your policy, the event name will be `custom:<your event key>`.

## Build config

The build configuration is used to configure the build process of the snap-In. For example, it can be used to set the environment variables used during the build process. This is useful if the snap-in requires libraries that
are either private or from different npm registry than the default.

Build config is defined as:

```yaml
build_config:
environment_variables:
- name: <Name of the environment variable>
description: <Description of what the environment variable does>
type: <Whether the value is a constant or in a developer keyring>
value: <variable value or developer keyring name>
```

`type` can either be `constant` or `keyring`.

`value` is either the actual value of the environment variable or name of the developer keyring that
contains the secret depending on the type being `constant` or `keyring`.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also link to the documentation page for build_configuration?


For further information, see [Build Config](/references/build-config).
3 changes: 3 additions & 0 deletions fern/versions/public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ navigation:
- page: Snap-in resources
slug: snap-in-resources
path: ../docs/pages/references/snap-in-resources.mdx
- page: Build Config
slug: build-config
path: ../docs/pages/references/build-config.mdx
- page: Development best practices
slug: best-practices
path: ../docs/pages/best_practices.mdx
Expand Down
Loading