> For the complete documentation index, see [llms.txt](https://manual.dxable.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manual.dxable.com/1password/inject.md).

# inject

シークレット参照でテンプレート化されたファイルにシークレットを挿入します。

```
op inject [flags]
```

#### **Flags** <a href="#go875tnsr34r" id="go875tnsr34r"></a>

```
    --file-mode filemode   Set filemode for the output file. It is ignored without the --out-file flag. (default 0600)
-f, --force                Do not prompt for confirmation.
-i, --in-file string       The filename of a template file to inject.
-o, --out-file string      Write the injected template to a file instead of stdout.
```

[秘密の参照について詳しく紹介します。](https://developer.1password.com/docs/cli/secret-references)

シークレット参照でテンプレート化された構成ファイルを渡し、実際のシークレットが置き換えられた構成ファイルを受け取ることができます。解決されたファイルは不要になったら必ず削除してください。

[シークレットを構成ファイルに読み込む方法について詳しく紹介します。](https://developer.1password.com/docs/cli/secrets-config-files)

#### [**例**](https://developer.1password.com/docs/cli/reference/commands/inject/#examples) <a href="#p0uuw3ok0l3p" id="p0uuw3ok0l3p"></a>

```
echo "db_password: {{ op://app-prod/db/password }}" | op inject
db_password: fX6nWkhANeyGE27SQGhYQ
```

設定テンプレート ファイルにシークレットを挿入します。

```
cat config.yml.tpl
db_password: {{ op://app-prod/db/password }}
```

```
op inject -i config.yml.tpl -o config.yml && cat config.yml
db_password: fX6nWkhANeyGE27SQGhYQ
```

複数のシークレットを連結できます:

```
echo "db_url: postgres://{{ op://lcl/db/user }}:{{ op://lcl/db/pw }}@{{ op://lcl/db/host }}:{{ op://lcl/db/port }}/{{ op://my-app-prd/db/db }}" | op inject
db_url: postgres://admin:admin@127.0.0.1:5432/my-app"
```

シークレット参照内の変数を使用して、さまざまな環境のさまざまなシークレット セットを切り替えます。

```
echo "db_password: op://$env/db/password" | env=prod op inject
db_password: fX6nWkhANeyGE27SQGhYQ
```
