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/docker: added support for linux capabilities #12045

Merged
merged 3 commits into from
Mar 7, 2017
Merged

provider/docker: added support for linux capabilities #12045

merged 3 commits into from
Mar 7, 2017

Conversation

dmportella
Copy link
Contributor

Refs #11623

Added capabilities block
Added tests for it
Added documentation for it.

My PC doesn't support memory swap so it errors there.

$ make testacc TEST=./builtin/providers/docker TESTARGS='-run=TestAccDockerContainer_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/02/17 14:57:08 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/docker -v -run=TestAccDockerContainer_ -timeout 120m
=== RUN   TestAccDockerContainer_basic
--- PASS: TestAccDockerContainer_basic (44.50s)
=== RUN   TestAccDockerContainer_volume
--- PASS: TestAccDockerContainer_volume (40.73s)
=== RUN   TestAccDockerContainer_customized
--- FAIL: TestAccDockerContainer_customized (50.27s)
	testing.go:265: Step 0 error: Check failed: Check 2/2 error: Container has wrong memory swap setting: -1
	Please check that you machine supports memory swap (you can do that by running 'docker info' command).
=== RUN   TestAccDockerContainer_upload
--- PASS: TestAccDockerContainer_upload (38.56s)
FAIL
exit status 1
FAIL	github.com/hashicorp/terraform/builtin/providers/docker	174.070s
Makefile:48: recipe for target 'testacc' failed
make: *** [testacc] Error 1

Refs #11623

Added capabilities block
Added tests for it
Added documentation for it.

My PC doesnt support memory swap so it errors there.

```
$ make testacc TEST=./builtin/providers/docker TESTARGS='-run=TestAccDockerContainer_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/02/17 14:57:08 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/docker -v -run=TestAccDockerContainer_ -timeout 120m
=== RUN   TestAccDockerContainer_basic
--- PASS: TestAccDockerContainer_basic (44.50s)
=== RUN   TestAccDockerContainer_volume
--- PASS: TestAccDockerContainer_volume (40.73s)
=== RUN   TestAccDockerContainer_customized
--- FAIL: TestAccDockerContainer_customized (50.27s)
	testing.go:265: Step 0 error: Check failed: Check 2/2 error: Container has wrong memory swap setting: -1
	Please check that you machine supports memory swap (you can do that by running 'docker info' command).
=== RUN   TestAccDockerContainer_upload
--- PASS: TestAccDockerContainer_upload (38.56s)
FAIL
exit status 1
FAIL	github.com/hashicorp/terraform/builtin/providers/docker	174.070s
Makefile:48: recipe for target 'testacc' failed
make: *** [testacc] Error 1
```
@dmportella
Copy link
Contributor Author

I am just updating some of the documentation now... Also I wanted to ask something I wasnt sure how to add a block that is not repeatable. So I added a TypeSet block for the capabilities but I only read the first one

add= ["ALL"]
drop = ["SYS_ADMIN"]
}

Copy link
Contributor Author

@dmportella dmportella Feb 17, 2017

Choose a reason for hiding this comment

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

this is what i mean - I wasnt sure how to make a block that can not be repeated. alternatively I could change the resource so it is just two set of string lists. like

Instead of the above:

