-
Notifications
You must be signed in to change notification settings - Fork 156
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 tfe_projects
data source
#1339
Add tfe_projects
data source
#1339
Conversation
28d86c7
to
ef3e3a0
Compare
ef3e3a0
to
59ab0b8
Compare
59ab0b8
to
be24691
Compare
4b3169b
to
cb89051
Compare
Can this one be reviewed, or does it require any additional info ? |
cb89051
to
30a8841
Compare
30a8841
to
fae46c4
Compare
23f978d
to
331f2ca
Compare
fa20532
to
2939a40
Compare
2939a40
to
a5d826e
Compare
@tdevelioglu could you please provide feedback so we can proceed with the changes, thanks. |
4c08483
to
540523c
Compare
resource.TestCheckResourceAttrSet( | ||
"data.tfe_projects.all", "projects.0.id"), | ||
resource.TestCheckResourceAttr( | ||
"data.tfe_projects.all", "projects.0.name", "Default Project"), |
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.
@tdevelioglu The test might fail because of the ordering of the 4 projects. Hence we need to do something like this:
Declare this array: prjNames := []string{"Default Project", prj1.Name, prj2.Name, prj3.Name}
and then
resource.TestCheckResourceAttrWith(
"data.tfe_projects.all", "projects.0.name", func(value string) error {
for _, name := range prjNames {
if name == value {
return nil
}
}
return fmt.Errorf("Excepted project name %s to be in the list %v but not found. ", value, prjNames)
}),
instead of
resource.TestCheckResourceAttr(
"data.tfe_projects.all", "projects.0.name", "Default Project"),
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.
Sure, but how do we check both description and name are correct ?
Related, I am unable to further testacc these changes myself due to lack of permission.
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.
@tdevelioglu For description you will also have to create something like:
description := []string{"", prj1.Description, prj2.Description, prj3.Description}
and then
resource.TestCheckResourceAttrWith(
"data.tfe_projects.all", "projects.0.description", func(value string) error {
for _,description := range description {
if description == value {
return nil
}
}
return fmt.Errorf("Excepted project description %s to be in the list %v but not found. ", value, description)
}),
But to be honest, I think we can remove and ignore description from this test entirely since the purpose of this test is to check if project is returned or not.
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.
If it helps, you can reference this: https://github.com/hashicorp/terraform-provider-tfe/pull/1506/files#diff-94dc573614fee0ef601ca30331d457363deb060c4ce0af0d93c51dff59f62943
Let me know if you are not able to access this.
I have confirm that the CI test passes with this.
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.
I've dropped the description and order-dependent checks, can you check if this passes ?
540523c
to
75bebba
Compare
Can be used to retrieve all projects in an organization.
75bebba
to
342df3d
Compare
I have opened another PR with your commits present. I'll look into the CI tests there and get it merged as soon as possible. We can close this PR now. Thank you for addressing the feedback! |
Description
Add
tfe_projects
data source for retrieving organization projects.Testing plan
Create and retrieve projects with the new data source.
Example configuration
External links
Output from acceptance tests