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

Add morpheus_details data-source #255

Merged

Conversation

eamonnotoole
Copy link
Contributor

@eamonnotoole eamonnotoole commented Sep 11, 2024

In this PR we add a data-source to fetch details for an on-prem Morpheus deployment. These details are:

  • access_token
  • valid_till
  • url

This data-source can be used to set the url and access_token fields in a Morpheus provider stanza, and should make it easier for customers to use the Morpheus provider with VMaaS deployments.

The data-source is named hpegl_vmaas_morpheus_details

The changes:

  • we've added tf examples in the examples directory
    • minimal.tf showing just one hpegl stanza for one location and/or space-name
    • multiple.tf showing two hpegl stanzas for two locations
  • we've added a tfdocs template that makes use of these examples in templates/data-sources/vmaas_morpheus_details.md.tmpl
  • we've added a definition of the data-source to resources/data_source_morpheus_token_broker.go
  • we've added a definition of a BrokerClient with a MorpheusDetails data-source to internal/cmp/broker_client.go
    • this BrokerClient is initialised with an APIClient instance created for the Broker API and a corresponding Configuration
    • we've added a newMorhpeusBroker definition in internal/cmp/morpheus_datasource_broker.go which is used in the above initialisation
  • we add a broker_url to the VMaaS provider block
  • we add the Broker Client to pgk/client
    • we add BrokerClient to the Client struct
    • we create the BrokerClient in NewClient
      • we add X-Tenant-ID to the headers for the BrokerClient
      • we don't add any default query parameters
      • we create a NewAPIClient with the broker_url
      • we create a new Configuration for the Broker, the main use of this configuration is to define the query parameters for use with one of the Broker API calls
      • we pass the Broker API Client and this new Configuration to the constructor defined in internal/cmp/broker_client.go

go.mod Outdated Show resolved Hide resolved
In this PR we add a data-source to fetch details for an on-prem Morpheus
deployment.  These details are:
- access_token
- access_token_expires_in
- morpheus_url

This data-source can be used to set the url and access_token fields in a
Morpheus provider stanza, and should make it easier for customers to use
the Morpheus provider with VMaaS deployments.

The data-source is named hpegl_vmaas_morpheus_details

The changes:
- we've added tf examples in the examples directory
  - minimal.tf showing just one hpegl stanza for one location and/or
    space-name
  - multiple.tf showing two hpegl stanzas for two locations
- we've added a tfdocs template that makes use of these examples in
  templates/data-sources/vmaas_morpheus_details.md.tmpl
- we've added a definition of the data-source to
  resources/data_source_morpheus_token_broker.go
- we've added a definition of a BrokerClient with a MorpheusDetails
  data-source to internal/cmp/broker_client.go
  - this BrokerClient is initialised with an APIClient instance created
    for the Broker API and a corresponding Configuration
  - we've added a newMorhpeusBroker definition in
    internal/cmp/morpheus_datasource_broker.go which is used in the
    above initialisation
- we add a broker_url to the VMaaS provider block
- we add the Broker Client to pgk/client
  - we add BrokerClient to the Client struct
  - we create the BrokerClient in NewClient
    - we add X-Tenant-ID to the headers for the BrokerClient
    - we don't add any default query parameters
    - we create a NewAPIClient with the broker_url
    - we create a new Configuration for the Broker, the main use of this
      configuration is to define the query parameters for use with one
      of the Broker API calls
    - we pass the Broker API Client and this new Configuration to the
      constructor defined in internal/cmp/broker_client.go
@eamonnotoole eamonnotoole force-pushed the morpheus-token-data-source branch from 14203a5 to d9a5ee5 Compare September 16, 2024 16:44
We've changed the MorpheusDetails response from the SDK, and we adapt
the data-source definition and and API Read implementation accordingly.
This version of the SDK supports creation of the Broker API Client.
We've updated the fields returned from the data-source.
@eamonnotoole eamonnotoole marked this pull request as ready for review September 19, 2024 10:22
Copy link
Collaborator

@mahesh-hpe mahesh-hpe left a comment

Choose a reason for hiding this comment

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

Pl add tf acceptance test, inside acceptance_test folder

We add an acceptance test to internal/acceptance_test.  We've had to add
a new helper function getBrokerAPIClient() and move some shared code
into getHeadersAndQueryParamsAndIAMVersion() and apiClientSetMeta().
Fixed name of test file and added
acc-testcases/data-sources/morpheus_details.yaml
@eamonnotoole
Copy link
Contributor Author

Acceptance test execution:

➜  hpegl-vmaas-terraform-resources git:(morpheus-token-data-source) ✗ make acceptance case='^TestAccDataSourceMorpheusDetails$'
=== RUN   TestAccDataSourceMorpheusDetails
=== PAUSE TestAccDataSourceMorpheusDetails
=== CONT  TestAccDataSourceMorpheusDetails
--- PASS: TestAccDataSourceMorpheusDetails (295.62s)
PASS
coverage: 61.0% of statements
ok    github.com/HewlettPackard/hpegl-vmaas-terraform-resources/internal/acceptance_test  296.038s  coverage: 61.0% of statements
hpegl-vmaas-terraform-resources git:(morpheus-token-data-source) ✗

@eamonnotoole
Copy link
Contributor Author

Existing acceptance tests:

➜  hpegl-vmaas-terraform-resources git:(morpheus-token-data-source) make acceptance case='^TestAccDataSourceCloud$'
=== RUN   TestAccDataSourceCloudFolder
=== PAUSE TestAccDataSourceCloudFolder
=== RUN   TestAccDataSourceCloud
=== PAUSE TestAccDataSourceCloud
=== CONT  TestAccDataSourceCloudFolder
--- PASS: TestAccDataSourceCloudFolder (523.92s)
=== CONT  TestAccDataSourceCloud
--- PASS: TestAccDataSourceCloud (585.33s)
PASS
coverage: 61.0% of statements
ok  	github.com/HewlettPackard/hpegl-vmaas-terraform-resources/internal/acceptance_test	1109.851s	coverage: 61.0% of statements
➜  hpegl-vmaas-terraform-resources git:(morpheus-token-data-source) 

@reubenur-rahman reubenur-rahman merged commit e455a03 into HewlettPackard:master Sep 25, 2024
1 of 2 checks passed
@eamonnotoole eamonnotoole deleted the morpheus-token-data-source branch September 25, 2024 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants