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

provider/azurerm: Container Registry #10973

Merged
merged 12 commits into from
Jan 2, 2017

Conversation

tombuildsstuff
Copy link
Contributor

Fixes #10819

  • CRUD
  • Import
  • Documentation
  • Tests
    • Acceptance Tests
    • Import Tests
    • Run output in a Comment

The access_key for the Storage Account isn't returned from the server once the Container Registry has been created (for obvious reasons) - so I've ignored that object in the import tests for now.

@tombuildsstuff
Copy link
Contributor Author

Tests pass

$ TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMContainerRegistry -timeout 120m
=== RUN   TestAccAzureRMContainerRegistry_importBasic
--- PASS: TestAccAzureRMContainerRegistry_importBasic (123.07s)
=== RUN   TestAccAzureRMContainerRegistry_importComplete
--- PASS: TestAccAzureRMContainerRegistry_importComplete (124.61s)
=== RUN   TestAccAzureRMContainerRegistryName_validation
--- PASS: TestAccAzureRMContainerRegistryName_validation (0.00s)
=== RUN   TestAccAzureRMContainerRegistry_basic
--- PASS: TestAccAzureRMContainerRegistry_basic (123.95s)
=== RUN   TestAccAzureRMContainerRegistry_complete
--- PASS: TestAccAzureRMContainerRegistry_complete (121.54s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	493.199s

Copy link
Contributor

@stack72 stack72 left a comment

Choose a reason for hiding this comment

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

Hey @tombuildsstuff

This is looking good - few questions left inline

Thanks

Paul

ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"storage_account"},
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we ignore the storage_account?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is because the inner access_key field isn't returned through the API after the initial CreateOrUpdate. Potentially we could retrieve it via the Storage Account - but it felt like the wrong thing to do (given it's a completely unrelated object)?

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, that makes sense

Tags: expandTags(tags),
}

if v, ok := d.GetOk("storage_account"); ok {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is a required field, we don't need the if v, ok part - we can assume it's always there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

storageAccountName := account["name"].(string)
storageAccountAccessKey := account["access_key"].(string)
parameters.RegistryProperties.StorageAccount = &containerregistry.StorageAccountProperties{
Name: &storageAccountName,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be wrapped in azure.String()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

}
}

_, err := client.CreateOrUpdate(resourceGroup, name, parameters)
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this handle the polling or do we need to do that in our code using a staterefreshfunc?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, the SDK says that it's only possible to get a 200 OK back (i.e. that it's not a long running operation) - which I've confirmed in all of the testing I've done with this, where the Registry's created so quickly I've not seen it block.

The Documentation on the other hand specifies that it's possible to get a 202 Accepted back - however I've noticed a couple of issues in the Documentation anyway so this may well be a bug in the docs.

Given they're both generated from the same place I'll file an issue - but as yet I've not seen a 202 in real world usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tombuildsstuff
Copy link
Contributor Author

Updated and re-ran the tests:

$ TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMContainerRegi -timeout 120m
=== RUN   TestAccAzureRMContainerRegistry_importBasic
--- PASS: TestAccAzureRMContainerRegistry_importBasic (131.18s)
=== RUN   TestAccAzureRMContainerRegistry_importComplete
--- PASS: TestAccAzureRMContainerRegistry_importComplete (127.82s)
=== RUN   TestAccAzureRMContainerRegistryName_validation
--- PASS: TestAccAzureRMContainerRegistryName_validation (0.00s)
=== RUN   TestAccAzureRMContainerRegistry_basic
--- PASS: TestAccAzureRMContainerRegistry_basic (119.65s)
=== RUN   TestAccAzureRMContainerRegistry_complete
--- PASS: TestAccAzureRMContainerRegistry_complete (125.95s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	504.617s

@stack72
Copy link
Contributor

stack72 commented Jan 2, 2017

This LGTM! thanks for the changes :)

% make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMContainerRegi'                                                                                                           2 ↵
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/01/02 14:28:13 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMContainerRegi -timeout 120m
=== RUN   TestAccAzureRMContainerRegistry_importBasic
--- PASS: TestAccAzureRMContainerRegistry_importBasic (131.46s)
=== RUN   TestAccAzureRMContainerRegistry_importComplete
--- PASS: TestAccAzureRMContainerRegistry_importComplete (131.55s)
=== RUN   TestAccAzureRMContainerRegistryName_validation
--- PASS: TestAccAzureRMContainerRegistryName_validation (0.00s)
=== RUN   TestAccAzureRMContainerRegistry_basic
--- PASS: TestAccAzureRMContainerRegistry_basic (125.96s)
=== RUN   TestAccAzureRMContainerRegistry_complete
--- PASS: TestAccAzureRMContainerRegistry_complete (128.36s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	517.339s

@stack72 stack72 merged commit 874ec8b into hashicorp:master Jan 2, 2017
@ghost
Copy link

ghost commented Apr 18, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 18, 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.

provider/azurerm: Support Container Registry
2 participants