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

New data-source: azurerm_kubernetes_service_versions #3382

Merged
merged 20 commits into from
May 16, 2019

Conversation

alexsomesan
Copy link
Member

This datasource retrieves available versions of container orchestrators.

It enables users to dynamically select one of the supported Kubernetes versions when provisioning
AKS clusters, for example.

Tested locally

» TF_ACC=1 ./azurerm.test -test.v -test.run '^TestAccDataSourceArmContainerOrchestratorVersions'                                                                                                                                         alex@alexs-macbook
=== RUN   TestAccDataSourceArmContainerOrchestratorVersions_basic
--- PASS: TestAccDataSourceArmContainerOrchestratorVersions_basic (29.06s)
=== RUN   TestAccDataSourceArmContainerOrchestratorVersions_filtered
--- PASS: TestAccDataSourceArmContainerOrchestratorVersions_filtered (27.23s)
PASS
------------------------------------------------------------

@alexsomesan alexsomesan requested a review from a team May 6, 2019 13:12
@alexsomesan
Copy link
Member Author

Tests still pass.

Copy link
Contributor

@paultyng paultyng left a comment

Choose a reason for hiding this comment

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

LGTM, should probably have @katbyte or @tombuildsstuff take a peek prior to merging though.

@alexsomesan
Copy link
Member Author

I'd prefer that they do as well.
I'm going to leave it up to them to merge, unless more changes are needed.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Left a few comments inline

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks for the revisions @alexsomesan, LGTM now

however I think @tombuildsstuff had a comment on the resource's name so I will hold off merging until he comments

@alexsomesan
Copy link
Member Author

I am unconvinced myself about the name. It's rather unwieldy, TBH.

For lack of a better option I went with what the convention dictated and composed it from the name of the API resource. I'm open to any other suggestions.

@katbyte
Copy link
Collaborator

katbyte commented May 12, 2019

@alexsomesan, discussed with @ tombuildsstuff, and as much as orchestrator is a fantastic word i'd like to use as much as possible we think renaming it to azurerm_kubernetes_version and dropping the type parameter is the ideal path forward.

@alexsomesan
Copy link
Member Author

That sounds fine by me. I'll make the necessary adaptations.

I guess we do still want to filter the output of ListOrchestrators by OrchestratorType == "Kubernetes" even if we drop the type parameter, right?

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @alexsomesan

Thanks for pushing those changes - as discussed IRL can we make this azurerm_kubernetes_service_versions rather than container_orchestrator_versions?

Thanks!

