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 data provider for workflows thru data env0_environment #957

Merged
merged 3 commits into from
Sep 24, 2024

Conversation

TomerHeber
Copy link
Collaborator

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).

  1. Updated the schema.
  2. Added the code the writes to the schema.
  3. Updated the acceptance tests and the harness tests.

Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"id": {
Type: schema.TypeString,
Copy link
Collaborator Author

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.

Copy link
Contributor

@GiliFaroEnv0 GiliFaroEnv0 left a 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": {
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure! added!

Copy link
Collaborator Author

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": {
Copy link
Contributor

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?

Copy link
Collaborator Author

@TomerHeber TomerHeber Sep 23, 2024

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.

@GiliFaroEnv0 GiliFaroEnv0 removed the request for review from yaronya September 23, 2024 06:49
}
}

slices.SortFunc(subEnvironments, func(a, b interface{}) int {
Copy link
Collaborator Author

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.

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 mostly for tests... but who knows... maybe this inconsistency can also cause real issues in the future...

Copy link
Contributor

@GiliFaroEnv0 GiliFaroEnv0 left a 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

@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 Sep 24, 2024
@TomerHeber TomerHeber merged commit a6acb67 into main Sep 24, 2024
9 checks passed
@TomerHeber TomerHeber deleted the feat-data-sub-env-#956 branch September 24, 2024 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature integration-tests provider ready to merge PR approved - can be merged once the PR owner is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add data provider for workflows thru data env0_environment or new data env0_workflow_environment
2 participants