mirror of https://github.com/docker/compose.git
Merge pull request #969 from gtardif/compose-network_labels
Add compose labels for network
This commit is contained in:
commit
775c46084c
|
@ -55,6 +55,9 @@ func (s *local) Up(ctx context.Context, project *types.Project, detach bool) err
|
|||
network.Name = fmt.Sprintf("%s_%s", project.Name, k)
|
||||
project.Networks[k] = network
|
||||
}
|
||||
network.Labels = network.Labels.Add(networkLabel, k)
|
||||
network.Labels = network.Labels.Add(projectLabel, project.Name)
|
||||
network.Labels = network.Labels.Add(versionLabel, ComposeVersion)
|
||||
err := s.ensureNetwork(ctx, network)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -37,9 +37,12 @@ func TestLocalBackendComposeUp(t *testing.T) {
|
|||
|
||||
t.Run("up", func(t *testing.T) {
|
||||
c.RunDockerCmd("compose", "up", "-f", "../../tests/composefiles/demo_multi_port.yaml", "--project-name", projectName)
|
||||
t.Cleanup(func() {
|
||||
_ = c.RunDockerCmd("compose", "down", "--project-name", projectName)
|
||||
})
|
||||
})
|
||||
t.Cleanup(func() {
|
||||
_ = c.RunDockerCmd("compose", "down", "--project-name", projectName)
|
||||
})
|
||||
|
||||
t.Run("check running project", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("compose", "ps", "-p", projectName)
|
||||
res.Assert(t, icmd.Expected{Out: `web`})
|
||||
|
||||
|
@ -47,4 +50,21 @@ func TestLocalBackendComposeUp(t *testing.T) {
|
|||
output := HTTPGetWithRetry(t, endpoint+"/words/noun", http.StatusOK, 2*time.Second, 20*time.Second)
|
||||
assert.Assert(t, strings.Contains(output, `"word":`))
|
||||
})
|
||||
|
||||
t.Run("check compose labels", func(t *testing.T) {
|
||||
res := c.RunDockerCmd("--context", "default", "inspect", projectName+"_web_1")
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.container-number": "1"`})
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.project": "compose-e2e-demo"`})
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.oneoff": "False",`})
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.config-hash":`})
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.project.config_files":`})
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.project.working_dir":`})
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.service": "web"`})
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.version":`})
|
||||
|
||||
res = c.RunDockerCmd("--context", "default", "network", "inspect", projectName+"_default")
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.network": "default"`})
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.project": `})
|
||||
res.Assert(t, icmd.Expected{Out: `"com.docker.compose.version": `})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ const (
|
|||
serviceLabel = "com.docker.compose.service"
|
||||
versionLabel = "com.docker.compose.version"
|
||||
configHashLabel = "com.docker.compose.config-hash"
|
||||
networkLabel = "com.docker.compose.network"
|
||||
|
||||
//ComposeVersion Compose version
|
||||
ComposeVersion = "1.0-alpha"
|
||||
|
|
Loading…
Reference in New Issue