azurerm/provider.go Outdated Show resolved Hide resolved
azurerm/data_source_container_orchestrator_versions.go Outdated Show resolved Hide resolved
azurerm/data_source_container_orchestrator_versions.go Outdated Show resolved Hide resolved
azurerm/data_source_container_orchestrator_versions.go Outdated Show resolved Hide resolved
azurerm/data_source_container_orchestrator_versions.go Outdated Show resolved Hide resolved
listResp, err := client.ListOrchestrators(ctx, location, "managedClusters")
if err != nil {
if utils.ResponseWasNotFound(listResp.Response) {
return fmt.Errorf("Error: Container Orchestrators not found for location %q", location)
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the use-case for this, when AKS isn't supported in that region?

Copy link
Member Author

Choose a reason for hiding this comment

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

I would say yes, but I'm not 100% sure this is the right error to check for that case. Any idea how to confirm it?

The API docs only mention positive responses. Does that mean there can be no errors returned?
https://docs.microsoft.com/en-us/rest/api/container-service/container%20service%20client/listorchestrators

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm 99% sure that'll come through as a 404; it's generally something along the lines of the API version '2019-01-01' was not found for the Resource Provider 'Microsoft.ContainerService'

azurerm/data_source_container_orchestrator_versions.go Outdated Show resolved Hide resolved
azurerm/data_source_container_orchestrator_versions.go Outdated Show resolved Hide resolved
@katbyte katbyte changed the title New data-source: azurerm_container_orchestrator_versions New data-source: azurerm_kubernetes_service_versions May 16, 2019
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

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

hey @alexsomesan

Thanks for pushing those changes - I've left some comments inline (mostly) around the renaming but this is otherwise looking good to me; so that we can get this released in the v1.28 release I'm going to push some commits to fix that, I hope you don't mind!

Thanks!

client := meta.(*ArmClient).containerServicesClient
ctx := meta.(*ArmClient).StopContext

location := d.Get("location").(string)
Copy link
Contributor

Choose a reason for hiding this comment

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

we probably want to run this through azurermNormalizeLocation(location) to ensure this value's normalized?

versions := []string{}
for _, rawV := range *listResp.Orchestrators {
if rawV.OrchestratorType != nil && rawV.OrchestratorVersion != nil {
if *rawV.OrchestratorType == "Kubernetes" {
Copy link
Contributor

Choose a reason for hiding this comment

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

given the history with some of the API's, we probably want to be doing this case insensitively:

Suggested change
if *rawV.OrchestratorType == "Kubernetes" {
if strings.EqualsFold(*rawV.OrchestratorType, "Kubernetes") {

azurerm/provider.go Show resolved Hide resolved
@@ -131,6 +131,10 @@
<a href="/docs/providers/azurerm/d/client_config.html">azurerm_client_config</a>
</li>

<li<%= sidebar_current("docs-azurerm-datasource-container-orchestrator-versions") %>>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<li<%= sidebar_current("docs-azurerm-datasource-container-orchestrator-versions") %>>
<li<%= sidebar_current("docs-azurerm-datasource-kubernetes-service-versions") %>>

@@ -131,6 +131,10 @@
<a href="/docs/providers/azurerm/d/client_config.html">azurerm_client_config</a>
</li>

<li<%= sidebar_current("docs-azurerm-datasource-container-orchestrator-versions") %>>
<a href="/docs/providers/azurerm/d/container_orchestrator_versions.html">container_orchestrator_versions</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<a href="/docs/providers/azurerm/d/container_orchestrator_versions.html">container_orchestrator_versions</a>
<a href="/docs/providers/azurerm/d/kubernetes_service_versions.html"> azurerm_kubernetes_service_versions</a>

}

output "latest_version" {
value = "${data.azurerm_container_orchestrator_versions.current.latest_version}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
value = "${data.azurerm_container_orchestrator_versions.current.latest_version}"
value = "${data.azurerm_kubernetes_service_versions.current.latest_version}"


# Data Source: azurerm_container_orchestrator_versions

Use this data source to access information about available versions of orchestrators supported by the Azure Container services.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Use this data source to access information about available versions of orchestrators supported by the Azure Container services.
Use this data source to access information about the available versions of Kubernetes supported by the Azure Kubernetes Service.

@@ -0,0 +1,38 @@
---
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_container_orchestrator_versions"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
page_title: "Azure Resource Manager: azurerm_container_orchestrator_versions"
page_title: "Azure Resource Manager: azurerm_kubernetes_service_versions"

## Argument Reference

* `location` - (Required) Specifies the location in which to query for versions.
* `orchestrator_type` - (Optional) The type of orchestrator for which to fetch versions. Right now the only supported value is `Kubernetes`. If omitted, defaults to `Kubernetes`.
Copy link
Contributor

Choose a reason for hiding this comment

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

this has been removed so:

Suggested change
* `orchestrator_type` - (Optional) The type of orchestrator for which to fetch versions. Right now the only supported value is `Kubernetes`. If omitted, defaults to `Kubernetes`.


* `location` - (Required) Specifies the location in which to query for versions.
* `orchestrator_type` - (Optional) The type of orchestrator for which to fetch versions. Right now the only supported value is `Kubernetes`. If omitted, defaults to `Kubernetes`.
* `version_prefix` - (Optional) A string prefix used to filter the versions retrieved by the query. When this argument is specified, only the versions which match this prefix are returned.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* `version_prefix` - (Optional) A string prefix used to filter the versions retrieved by the query. When this argument is specified, only the versions which match this prefix are returned.
* `version_prefix` - (Optional) A prefix filter for the versions of Kubernetes which should be returned; for example `1.x` will return `1.9` to `1.14`, whereas `1.12` will return `1.12.2.

katbyte and others added 13 commits May 16, 2019 16:55
…st.go

Co-Authored-By: alexsomesan <alex.somesan@gmail.com>
…st.go

Co-Authored-By: alexsomesan <alex.somesan@gmail.com>
Co-Authored-By: alexsomesan <alex.somesan@gmail.com>
Co-Authored-By: Tom Harvey <tombuildsstuff@users.noreply.github.com>
Co-Authored-By: Tom Harvey <tombuildsstuff@users.noreply.github.com>
Co-Authored-By: Tom Harvey <tombuildsstuff@users.noreply.github.com>
Co-Authored-By: Tom Harvey <tombuildsstuff@users.noreply.github.com>
Co-Authored-By: Tom Harvey <tombuildsstuff@users.noreply.github.com>
Co-Authored-By: Tom Harvey <tombuildsstuff@users.noreply.github.com>
@tombuildsstuff
Copy link
Contributor

Tests pass:

$ acctests azurerm TestAccDataSourceAzureRMKubernetesServiceVersions_
=== RUN   TestAccDataSourceAzureRMKubernetesServiceVersions_basic
--- PASS: TestAccDataSourceAzureRMKubernetesServiceVersions_basic (45.14s)
=== RUN   TestAccDataSourceAzureRMKubernetesServiceVersions_filtered
--- PASS: TestAccDataSourceAzureRMKubernetesServiceVersions_filtered (43.31s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm	90.490s

katbyte added a commit that referenced this pull request May 16, 2019
@katbyte katbyte merged commit 969fbf8 into master May 16, 2019
@katbyte katbyte deleted the orchestrator-versions-ds branch May 16, 2019 16:22
@alexsomesan
Copy link
Member Author

Thanks for pushing those changes, Tom!
I’m on PTO and respond slowly.

@ghost
Copy link

ghost commented May 17, 2019

This has been released in version 1.28.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
	version = "~> 1.28.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Jun 16, 2019

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked and limited conversation to collaborators Jun 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants