-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
[WIP] feat: add resource for managing custom applications #109
Conversation
"commercetools_channel": resourceChannel(), | ||
"commercetools_custom_application": resourceCustomApplication(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the new resource. The other changes here are because I sorted the list alphabetically.
// TerraformContext holds the HTTP and GraphQL clients to be used by the Terraform resources. | ||
// We recommend to use the utility functions `getClient` and `getGraphQLClient` | ||
// to get the necessary client object. | ||
type TerraformContext struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This struct is used to hold different values that are used within the resources. Besides the HTTP client, I added the GraphQLClient and the ProjectKey.
// https://github.com/hashicorp/terraform-plugin-sdk/issues/62 | ||
// https://github.com/hashicorp/terraform-plugin-sdk/issues/155. | ||
"navbar_menu": { | ||
Type: schema.TypeList, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In JSON, this is an object, not a list. However, as far as I understand, nested object maps are not supported yet by the terraform sdk. See comment above
12786f6
to
7cf828b
Compare
@emmenko sorry for getting back to this so late. I'm working on extracting your code and moving it to the commercetools-go-sdk project. See labd/commercetools-go-sdk#52 However i'm running into a permission issue so would be great to get some help over there |
DO NOT MERGE YET
Since Custom Applications are in public beta now, we can provide a Terraform resource to manage their "registration" (currently possible only via the Merchant Center).
https://docs.commercetools.com/custom-applications/register-applications/configuring-a-custom-application
Some important notes for the reviewers:
the MC API endpoint to allow authorized requests needs to be adjusted a bit. The PR is already being reviewed and it will probably be available this week.
I decided to add the
mc_api_url
as a required field to the TF provider, in order to configure the graphql HTTP client.I tested this manually locally and it seems to work as it should. The error handling of the graphql library is a bit "buggy" (there are some issues already), for example when the HTTP response is not a
200
. I couldn't find a "better" graphql client, we can still write our own (it shouldn't be too difficult). We might also consider adding it to the go-sdk library.I only added a basic unit test, I'm a bit unsure about the acceptance tests, as we would need to use the production APIs.