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

Update Terraform plugin sdk v2 #67

Merged
merged 6 commits into from
Sep 3, 2020
Merged

Conversation

KeisukeYamashita
Copy link
Contributor

@KeisukeYamashita KeisukeYamashita commented Aug 31, 2020

WHAT

Updated

  • Context functions
  • Add description to all resources

WHY

  • To maintain

Ref

@KeisukeYamashita KeisukeYamashita self-assigned this Aug 31, 2020
@KeisukeYamashita KeisukeYamashita linked an issue Aug 31, 2020 that may be closed by this pull request
@KeisukeYamashita
Copy link
Contributor Author

@micnncim @dragon3 @nessex
Any updates?

Copy link
Contributor

@dragon3 dragon3 left a comment

Choose a reason for hiding this comment

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

Looks good to me 👍
( I added some notes for me 😬 and I'd like to upgrade the SDK for https://github.com/mercari/terraform-provider-openpgp as well )

Comment on lines +13 to +29
var debugMode bool

flag.BoolVar(&debugMode, "debuggable", false, "set to true to run the provider with support for debuggers like delve")
flag.Parse()

if debugMode {
err := plugin.Debug(context.Background(), "registry.terraform.io/mercari/spinnaker",
&plugin.ServeOpts{
ProviderFunc: spinnaker.Provider,
})
if err != nil {
log.Println(err.Error())
}
} else {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: spinnaker.Provider})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -35,6 +36,6 @@ func datasourceApplication() *schema.Resource {
Computed: true,
},
},
Read: resourceSpinnakerProjectRead,
ReadContext: resourceSpinnakerApplicationRead,
Copy link
Contributor

Choose a reason for hiding this comment

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

Just question, the previous implementation was incorrect, right? ( It should have been Application, not Project )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it was incorrect 🙇

@@ -45,6 +46,6 @@ func datasourceCanaryConfig() *schema.Resource {
},
},
},
Read: resourceSpinnakerCanaryConfigRead,
ReadContext: resourceSpinnakerCanaryConfigRead,
Copy link
Contributor

Choose a reason for hiding this comment

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

[note]
More Support for context.Context

for example, the helper/schema.CreateFunc, helper/schema.UpdateFunc, helper/schema.ReadFunc, and helper/schema.DeleteFunc types all got context-aware versions (helper/schema.CreateContextFunc, helper/schema.UpdateContextFunc, helper/schema.ReadContextFunc, helper/schema.DeleteContextFunc, respectively). The old versions are now deprecated, and we recommend you upgrade to the context-aware versions to get their improvements, ...

)

var testAccProviders map[string]terraform.ResourceProvider
var testAccProviders map[string]*schema.Provider
Copy link
Contributor

Choose a reason for hiding this comment

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

[note]
Removal of the terraform.ResourceProvider Interface

The terraform.ResourceProvider interface has been removed. The concrete *helper/schema.Provider type should be used in its place.

@@ -88,32 +91,34 @@ type Permissions struct {
Write []string `json:"WRITE"`
}

func resourceSpinnakerApplicationCreate(d *schema.ResourceData, meta interface{}) error {
func resourceSpinnakerApplicationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
Copy link
Contributor

Choose a reason for hiding this comment

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

[note]
Support for Diagnostics

A number of new functions have been added that return a diag.Diagnostics type. This type can be used to return multiple errors and warnings to Terraform, and to associate those errors or warnings with specific fields.

return nil
}

func resourceSpinnakerApplicationExists(d *schema.ResourceData, meta interface{}) (bool, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

[note]
Deprecation of helper/schema.ExistsFunc

The helper/schema.ExistsFunc (usually set as the Exists property on helper/schema.Resource) is now deprecated.

@KeisukeYamashita
Copy link
Contributor Author

Thank you for your review 🙇

@KeisukeYamashita KeisukeYamashita merged commit d9f972d into master Sep 3, 2020
@KeisukeYamashita KeisukeYamashita deleted the update-plugin-sdk-v2 branch September 3, 2020 02:13
KeisukeYamashita added a commit that referenced this pull request Jan 14, 2021
Update Terraform plugin sdk v2

Signed-off-by: KeisukeYamashita <19yamashita15@gmail.com>
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.

Update the terraform-provider-sdk to v2
2 participants