-
Notifications
You must be signed in to change notification settings - Fork 14
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 data provider for workflows thru data env0_environment #957
Conversation
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"id": { | ||
Type: schema.TypeString, |
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.
for now I have added 'alias' and 'id'. More can be added in the future if required.
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.
Nice work!
@@ -32,6 +32,13 @@ func TestEnvironmentDataSource(t *testing.T) { | |||
BlueprintId: template.Id, | |||
BlueprintRevision: "revision", | |||
Output: []byte(`{"a": "b"}`), | |||
WorkflowFile: &client.WorkflowFile{ | |||
Environments: map[string]client.WorkflowSubEnvironment{ | |||
"db": { |
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 you please add 1 more to the test so it will show we handle multiple and not just the first/last/random in the object
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! added!
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 also just added a sort - too keep order consistent.
@@ -98,6 +98,25 @@ func dataEnvironment() *schema.Resource { | |||
Description: "The token id used for repo integrations (Used by Gitlab or Azure DevOps)", | |||
Computed: true, | |||
}, | |||
"sub_environment_configuration": { |
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.
Do we already return this data to the resource?
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'm unsure I understand the question.
But I'll try to answer...
The environment_resource does return this... but is not the required implementation.
It does not do what's needed for the data source.
} | ||
} | ||
|
||
slices.SortFunc(subEnvironments, func(a, b interface{}) int { |
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.
the order in a map can be inconsistent...
Added a sort to the slice to be sure order is always the same.
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.
this is mostly for tests... but who knows... maybe this inconsistency can also cause real issues in the 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.
NICE WORK AS ALWAYS
Issue & Steps to Reproduce / Feature Request
resolves #956
Solution
To keep the implementation simple I decided to use the existing data_environment. (Instead of creating a new data source).