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 namespace resource #44

Merged
merged 7 commits into from
Aug 23, 2022
Merged

Add namespace resource #44

merged 7 commits into from
Aug 23, 2022

Conversation

Morganamilo
Copy link

Also fixes some small issues with the app resource.

Implements #9

Copy link
Contributor

@kavalerov kavalerov left a comment

Choose a reason for hiding this comment

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

I have tested the behaviour, and creating, updating and deleting all seem to be working well.

There are several things to fix re error messages though.

internal/provider/resource_ably_app.go Show resolved Hide resolved
internal/provider/resource_ably_app.go Show resolved Hide resolved
internal/provider/resource_ably_namespace.go Show resolved Hide resolved
internal/provider/resource_ably_namespace.go Show resolved Hide resolved
internal/provider/resource_ably_namespace.go Show resolved Hide resolved
internal/provider/resource_ably_namespace.go Show resolved Hide resolved
internal/provider/resource_ably_namespace.go Show resolved Hide resolved
internal/provider/resource_ably_namespace.go Show resolved Hide resolved
internal/provider/resource_ably_namespace.go Show resolved Hide resolved
internal/provider/resource_ably_namespace.go Show resolved Hide resolved
Copy link
Contributor

@kavalerov kavalerov left a comment

Choose a reason for hiding this comment

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

Actually found one more issue, the field names are different to the ones that we settled on before

internal/provider/models.go Show resolved Hide resolved
Copy link
Contributor

@kavalerov kavalerov left a comment

Choose a reason for hiding this comment

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

LGTM, thanks

@kavalerov
Copy link
Contributor

Follow up issues created: #46 and #47

@kavalerov
Copy link
Contributor

@Morganamilo should we merge this?

@graham-russell
Copy link
Member

@Morganamilo - When testing the change of a namespace_name. I get issues

I updated the test to change the namespace_name in the second step:

// Update and Read testing of ably_app.app0 { Config: testAccAblyNamespaceConfig(app_name, "namespace1", false, false, false, false, false, false), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("ably_app.app0", "name", app_name), resource.TestCheckResourceAttr("ably_namespace.namespace0", "id", "namespace1"), resource.TestCheckResourceAttr("ably_namespace.namespace0", "authenticated", "false"), resource.TestCheckResourceAttr("ably_namespace.namespace0", "persisted", "false"), resource.TestCheckResourceAttr("ably_namespace.namespace0", "persist_last", "false"), resource.TestCheckResourceAttr("ably_namespace.namespace0", "push_enabled", "false"), resource.TestCheckResourceAttr("ably_namespace.namespace0", "tls_only", "false"), resource.TestCheckResourceAttr("ably_namespace.namespace0", "expose_timeserial", "false"), ), },

It then fails with this:

`=== RUN TestAccAblyNamespace
resource_ably_namespace_test.go:13: Step 2/2 error: Error running apply: exit status 1

    Error: Provider produced inconsistent result after apply
    
    When applying changes to ably_namespace.namespace0, provider
    "provider[\"github.com/ably/ably\"]" produced an unexpected new value: .id:
    was cty.StringVal("namespace1"), but now cty.StringVal("namespace0").
    
    This is a bug in the provider, which should be reported in the provider's own
    issue tracker.

--- FAIL: TestAccAblyNamespace (8.47s)`

Could you take a look and figure out why namespace_name update is failing?

@Morganamilo
Copy link
Author

You can't change the name of a namespace, at least from the control API perspective.

I guess you could delete the namespace and make a new one if the user sets a different name. Should the provider do this?

@Morganamilo
Copy link
Author

Also @graham-russell could you give your input on the ImportState comment?

@Morganamilo
Copy link
Author

Never mind, missed the link you sent, figuring it out.

@graham-russell
Copy link
Member

graham-russell commented Aug 22, 2022

you can't change the name of a namespace, at least from the control API perspective

I was just checking this in the UI and was able to change the Namespace id in the UI. I wonder how that works.
If we can't update items, we'll need to implement destroy/recreate functionality. This is fairly common across other providers but I'd still say that it would be better for us to be able to update if we can.

@graham-russell
Copy link
Member

Screenshot 2022-08-22 at 14 09 50
It appears that there is a parameter named 'old_id' that can be used when sending a PUT request to /update

@Morganamilo
Copy link
Author

@Morganamilo - When testing the change of a namespace_name. I get issues

I updated the test to change the namespace_name in the second step:

// Update and Read testing of ably_app.app0 { Config: testAccAblyNamespaceConfig(app_name, "namespace1", false, false, false, false, false, false), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttr("ably_app.app0", "name", app_name), resource.TestCheckResourceAttr("ably_namespace.namespace0", "id", "namespace1"), resource.TestCheckResourceAttr("ably_namespace.namespace0", "authenticated", "false"), resource.TestCheckResourceAttr("ably_namespace.namespace0", "persisted", "false"), resource.TestCheckResourceAttr("ably_namespace.namespace0", "persist_last", "false"), resource.TestCheckResourceAttr("ably_namespace.namespace0", "push_enabled", "false"), resource.TestCheckResourceAttr("ably_namespace.namespace0", "tls_only", "false"), resource.TestCheckResourceAttr("ably_namespace.namespace0", "expose_timeserial", "false"), ), },

It then fails with this:

`=== RUN TestAccAblyNamespace resource_ably_namespace_test.go:13: Step 2/2 error: Error running apply: exit status 1

    Error: Provider produced inconsistent result after apply
    
    When applying changes to ably_namespace.namespace0, provider
    "provider[\"github.com/ably/ably\"]" produced an unexpected new value: .id:
    was cty.StringVal("namespace1"), but now cty.StringVal("namespace0").
    
    This is a bug in the provider, which should be reported in the provider's own
    issue tracker.

--- FAIL: TestAccAblyNamespace (8.47s)`

Could you take a look and figure out why namespace_name update is failing?

I've implemented this myself and have the same issue even with forcenew.

Copy link
Member

@graham-russell graham-russell left a comment

Choose a reason for hiding this comment

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

LGTM!

@Morganamilo Morganamilo merged commit c7b4bbe into main Aug 23, 2022
@Morganamilo Morganamilo deleted the namespace branch August 23, 2022 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants