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

Add argument to delete volumes on container remove #336

Merged
merged 2 commits into from
Jul 21, 2019
Merged

Add argument to delete volumes on container remove #336

merged 2 commits into from
Jul 21, 2019

Conversation

zoispag
Copy link
Member

@zoispag zoispag commented Jun 13, 2019

Adds a boolean --remove-volumes argument to delete volumes on container remove.

Closes #190

Bear with me! This is my first attempt on Go code.
If you find issues, please point me to the correct direction on how to improve this PR.

Thanks

@welcome
Copy link

welcome bot commented Jun 13, 2019

Thanks for opening this pull request! Please check out our contributing guidelines as well as our code of conduct.

@zoispag
Copy link
Member Author

zoispag commented Jun 13, 2019

If this is the correct output of the tests, 0 have failed:

go test ./... -v
?   	github.com/containrrr/watchtower	[no test files]
=== RUN   TestActions
Running Suite: Actions Suite
============================
Random Seed: 1560452316
Will run 5 of 5 specs

••time="2019-06-13T20:58:39+02:00" level=info msg="Found multiple running watchtower instances. Cleaning up."
•time="2019-06-13T20:58:40+02:00" level=info msg="Found multiple running watchtower instances. Cleaning up."
•time="2019-06-13T20:58:41+02:00" level=info msg="Found multiple running watchtower instances. Cleaning up."
•
Ran 5 of 5 Specs in 5.018 seconds
SUCCESS! -- 5 Passed | 0 Failed | 0 Pending | 0 Skipped
--- PASS: TestActions (5.02s)
PASS
ok  	github.com/containrrr/watchtower/actions	(cached)
?   	github.com/containrrr/watchtower/app	[no test files]
=== RUN   TestContainer
Running Suite: Container Suite
==============================
Random Seed: 1560452316
Will run 20 of 20 specs

•time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/containers.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/container_stopped.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/image02.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/container_running.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/image01.json
•time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/containers.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/container_stopped.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/image02.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/container_running.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/image01.json
•time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/containers.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/container_stopped.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/image02.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/container_running.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/image01.json
•time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/containers.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/container_stopped.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/image02.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/container_running.json
time="2019-06-13T20:58:36+02:00" level=error msg=~/Projects/watchtower_fork/container/mocks/data/image01.json
••••••••••••••••
Ran 20 of 20 Specs in 0.014 seconds
SUCCESS! -- 20 Passed | 0 Failed | 0 Pending | 0 Skipped
--- PASS: TestContainer (0.01s)
=== RUN   TestWatchtowerContainersFilter
--- PASS: TestWatchtowerContainersFilter (0.00s)
    filters_test.go:17: PASS:	IsWatchtower()
=== RUN   TestNoFilter
--- PASS: TestNoFilter (0.00s)
=== RUN   TestFilterByNames
--- PASS: TestFilterByNames (0.00s)
    filters_test.go:42: PASS:	Name()
    filters_test.go:47: PASS:	Name()
=== RUN   TestFilterByEnableLabel
--- PASS: TestFilterByEnableLabel (0.00s)
    filters_test.go:57: PASS:	Enabled()
    filters_test.go:62: PASS:	Enabled()
    filters_test.go:67: PASS:	Enabled()
=== RUN   TestFilterByDisabledLabel
--- PASS: TestFilterByDisabledLabel (0.00s)
    filters_test.go:77: PASS:	Enabled()
    filters_test.go:82: PASS:	Enabled()
    filters_test.go:87: PASS:	Enabled()
=== RUN   TestBuildFilter
--- PASS: TestBuildFilter (0.00s)
    filters_test.go:100: PASS:	Name()
    filters_test.go:100: PASS:	Enabled()
    filters_test.go:106: PASS:	Name()
    filters_test.go:106: PASS:	Enabled()
    filters_test.go:112: PASS:	Name()
    filters_test.go:112: PASS:	Enabled()
    filters_test.go:118: PASS:	Name()
    filters_test.go:118: PASS:	Enabled()
    filters_test.go:123: PASS:	Enabled()
=== RUN   TestBuildFilterEnableLabel
--- PASS: TestBuildFilterEnableLabel (0.00s)
    filters_test.go:135: PASS:	Enabled()
    filters_test.go:141: PASS:	Name()
    filters_test.go:141: PASS:	Enabled()
    filters_test.go:147: PASS:	Name()
    filters_test.go:147: PASS:	Enabled()
    filters_test.go:152: PASS:	Enabled()
