From eb26ae7378144b02cc53faeebb8352c1512d052e Mon Sep 17 00:00:00 2001 From: Ian Neubert Date: Tue, 3 Mar 2026 16:22:20 -0500 Subject: [PATCH] Add OpenTofu CLI support to Terraform plugin Add OpenTofu as a new executable in the existing Terraform plugin, allowing `tofu` commands to authenticate via 1Password shell plugins. Closes #483 --- plugins/terraform/opentofu.go | 40 +++++++++++++++++++++++++++++++++++ plugins/terraform/plugin.go | 1 + 2 files changed, 41 insertions(+) create mode 100644 plugins/terraform/opentofu.go diff --git a/plugins/terraform/opentofu.go b/plugins/terraform/opentofu.go new file mode 100644 index 000000000..cf2e4b8b2 --- /dev/null +++ b/plugins/terraform/opentofu.go @@ -0,0 +1,40 @@ +package terraform + +import ( + "github.com/1Password/shell-plugins/sdk" + "github.com/1Password/shell-plugins/sdk/needsauth" + "github.com/1Password/shell-plugins/sdk/schema" +) + +func OpenTofuCLI() schema.Executable { + return schema.Executable{ + Name: "OpenTofu CLI", + Runs: []string{"tofu"}, + DocsURL: sdk.URL("https://opentofu.org/docs/cli/"), + NeedsAuth: needsauth.IfAll( + needsauth.NotForHelpOrVersion(), + needsauth.NotWithoutArgs(), + ), + Uses: []schema.CredentialUsage{ + { + Description: "Credentials to use within the OpenTofu project", + SelectFrom: &schema.CredentialSelection{ + ID: "project", + IncludeAllCredentials: true, + AllowMultiple: true, + }, + Optional: true, + NeedsAuth: needsauth.IfAny( + needsauth.ForCommand("refresh"), + needsauth.ForCommand("init"), + needsauth.ForCommand("state"), + needsauth.ForCommand("plan"), + needsauth.ForCommand("apply"), + needsauth.ForCommand("destroy"), + needsauth.ForCommand("import"), + needsauth.ForCommand("test"), + ), + }, + }, + } +} diff --git a/plugins/terraform/plugin.go b/plugins/terraform/plugin.go index 404fb9b94..ef282f1d9 100644 --- a/plugins/terraform/plugin.go +++ b/plugins/terraform/plugin.go @@ -14,6 +14,7 @@ func New() schema.Plugin { }, Executables: []schema.Executable{ TerraformCLI(), + OpenTofuCLI(), }, } }