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

docker provider additions #3761

Merged
merged 8 commits into from
Dec 2, 2015
Merged

docker provider additions #3761

merged 8 commits into from
Dec 2, 2015

Conversation

ryane
Copy link
Contributor

@ryane ryane commented Nov 4, 2015

Adds the following functionality to the docker_container resource:

  • support for setting the entrypoint
  • support for setting the restart policy (off|on-failure|always)
  • support for setting memory, memory-swap, and cpu-shares runtime constraints
  • support for docker labels
  • support for log-driver and log-options
  • includes HostConfig when creating container

@@ -112,6 +117,46 @@ func resourceDockerContainerCreate(d *schema.ResourceData, meta interface{}) err
hostConfig.Links = stringSetToStringSlice(v.(*schema.Set))
}

if v, ok := d.GetOk("memory"); ok {
memory := int64(v.(int))
if memory > 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of this check, we should be able to trust that d.GetOk("memory") will return a non-zero value, and instead put in a check for negative values into the ValidateFunc for this schema such that obviously bad values are raised to the user.

@jen20
Copy link
Contributor

jen20 commented Nov 9, 2015

This looks good. I added a few notes about moving some validation to ValidateFunc on various schema instead of performing it in the create - let me know what you think on those?

@ryane
Copy link
Contributor Author

ryane commented Nov 9, 2015

thanks for the feedback @jen20. It all makes sense to me. Working on an update...


if v, ok := d.GetOk("memory_swap"); ok {
swap := int64(v.(int))
if swap > 0 {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

-1 is actually a valid value for memory_swap so I still need to check it here before converting to MBs

Copy link
Contributor

Choose a reason for hiding this comment

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

👍

@jen20
Copy link
Contributor

jen20 commented Dec 2, 2015

LGTM now - thanks @ryane! We can merge this once the release window for 0.6.8 is finished.

@ryane
Copy link
Contributor Author

ryane commented Dec 2, 2015

great, thanks for the update!

@jen20
Copy link
Contributor

jen20 commented Dec 2, 2015

Hi @ryane, I'm about to merge this, but I'm going to take the support for restart policies from #3509 as it covers more cases.

jen20 added a commit that referenced this pull request Dec 2, 2015
provider/docker: support additional arguments for `docker_container` resource
@jen20 jen20 merged commit 50d7abc into hashicorp:master Dec 2, 2015
@ryane
Copy link
Contributor Author

ryane commented Dec 2, 2015

what are the additional use cases? it looks like it just uses a different syntax to specify the number of times to attempt a restart. I don't have a strong opinion on either implementation so whatever you prefer works for me!

@jen20
Copy link
Contributor

jen20 commented Dec 2, 2015

Actually just looking through it I agree - I hadn't spotted the max_retry_count until I was looking to merge #3509. We'll stick with the syntax in this pull request. Many thanks for your contribution!

@ghost
Copy link

ghost commented Apr 27, 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 27, 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.

3 participants