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_container_registry #1642

Merged
merged 7 commits into from
Jul 25, 2018

Conversation

schoren
Copy link
Contributor

@schoren schoren commented Jul 25, 2018

This PR fixes #1634

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 @schoren

Thanks for this PR :)

I've taken a look through and left some (mostly minor) comments in-line but this is looking good; the failing tests you're referring to in #1634 are because the fields are missing from the schema - if we add them to the schema (I've added an example in the review) then these should pass and we should be able to run the tests / get this merged 👍

Thanks!

State: schema.ImportStatePassthrough,
},
MigrateState: resourceAzureRMContainerRegistryMigrateState,
SchemaVersion: 2,
Copy link
Contributor

Choose a reason for hiding this comment

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

we should be able to remove the Importer -> Schema version lines here, since they're not needed for data sources

page_title: "Azure Resource Manager: azurerm_container_registry"
sidebar_current: "docs-azurerm-datasource-image"
description: |-
Get information about an Image
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make this Use this data source to access information about a Container Registry. to match the comment below?

---
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_container_registry"
sidebar_current: "docs-azurerm-datasource-image"
Copy link
Contributor

Choose a reason for hiding this comment

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

can we make this "docs-azurerm-datasource-container-registry"?


output "image_id" {
value = "${data.azurerm_container_registry.test.id}"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

minor could we make this login_server which would be a more likely output here? e.g.

output "login_server" {
  value = "${data.azurerm_container_registry.test.login_server}"
}


* `admin_username` - The Username associated with the Container Registry Admin account - if the admin account is enabled.

* `admin_password` - The Password associated with the Container Registry Admin account - if the admin account is enabled.

This comment was marked as outdated.

ValidateFunc: validateAzureRMContainerRegistryName,
},

"resource_group_name": resourceGroupNameSchema(),
Copy link
Contributor

Choose a reason for hiding this comment

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

can we swap resourceGroupNameSchema for resourceGroupNameForDataSourceSchema here?

},

"resource_group_name": resourceGroupNameSchema(),
},
Copy link
Contributor

Choose a reason for hiding this comment

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

there's other fields being set below which don't exist in the Schema - can we add them? They'll be computed only fields since this is a Data Source, so this'll be:

"location": locationForDataSourceSchema(),

"admin_enabled": {
  Type: schema.TypeBool,
  Computed: true,
},

"admin_password": {
  Type: schema.TypeString,
  Computed: true,
},

"admin_username": {
  Type: schema.TypeString,
  Computed: true,
},

"login_server": {
  Type: schema.TypeString,
  Computed: true,
},

"sku": {
  Type: schema.TypeString,
  Computed: true,
},

"storage_account_id": {
  Type: schema.TypeString,
  Computed: true,
},

@@ -0,0 +1,42 @@
---

This comment was marked as outdated.

@tombuildsstuff tombuildsstuff changed the title Add new datasource for container_registry New Data Source: azurerm_container_registry Jul 25, 2018
@schoren
Copy link
Contributor Author

schoren commented Jul 25, 2018

@tombuildsstuff Thanks for your comments and help. I've made the changes as suggested, and now the tests are passing. Let me know if I missed something and I'll fix it.

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 @schoren

Thanks for pushing those changes - taking one last look through I've noticed a couple of minor things which need to be resolved prior to merging; but this now otherwise LGTM 👍

Thanks!

return &schema.Resource{
Read: dataSourceArmContainerRegistryRead,
MigrateState: resourceAzureRMContainerRegistryMigrateState,
SchemaVersion: 2,
Copy link
Contributor

Choose a reason for hiding this comment

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

can we remove these two lines MigrateState / SchemaVersion - since they're not needed?

if utils.ResponseWasNotFound(resp.Response) {
log.Printf("[DEBUG] Container Registry %q was not found in Resource Group %q", name, resourceGroup)
d.SetId("")
return nil
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is a Data Source, if this isn't found we should return an error; thus can we make this:

return fmt.Errorf("Container Registry %q was not found in Resource Group %q", name, resourceGroup)

schoren and others added 2 commits July 25, 2018 11:39
* Remove unused Schema fields
* Return error if resource is not found
ri := acctest.RandInt()
config := testAccDataSourceAzureRMContainerRegistry_basic(ri)

dataSourceName := "data.azurerm_container_registry.test"
Copy link
Contributor

Choose a reason for hiding this comment

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

re-reviewing this I noticed this was checking the resource (azurerm_container_registry.test) rather than the data source (which has the data. prefix) - I've pushed a commit to fix this (I hope you don't mind!)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Of course not! Thanks for taking the time to review this and making this fix. Sorry for all this little erros

Copy link
Contributor

Choose a reason for hiding this comment

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

not at all - apologies I missed it the first time around; thanks for this contribution, this'll go out in v1.12 :)

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 @schoren

Thanks for pushing those changes - this now LGTM; I'll kick off the tests now 👍

Thanks!

@tombuildsstuff
Copy link
Contributor

Test passes:

screenshot 2018-07-25 at 16 57 56

@tombuildsstuff tombuildsstuff added this to the 1.12.0 milestone Jul 25, 2018
@tombuildsstuff tombuildsstuff merged commit 2098ef3 into hashicorp:master Jul 25, 2018
tombuildsstuff added a commit that referenced this pull request Jul 25, 2018
@ghost
Copy link

ghost commented Mar 30, 2020

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 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 30, 2020
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.

Data Source for Azure Container Registry
2 participants