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

resource/container_group: add registry credential #1509

Closed
wants to merge 1 commit into from
Closed

resource/container_group: add registry credential #1509

wants to merge 1 commit into from

Conversation

tharvik
Copy link

@tharvik tharvik commented Jul 6, 2018

Found a serie of commits adding the registry credentials to a container group, made by @abhijeetgaiha, adding this feature. Reverting 0dd53df and c658442 makes it work.

Maybe @abhijeetgaiha wants to comments why he removed it two days after adding it, it's not really explained in the commits messages

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.

Hi @tharvik,

Thank you for opening this PR,

In addition to the comments i have left inline could we also add this to the documentation for the resource and add a test to verify it works?

Thanks!

Required: true,
ForceNew: true,
},
"username": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we get a blank line between these properties like the rest of the resource?

"server": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we get some simple validation here (and on username/password)?

ValidateFunc: validation.NoZeroValues

Would suffice

Volumes: containerGroupVolumes,
OsType: containerinstance.OperatingSystemTypes(OSType),
Volumes: containerGroupVolumes,
ImageRegistryCredentials: credentials,
Copy link
Collaborator

Choose a reason for hiding this comment

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

very minor but we could just directly assign this here

ImageRegistryCredentials: expandContainerGroupImageRegistryCredentials(d)

@@ -286,6 +314,12 @@ func resourceArmContainerGroupRead(d *schema.ResourceData, meta interface{}) err
}
d.Set("restart_policy", string(resp.RestartPolicy))

imageRegistryCredentials := flattenContainerGroupImageRegistryCredentials(d, resp.ImageRegistryCredentials)
err = d.Set("image_registry_credential", imageRegistryCredentials)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also minor, this could be combined into one line:

	if err = d.Set("image_registry_credential", imageRegistryCredentials); err != nil {


for _, irc := range *credentials {
ircConfig := make(map[string]interface{})
ircConfig["server"] = *irc.Server
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we wrap these assignments in nil checks?

if v := ircConfig["server"] = *irc.Server; v != nil {
    ircConfig["server"] = *v
}

ircConfig["server"] = *irc.Server
ircConfig["username"] = *irc.Username
// search for password in the old configs
for _, oldIrcConfig := range ircConfigsOld {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not entirely sure, but i think the index will always be the same (otherwise each plan/apply we would attempt to update) so you might beable to simplify this to:

for i, oldIrcConfig := range ircConfigsOld {
...

    if v, ok := d.GetOk(fmt.Sprintf("image_registry_credential.%d.password", i)); ok {
        block["password"] = v.(string)
    }
}

@abhijeetgaiha
Copy link

I was unable to write a test for the feature and had to revert it. It's functionally complete but lacks the test. The test requires setting up a private docker registry which I wasn't able to figure out in time.

@abhijeetgaiha
Copy link

@tharvik I would recommend adding the test.

lawrencegripper added a commit to lawrencegripper/terraform-provider-azurerm that referenced this pull request Jul 10, 2018
lawrencegripper added a commit to lawrencegripper/terraform-provider-azurerm that referenced this pull request Jul 10, 2018
lawrencegripper added a commit to lawrencegripper/terraform-provider-azurerm that referenced this pull request Jul 10, 2018
@katbyte
Copy link
Collaborator

katbyte commented Jul 10, 2018

Hi @tharvik,

As you pulled these out of repo limbo, i hope you don't mind but i going to close this PR in favour of #1529 as it as both documentation and tests.

thanks again!

@katbyte katbyte closed this Jul 10, 2018
tombuildsstuff pushed a commit that referenced this pull request Jul 16, 2018
* Added imageRegistryCredentials to container group

* Update docs to add image_registry_credentials

* Added test and fixes from pr #1509

* Fix up review feedback

* Further tests and tweaks

* Reverting the LinuxBasic test

Tests pass:

```
$ acctests azurerm TestAccAzureRMContainerGroup_linuxBasic
=== RUN   TestAccAzureRMContainerGroup_linuxBasic
--- PASS: TestAccAzureRMContainerGroup_linuxBasic (86.67s)
=== RUN   TestAccAzureRMContainerGroup_linuxBasicUpdate
--- PASS: TestAccAzureRMContainerGroup_linuxBasicUpdate (107.92s)
PASS
ok  	github.com/terraform-providers/terraform-provider-azurerm/azurerm	194.641s
```
@tharvik tharvik deleted the readd_cg_creds branch July 17, 2018 10:05
@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.

4 participants