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

Fix build examples #114

Merged

Conversation

gastonfournier
Copy link
Collaborator

About the changes

Amends to original PR

@gastonfournier gastonfournier force-pushed the docs/define_import_docs_collab branch from 5e1c775 to 29adb29 Compare January 24, 2024 18:51
@@ -68,6 +68,7 @@ resource "unleash_project_access" "sample_project_access" {
}

resource "unleash_project_access" "default_project_access" {
project = "default"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is required by the resource definition

@@ -14,8 +14,8 @@ ProjectAccess schema

```terraform
import {
project = "default"
to = unleash_project_access.default_project_access
id = "default"
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This property has to be id

Comment on lines -16 to -30
import {
id = 5
to = unleash_role.project_member_role
}

resource "unleash_role" "project_member_role" {
permissions = [{
name = "CREATE_PROJECT"
}, {
name = "UPDATE_PROJECT"
}, {
name = "DELETE_PROJECT"
}]
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed cause we can't modify existing roles, import might work but in other circumstances such as running through the CLI. For predefined roles data should be used

@@ -0,0 +1,42 @@
import {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added to the automated test

Comment on lines +137 to +141
// validate if project was found
if project.Id == "" {
resp.Diagnostics.AddError(fmt.Sprintf("Project with id %s not found", state.Id.ValueString()), "NotFound")
return
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This validation was missing

Comment on lines +61 to +67
{
Config: `resource "unleash_project" "newly_imported" {}`,
ImportStateId: "TestId2",
ResourceName: "unleash_project.newly_imported",
ImportState: true,
ImportStateVerify: true,
},
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines +205 to +207
if state.SendEmail.IsNull() || state.SendEmail.IsUnknown() {
state.SendEmail = types.BoolValue(false)
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When not defined should default to false

@@ -74,6 +74,34 @@ func TestAccUserResource(t *testing.T) {
})
}

func TestAccUserResourceImport(t *testing.T) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Add import test as a different test suite because in the other one we run with CheckDestroy which somehow messes up with the test import. I didn't dig too much on it, because this works

@gastonfournier gastonfournier force-pushed the docs/define_import_docs_collab branch from 29adb29 to 8ec09b9 Compare January 24, 2024 18:52
@andreas-unleash andreas-unleash merged commit 1ff3aee into docs/define_import_docs Jan 25, 2024
12 checks passed
@andreas-unleash andreas-unleash deleted the docs/define_import_docs_collab branch January 25, 2024 08:02
andreas-unleash added a commit that referenced this pull request Jan 25, 2024
* chore: define import examples for resources

* chore: define import examples for resources

* chore: define import examples for resources

* chore: define import examples for resources

* Fix build examples (#114)

---------

Co-authored-by: Gastón Fournier <[email protected]>
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.

2 participants