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

Feat: add env0_projects (plural) data resource #787

Merged
merged 3 commits into from
Feb 2, 2024

Conversation

TomerHeber
Copy link
Collaborator

Issue & Steps to Reproduce / Feature Request

resolves #786

Solution

  1. Added the new data-source.
  2. Added acceptance tests.
  3. Updated integration tests.
  4. Added an example.

Computed: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"name": {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

decided to add name and id.
If anything else is required (or removed) let me know.

Copy link
Contributor

@razbensimon razbensimon Feb 1, 2024

Choose a reason for hiding this comment

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

I think we need to provide also those

isArchived?: boolean;
hierarchy: string;
parentProjectId?: string;

The last two are for creating custom logic around sub-projects.
For the first one (isArchived) we may want to filter by it by default. Can we?
and if possible add a parameter to include_archived_projects.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see that we don't have the ability to filter via the API.
So the filter of include_archived_projects should be locally in the provider.
WDYS?

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 the API:
https://docs.env0.com/reference/projects-find-by-organization-id

Will it return archived projects?
What should be the default of include_archived_projects true or false?

I can return the 3 additional values if needed. Just want to be sure there's a use-case for that. If you believe there is. happy to do so. Please confirm.

Copy link
Contributor

Choose a reason for hiding this comment

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

Will it return archived projects?

Yes

What should be the default of include_archived_projects true or false?

false. Meaning we should filter them locally by default.
Add them to the state only if include_archived_projects is true
This makes more sense because I don't see users use the archived ones so much.

Copy link
Contributor

@razbensimon razbensimon Feb 1, 2024

Choose a reason for hiding this comment

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

BTW
hierarchy looks like uuid|uuid|.....
and parentProjectId is just uuid.

parentProjectId returned only on sub-projects.
hierarchy by default equals its own id (if not part of a tree).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@razbensimon - I have added the additional code you requested.

52f69fa

@TomerHeber TomerHeber requested a review from yaronya January 30, 2024 17:26
Copy link
Contributor

@razbensimon razbensimon left a comment

Choose a reason for hiding this comment

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

LGTM

Edit:
please see

@github-actions github-actions bot added ready to merge PR approved - can be merged once the PR owner is ready and removed pending final review labels Feb 1, 2024
@razbensimon razbensimon self-requested a review February 1, 2024 21:26
Comment on lines +13 to +29
project1 := client.Project{
Id: "id0",
Name: "my-project-1",
ParentProjectId: "p1",
Hierarchy: "adsas|fdsfsd",
}

project2 := client.Project{
Id: "id1",
Name: "my-project-2",
}

project3 := client.Project{
Id: "id1",
Name: "my-project-2",
IsArchived: true,
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just to make it more synced with real data

Suggested change
project1 := client.Project{
Id: "id0",
Name: "my-project-1",
ParentProjectId: "p1",
Hierarchy: "adsas|fdsfsd",
}
project2 := client.Project{
Id: "id1",
Name: "my-project-2",
}
project3 := client.Project{
Id: "id1",
Name: "my-project-2",
IsArchived: true,
}
project1 := client.Project{
Id: "id1",
Name: "my-project-1",
Hierarchy: "id1",
IsArchived: false,
}
project2 := client.Project{
Id: "id2",
Name: "my-project-2",
Hierarchy: "id1|id2",
IsArchived: false,
ParentProjectId: "id1",
}
project3 := client.Project{
Id: "id3",
Name: "my-project-3",
Hierarchy: "id3",
IsArchived: true,
}

Copy link
Contributor

@razbensimon razbensimon left a comment

Choose a reason for hiding this comment

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

Thanks @TomerHeber

@TomerHeber TomerHeber merged commit b9c02fd into main Feb 2, 2024
6 checks passed
@TomerHeber TomerHeber deleted the feat-add-env0_projects-#786 branch February 2, 2024 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add env0_projects (plural) data resource
2 participants