-
Notifications
You must be signed in to change notification settings - Fork 4
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 workspaces data source (v1beta1 list workspaces equivalent) #6
Conversation
if resp.Diagnostics.HasError() { | ||
return | ||
} |
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.
does this print the error msg out too?
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.
yep, whatever is in resp.Diagnostics gets printed out at the end
sometimes, you'll see that i add my own error thats because the error didnt come from terraform but from somewhere else so terraform doesnt know an error occured, eg. if we called the api and there was an error, so in that case I add our own error to resp.Diagnostics
@@ -107,7 +107,11 @@ func (d *workspaceDataSource) Read( | |||
} | |||
|
|||
// Populate the model with the response data | |||
data.ReadFromResponse(ctx, workspace.JSON200) | |||
diags := data.ReadFromResponse(ctx, workspace.JSON200) |
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.
what is workspace.JSON200
? and why is it called JSON200
(is it supposed to represent a 200 resp code?)
notice this being referenced and used a lot
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.
workspace is the response object from the API client, workspace.JSON200 gives us the platformv1beta1.Workspace
object
we use a different client here than we do for the component tests, which is why there are these syntax differences
"id": datasource.StringAttribute{ | ||
func WorkspaceDataSourceSchemaAttributes() map[string]datasourceSchema.Attribute { | ||
return map[string]datasourceSchema.Attribute{ | ||
"id": datasourceSchema.StringAttribute{ | ||
MarkdownDescription: "Workspace identifier", |
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.
general q - with the MarkdownDescription
for all the Schema Attributes, how does this actually look, like do you have an example? will this operate similar to doc strings in our models?
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.
its in docs/data-sources/workspaces.md
README.md
Outdated
@@ -35,6 +35,7 @@ Then commit the changes to `go.mod` and `go.sum`. | |||
## Using the provider | |||
|
|||
```shell | |||
export ASTRI_API_TOKEN=<token> |
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.
export ASTRI_API_TOKEN=<token> | |
export ASTRO_API_TOKEN=<token> |
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.
Should we add a note and link to the doc on how to create this token?
https://docs.astronomer.io/astro/automation-authentication#step-1-create-an-api-token
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.
definitely
|
||
### Optional | ||
|
||
- `names` (List of String) |
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.
Is this supposed to be list of workspace names?
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.
yep that you can query if you want
func WorkspaceDataSourceSchemaAttributes() map[string]datasource.Attribute { | ||
return map[string]datasource.Attribute{ | ||
"id": datasource.StringAttribute{ | ||
func WorkspaceDataSourceSchemaAttributes() map[string]datasourceSchema.Attribute { |
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.
Can we add some tests for both get workspace and list workspaces?
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.
terraform unit tests aren't really a thing with the framework - they just do acceptance integration tests
those will be set up in the near future
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.
Thanks for addressing the comments.
terraform { | ||
required_providers { | ||
astronomer = { | ||
source = "registry.terraform.io/astronomer/astronomer" |
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.
should this be astronomer/astro since the provider is for astro the product?
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 we can change it
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.
what do you think @sunkickr ?
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.
astronomer/astro
makes more sense to me as well
Description
workspaces
data source to the terraform provider🎟 Issue(s)
(https://github.com/astronomer/astro/issues/19655)
🧪 Functional Testing
main.tf
file:output:
📸 Screenshots
📋 Checklist
make test
before taking out of draftmake fmt
before taking out of draft