add-capabilities =  ["ALL"]
drop-capabilities = ["SYS_ADMIN"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer my original entry

@dmportella
Copy link
Contributor Author

let me know if there anything else

@stack72
Copy link
Contributor

stack72 commented Feb 28, 2017

Hi @dmportella

Thanks for the work here - I am not sure I understand what you are asking about

add-capabilities = ["ALL"]

?

Paul

@stack72 stack72 self-assigned this Feb 28, 2017
@dmportella
Copy link
Contributor Author

@stack72 no worries

what i meant was. I created a section on the resource called capabilities and can be entered like this

resource "docker_container" "hello" {
	name = "tf-test"
	image = "hellow-world"
	capabilities {
		add= ["ALL"]
		drop = ["SYS_ADMIN"]
	}
}

but the way the resource section are done it allows the user to enter multiple copies of it.

resource "docker_container" "hello" {
	name = "tf-test"
	image = "hellow-world"
	capabilities {
		add= ["ALL"]
	}
	capabilities {
		add= ["ALL"]
	}
	capabilities {
		add= ["ALL"]
	}
}

In the code i just select the zero index but i wanted to know if there was a way to describe the resources so there can be only one.

@stack72
Copy link
Contributor

stack72 commented Mar 6, 2017

@dmportella

I got ya - if you make the schema look like this:

			"capabilities": &schema.Schema{
				Type:     schema.TypeSet,
				Optional: true,
				ForceNew: true,
        MaxItems: 1,
				Elem: &schema.Resource{

That will take care of it for you

@dmportella
Copy link
Contributor Author

awesome
will do

@dmportella
Copy link
Contributor Author

Added the max items now.

Test rerun so all good from my end

make testacc TEST=./builtin/providers/docker TESTARGS='-run=TestAccDockerContainer_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/07 16:38:46 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/docker -v -run=TestAccDockerContainer_ -timeout 120m
=== RUN   TestAccDockerContainer_basic
--- PASS: TestAccDockerContainer_basic (21.11s)
=== RUN   TestAccDockerContainer_volume
--- PASS: TestAccDockerContainer_volume (19.12s)
=== RUN   TestAccDockerContainer_customized
--- FAIL: TestAccDockerContainer_customized (29.76s)
	testing.go:265: Step 0 error: Check failed: Check 2/2 error: Container has wrong memory swap setting: -1
	Please check that you machine supports memory swap (you can do that by running 'docker info' command).
=== RUN   TestAccDockerContainer_upload
--- PASS: TestAccDockerContainer_upload (20.74s)
FAIL
exit status 1
FAIL	github.com/hashicorp/terraform/builtin/providers/docker	90.742s
Makefile:48: recipe for target 'testacc' failed
make: *** [testacc] Error 1

@stack72
Copy link
Contributor

stack72 commented Mar 7, 2017

LGMT! Will merge when it goes green :) Thanks for the work on this

@dmportella
Copy link
Contributor Author

no worries its cool - i keep an eye on the issues when i have some time i do some tickets ;)

@stack72 stack72 merged commit 88cdae9 into hashicorp:master Mar 7, 2017
stack72 pushed a commit that referenced this pull request Mar 7, 2017
* added support for linux capabilities

Refs #11623

Added capabilities block
Added tests for it
Added documentation for it.

My PC doesnt support memory swap so it errors there.

```
$ make testacc TEST=./builtin/providers/docker TESTARGS='-run=TestAccDockerContainer_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/02/17 14:57:08 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/docker -v -run=TestAccDockerContainer_ -timeout 120m
=== RUN   TestAccDockerContainer_basic
--- PASS: TestAccDockerContainer_basic (44.50s)
=== RUN   TestAccDockerContainer_volume
--- PASS: TestAccDockerContainer_volume (40.73s)
=== RUN   TestAccDockerContainer_customized
--- FAIL: TestAccDockerContainer_customized (50.27s)
	testing.go:265: Step 0 error: Check failed: Check 2/2 error: Container has wrong memory swap setting: -1
	Please check that you machine supports memory swap (you can do that by running 'docker info' command).
=== RUN   TestAccDockerContainer_upload
--- PASS: TestAccDockerContainer_upload (38.56s)
FAIL
exit status 1
FAIL	github.com/hashicorp/terraform/builtin/providers/docker	174.070s
Makefile:48: recipe for target 'testacc' failed
make: *** [testacc] Error 1
```

* Documentation changes.

* added maxitems and rerun tests
yanndegat pushed a commit to yanndegat/terraform that referenced this pull request Mar 13, 2017
* added support for linux capabilities

Refs hashicorp#11623

Added capabilities block
Added tests for it
Added documentation for it.

My PC doesnt support memory swap so it errors there.

```
$ make testacc TEST=./builtin/providers/docker TESTARGS='-run=TestAccDockerContainer_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/02/17 14:57:08 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/docker -v -run=TestAccDockerContainer_ -timeout 120m
=== RUN   TestAccDockerContainer_basic
--- PASS: TestAccDockerContainer_basic (44.50s)
=== RUN   TestAccDockerContainer_volume
--- PASS: TestAccDockerContainer_volume (40.73s)
=== RUN   TestAccDockerContainer_customized
--- FAIL: TestAccDockerContainer_customized (50.27s)
	testing.go:265: Step 0 error: Check failed: Check 2/2 error: Container has wrong memory swap setting: -1
	Please check that you machine supports memory swap (you can do that by running 'docker info' command).
=== RUN   TestAccDockerContainer_upload
--- PASS: TestAccDockerContainer_upload (38.56s)
FAIL
exit status 1
FAIL	github.com/hashicorp/terraform/builtin/providers/docker	174.070s
Makefile:48: recipe for target 'testacc' failed
make: *** [testacc] Error 1
```

* Documentation changes.

* added maxitems and rerun tests
@ghost
Copy link

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

2 participants