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.network resource #477

Merged
merged 14 commits into from
Nov 9, 2016
Merged

docker.network resource #477

merged 14 commits into from
Nov 9, 2016

Conversation

ryane
Copy link
Contributor

@ryane ryane commented Nov 4, 2016

fixes #298

@ryane ryane added this to the 0.4.0 milestone Nov 4, 2016
Copy link
Contributor

@arichardet arichardet left a comment

Choose a reason for hiding this comment

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

Mostly nitpicks on adjusting comments and could change "present"/"absent" to the StatePresent/StateAbsent

@@ -66,6 +66,12 @@ type Preparer struct {
// list of DNS servers for the container to use
DNS []string `hcl:"dns"`

// the mode of the container network
Copy link
Contributor

Choose a reason for hiding this comment

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

should you indicate the default if not specified?


// Prepare a docker network
func (p *Preparer) Prepare(ctx context.Context, render resource.Renderer) (resource.Task, error) {
if p.Name == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is handled for you by the preparer with required

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 think this is needed to prevent someone from manually specifying name = "" in the hcl

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, that is correct

// driver specific options
Options map[string]interface{} `hcl:"options"`

// ip address management driver
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe want to indicate the default in comments

// enable ipv6 networking
IPv6 bool `hcl:"ipv6"`

// indicates whether the volume should exist.
Copy link
Contributor

Choose a reason for hiding this comment

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

add that "present" is default

// ip address management driver
IPAMDriver string `hcl:"ipam_driver"`

// custom IPAM configuration. multiple IPAM configurations are permitted. Each
Copy link
Contributor

Choose a reason for hiding this comment

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

What if no configurations are specified? Probably good to add something to the comments.

DefaultIPAMDriver = "default"
)

// Network is responsible for managing docker volumes
Copy link
Contributor

Choose a reason for hiding this comment

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

managing docker networks

type IPAMConfigs []dc.IPAMConfig

// Len implements the sort interface for IPAMConfigs
func (ic IPAMConfigs) Len() int { return len(ic) }
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like Len, Swap, Less, and String (and ipamConfigString) are not used

Copy link
Contributor Author

Choose a reason for hiding this comment

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

these are used to implement the sort interface: https://golang.org/pkg/sort/

Copy link
Contributor

Choose a reason for hiding this comment

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

I see


// TestPreparerPrepare tests the Prepare function
func TestPreparerPrepare(t *testing.T) {
t.Run("name is required", func(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can remove this test with change in network/preparer.go (handled in resource/preparer.go)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, this is ok

}

if p.State == "" {
p.State = "present"
Copy link
Contributor

Choose a reason for hiding this comment

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

could use StatePresent instead of "present"

require.NoError(t, err)
assert.True(t, status.HasChanges())
assert.Equal(t, 1, len(status.Diffs()))
comparison.AssertDiff(t, status.Diffs(), nwName, "present", "absent")
Copy link
Contributor

Choose a reason for hiding this comment

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

could use StatePresent and StateAbsent throughout

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true but it requires a cast (otherwise, I get cannot use network.StatePresent (type network.State) as type string in argument to comparison.AssertDiff). makes the lines really long and harder to read (imo). worth it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually wasn't so bad - went ahead and fixed these

@arichardet
Copy link
Contributor

LGTM!

@arichardet arichardet merged commit b904201 into master Nov 9, 2016
@arichardet arichardet deleted the feature/docker.network branch November 9, 2016 16:40
BrianHicks pushed a commit that referenced this pull request Dec 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker.network resource
2 participants