=== RUN   TestEncodedEnvAuth_ShouldReturnAnErrorIfRepoEnvsAreUnset
--- PASS: TestEncodedEnvAuth_ShouldReturnAnErrorIfRepoEnvsAreUnset (0.00s)
=== RUN   TestEncodedEnvAuth_ShouldReturnAuthHashIfRepoEnvsAreSet
--- PASS: TestEncodedEnvAuth_ShouldReturnAuthHashIfRepoEnvsAreSet (0.00s)
=== RUN   TestEncodedConfigAuth_ShouldReturnAnErrorIfFileIsNotPresent
time="2019-06-13T20:58:36+02:00" level=error msg="Unable to find default config file /dev/null/should-fail/config.json: stat /dev/null/should-fail/config.json: not a directory"
--- PASS: TestEncodedConfigAuth_ShouldReturnAnErrorIfFileIsNotPresent (0.00s)
=== RUN   TestParseServerAddress_ShouldReturnErrorIfPassedEmptyString
--- PASS: TestParseServerAddress_ShouldReturnErrorIfPassedEmptyString (0.00s)
=== RUN   TestParseServerAddress_ShouldReturnTheRepoNameIfPassedAFullyQualifiedImageName
--- PASS: TestParseServerAddress_ShouldReturnTheRepoNameIfPassedAFullyQualifiedImageName (0.00s)
=== RUN   TestParseServerAddress_ShouldReturnTheOrganizationPartIfPassedAnImageNameMissingServerName
--- PASS: TestParseServerAddress_ShouldReturnTheOrganizationPartIfPassedAnImageNameMissingServerName (0.00s)
=== RUN   TestParseServerAddress_ShouldReturnTheServerNameIfPassedAFullyQualifiedImageName
--- PASS: TestParseServerAddress_ShouldReturnTheServerNameIfPassedAFullyQualifiedImageName (0.00s)
=== RUN   TestSliceEqual_True
--- PASS: TestSliceEqual_True (0.00s)
=== RUN   TestSliceEqual_DifferentLengths
--- PASS: TestSliceEqual_DifferentLengths (0.00s)
=== RUN   TestSliceEqual_DifferentContents
--- PASS: TestSliceEqual_DifferentContents (0.00s)
=== RUN   TestSliceSubtract
--- PASS: TestSliceSubtract (0.00s)
=== RUN   TestStringMapSubtract
--- PASS: TestStringMapSubtract (0.00s)
=== RUN   TestStructMapSubtract
--- PASS: TestStructMapSubtract (0.00s)
PASS
ok  	github.com/containrrr/watchtower/container	(cached)
?   	github.com/containrrr/watchtower/container/mocks	[no test files]
?   	github.com/containrrr/watchtower/notifications	[no test files]

Copy link
Member

@simskij simskij left a comment

Choose a reason for hiding this comment

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

Thanks a bunch for contributing! Really appreciate it.
Looks really good. If you dont mind, I'd appreciate if you'd add a test case for the new option as well.

Thanks again 🙏

@simskij
Copy link
Member

simskij commented Jun 13, 2019

@all-contributors add @zoispag for code

@allcontributors
Copy link
Contributor

@simskij

I've put up a pull request to add @zoispag! 🎉

@zoispag
Copy link
Member Author

zoispag commented Jun 13, 2019

@simskij I certainly don't mind! I will take a look to figure out exactly how. If I encounter any issue I will let you know! 🙏

Cheers!

@simskij
Copy link
Member

simskij commented Jul 20, 2019

Hi again @zoispag,

Can I assist You in any way to get this out the door?

Thanks again,
Simon

@zoispag
Copy link
Member Author

zoispag commented Jul 21, 2019

Hi @simskij,

i tried to add a new test case, but i stumbled upon some issues with the mockClient and how to mount volume in a mock container :(

This was some time ago and since then I didn't have too much spare time to work on this.
So helping with the test would be highly appreciated.

Thanks,
Zois

@zoispag
Copy link
Member Author

zoispag commented Jul 21, 2019

@simskij I updated the branch and resolved the conflicts.
Still no progress with the tests though!

@simskij simskij merged commit baf5e50 into containrrr:master Jul 21, 2019
@welcome
Copy link

welcome bot commented Jul 21, 2019

Congrats on merging your first pull request! We are all very proud of you! ✨

@zoispag zoispag deleted the feat/190_remove_volumes_on_container_stop branch July 21, 2019 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update volumes
2 participants