Skip to content

feat: Add support for shutdown_script #79

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

Merged
merged 1 commit into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions docs/resources/agent.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ resource "kubernetes_pod" "dev" {
- `dir` (String) The starting directory when a user creates a shell session. Defaults to $HOME.
- `env` (Map of String) A mapping of environment variables to set inside the workspace.
- `motd_file` (String) The path to a file within the workspace containing a message to display to users when they login via SSH. A typical value would be /etc/motd.
- `shutdown_script` (String) A script to run before the agent is stopped.
- `startup_script` (String) A script to run after the agent starts.
- `troubleshooting_url` (String) A URL to a document with instructions for troubleshooting problems with the agent.

Expand Down
6 changes: 6 additions & 0 deletions provider/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ func agentResource() *schema.Resource {
Optional: true,
Description: "The path to a file within the workspace containing a message to display to users when they login via SSH. A typical value would be /etc/motd.",
},
"shutdown_script": {
ForceNew: true,
Description: "A script to run before the agent is stopped.",
Type: schema.TypeString,
Optional: true,
},
},
}
}
Expand Down
2 changes: 2 additions & 0 deletions provider/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func TestAgent(t *testing.T) {
startup_script = "echo test"
troubleshooting_url = "https://example.com/troubleshoot"
motd_file = "/etc/motd"
shutdown_script = "echo bye bye"
}
`,
Check: func(state *terraform.State) error {
Expand All @@ -51,6 +52,7 @@ func TestAgent(t *testing.T) {
"connection_timeout",
"troubleshooting_url",
"motd_file",
"shutdown_script",
} {
value := resource.Primary.Attributes[key]
t.Logf("%q = %q", key, value)
Expand Down