Skip to content
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

Add importer for startup script #23

Merged
merged 1 commit into from
Nov 30, 2017

Conversation

teh-username
Copy link
Contributor

Test Plan:

Given .tf file:

provider "vultr" {
  api_key = "<api-key>"
}

resource "vultr_startup_script" "example" {
  content   = "#!/bin/bash echo Hello World > /root/hello"
  name      = "example"
  type      = "boot"
}

Running terraform import vultr_startup_script.example SCRIPTID yields:

vultr_startup_script.example: Importing from ID "SCRIPTID"...
vultr_startup_script.example: Import complete!
  Imported vultr_startup_script (ID: SCRIPTID)
vultr_startup_script.example: Refreshing state... (ID: SCRIPTID)

Import successful!

The resources that were imported are shown above. These resources are now in
your Terraform state and will henceforth be managed by Terraform.

Running terraform plan yields:

Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

vultr_startup_script.example: Refreshing state... (ID: SCRIPTID)

------------------------------------------------------------------------

No changes. Infrastructure is up-to-date.

This means that Terraform did not detect any differences between your
configuration and real physical resources that exist. As a result, no
actions need to be performed.

Copy link
Owner

@squat squat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks very good overall. I have two small comments. Fix those and let’s merge it.

@@ -67,6 +70,12 @@ func resourceStartupScriptRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error getting startup script (%s): %v", d.Id(), err)
}

if (lib.StartupScript{}) == script {
log.Printf("[WARN] Removing Startup Script (%s) because it is gone", d.Id())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could you fix the casing of “Startup Script” to be lowercase to match the other log statements like https://github.com/squat/terraform-provider-vultr/blob/master/vultr/resource_startup_script.go#L97

@@ -67,6 +70,12 @@ func resourceStartupScriptRead(d *schema.ResourceData, meta interface{}) error {
return fmt.Errorf("Error getting startup script (%s): %v", d.Id(), err)
}

if (lib.StartupScript{}) == script {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could you reverse the order of these operands? I think it’s geberally easier to read if the subject of the comparison, in this case script, comes first

@squat squat mentioned this pull request Nov 30, 2017
11 tasks
@squat squat merged commit b7c7896 into squat:master Nov 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants