Skip to content

Commit 374795b

Browse files
authored
Merge pull request #553 from gargakshit/main
Add OpenTofu plugin
2 parents c7c3dc1 + a21d7a9 commit 374795b

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

plugins/tofu/plugin.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package tofu
2+
3+
import (
4+
"github.com/1Password/shell-plugins/sdk"
5+
"github.com/1Password/shell-plugins/sdk/schema"
6+
)
7+
8+
func New() schema.Plugin {
9+
return schema.Plugin{
10+
Name: "tofu",
11+
Platform: schema.PlatformInfo{
12+
Name: "OpenTofu",
13+
Homepage: sdk.URL("https://opentofu.org"),
14+
},
15+
Executables: []schema.Executable{
16+
TofuCLI(),
17+
},
18+
}
19+
}

plugins/tofu/terraform.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package tofu
2+
3+
import (
4+
"github.com/1Password/shell-plugins/sdk"
5+
"github.com/1Password/shell-plugins/sdk/needsauth"
6+
"github.com/1Password/shell-plugins/sdk/schema"
7+
)
8+
9+
func TofuCLI() schema.Executable {
10+
return schema.Executable{
11+
Name: "OpenTofu",
12+
Runs: []string{"tofu"},
13+
DocsURL: sdk.URL("https://opentofu.org/docs/cli"),
14+
NeedsAuth: needsauth.IfAll(
15+
needsauth.NotForHelpOrVersion(),
16+
needsauth.NotWithoutArgs(),
17+
),
18+
Uses: []schema.CredentialUsage{
19+
{
20+
Description: "Credentials to use within the OpenTofu project",
21+
SelectFrom: &schema.CredentialSelection{
22+
ID: "project",
23+
IncludeAllCredentials: true,
24+
AllowMultiple: true,
25+
},
26+
Optional: true,
27+
NeedsAuth: needsauth.IfAny(
28+
needsauth.ForCommand("refresh"),
29+
needsauth.ForCommand("init"),
30+
needsauth.ForCommand("state"),
31+
needsauth.ForCommand("plan"),
32+
needsauth.ForCommand("apply"),
33+
needsauth.ForCommand("destroy"),
34+
needsauth.ForCommand("import"),
35+
needsauth.ForCommand("test"),
36+
),
37+
},
38+
},
39+
}
40+
}

0 commit comments

Comments
 (0)