Repository navigation
Add 1password-cli Feature #16
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ jobs: | |
| strategy: | ||
| matrix: | ||
| features: | ||
| - 1password-cli | ||
| - actionlint | ||
| - elixir-project | ||
| - google-cloud-cli | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,30 @@ | ||||||||||
| # 1password-cli | ||||||||||
|
|
||||||||||
| Install the [1Password CLI](https://developer.1password.com/docs/cli/) (`op`) from 1Password's signed apt repository. | ||||||||||
|
|
||||||||||
| ## Usage | ||||||||||
|
|
||||||||||
| ```json | ||||||||||
| "features": { | ||||||||||
| "ghcr.io/CargoSense/devcontainer-features/1password-cli:1": {} | ||||||||||
| } | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| ## Options | ||||||||||
|
|
||||||||||
| This Feature has no options. It installs the latest `1password-cli` package. | ||||||||||
|
Comment on lines
+12
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
No need to say nothing's there. |
||||||||||
|
|
||||||||||
| ## Signing in | ||||||||||
|
|
||||||||||
| The 1Password desktop app's CLI integration does not reach into a container, so `op` signs in with your account details instead: | ||||||||||
|
|
||||||||||
| ```sh | ||||||||||
| op account add --address <your-team>.1password.com --email <you@example.com> # once; asks for your Secret Key and password | ||||||||||
| eval "$(op signin)" # in each terminal that needs it | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
| `op account add` stores the account in `~/.config/op`. Mount a named volume there (for example `type=volume,source=op-config,target=/home/vscode/.config/op`, owned by the remote user) to keep it across rebuilds. | ||||||||||
|
|
||||||||||
| ## OS Support | ||||||||||
|
|
||||||||||
| This Feature should work on recent versions of Debian/Ubuntu and Linux distributions using the [apt](https://wiki.debian.org/AptCLI) management tool, on `amd64` and `arm64`. | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Practically, |
||||||||||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,12 @@ | ||||||||
| { | ||||||||
| "name": "1Password CLI", | ||||||||
| "id": "1password-cli", | ||||||||
| "version": "1.0.0", | ||||||||
| "description": "Install the 1Password CLI (op) from 1Password's signed apt repository.", | ||||||||
| "documentationURL": "https://github.com/CargoSense/devcontainer-features/tree/main/src/1password-cli", | ||||||||
| "licenseURL": "https://github.com/CargoSense/devcontainer-features/blob/main/LICENSE", | ||||||||
| "installsAfter": [ | ||||||||
| "ghcr.io/devcontainers/features/common-utils", | ||||||||
| "ghcr.io/CargoSense/devcontainer-features/apt-packages" | ||||||||
|
Comment on lines
+9
to
+10
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
The Feature's The |
||||||||
| ] | ||||||||
| } | ||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,58 @@ | ||||||
| #!/usr/bin/env sh | ||||||
|
|
||||||
| # Installs op from 1Password's apt repository, following | ||||||
| # https://developer.1password.com/docs/cli/get-started/ (Debian/Ubuntu), | ||||||
| # including the debsig policy that verifies the package signature. | ||||||
|
|
||||||
| set -e | ||||||
|
|
||||||
| if [ "$(id -u)" -ne 0 ]; then | ||||||
| printf 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.' | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| export DEBIAN_FRONTEND=noninteractive | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| curl_installed="" | ||||||
| gpg_installed="" | ||||||
|
|
||||||
| if ! type curl >/dev/null 2>&1; then | ||||||
| apt-get update --yes | ||||||
| apt-get install --no-install-recommends --yes curl ca-certificates | ||||||
|
|
||||||
| curl_installed="true" | ||||||
| fi | ||||||
|
|
||||||
| if ! type gpg >/dev/null 2>&1; then | ||||||
| apt-get update --yes | ||||||
| apt-get install --no-install-recommends --yes gpg | ||||||
|
|
||||||
| gpg_installed="true" | ||||||
| fi | ||||||
|
|
||||||
| arch="$(dpkg --print-architecture)" | ||||||
| key_url="https://downloads.1password.com/linux/keys/1password.asc" | ||||||
|
|
||||||
| curl -fsSL "${key_url}" | gpg --dearmor --yes --output /usr/share/keyrings/1password-archive-keyring.gpg | ||||||
| echo "deb [arch=${arch} signed-by=/usr/share/keyrings/1password-archive-keyring.gpg] https://downloads.1password.com/linux/debian/${arch} stable main" \ | ||||||
| > /etc/apt/sources.list.d/1password.list | ||||||
|
|
||||||
| mkdir -p /etc/debsig/policies/AC2D62742012EA22 /usr/share/debsig/keyrings/AC2D62742012EA22 | ||||||
| curl -fsSL https://downloads.1password.com/linux/debian/debsig/1password.pol \ | ||||||
| > /etc/debsig/policies/AC2D62742012EA22/1password.pol | ||||||
| curl -fsSL "${key_url}" | gpg --dearmor --yes --output /usr/share/debsig/keyrings/AC2D62742012EA22/debsig.gpg | ||||||
|
|
||||||
| apt-get update --yes | ||||||
| apt-get install --no-install-recommends --yes 1password-cli | ||||||
|
|
||||||
| if [ -n "${curl_installed}" ]; then | ||||||
| apt purge curl --autoremove --yes | ||||||
| fi | ||||||
|
|
||||||
| if [ -n "${gpg_installed}" ]; then | ||||||
| apt purge gpg --autoremove --yes | ||||||
| fi | ||||||
|
|
||||||
| rm -rf /var/lib/apt/lists/* | ||||||
|
|
||||||
| op --version | ||||||
|
Comment on lines
+57
to
+58
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| set -e | ||
|
|
||
| # Optional: Import test library bundled with the devcontainer CLI | ||
| # shellcheck source=/dev/null | ||
| source dev-container-features-test-lib | ||
|
|
||
| # Feature-specific tests | ||
| check "version" op --version | ||
| check "which op" bash -c "which op | grep /usr/bin/op" | ||
|
|
||
| # Report result | ||
| reportResults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extremely pedantic nitpick. 😬