cli/compose/convert: split exported AddStackLabel from implementation
This function is currently only used within the package; create a non-exported version of it, to make it clear it's not used elsewhere. This patch keeps the exported function for now, but we can decide if we need to keep it in future. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@ -42,6 +42,11 @@ func NewNamespace(name string) Namespace {
|
||||
|
||||
// AddStackLabel returns labels with the namespace label added
|
||||
func AddStackLabel(namespace Namespace, labels map[string]string) map[string]string {
|
||||
return addStackLabel(namespace, labels)
|
||||
}
|
||||
|
||||
// addStackLabel returns labels with the namespace label added
|
||||
func addStackLabel(namespace Namespace, labels map[string]string) map[string]string {
|
||||
if labels == nil {
|
||||
labels = make(map[string]string)
|
||||
}
|
||||
@ -67,7 +72,7 @@ func Networks(namespace Namespace, networks networkMap, servicesNetworks map[str
|
||||
}
|
||||
|
||||
createOpts := client.NetworkCreateOptions{
|
||||
Labels: AddStackLabel(namespace, nw.Labels),
|
||||
Labels: addStackLabel(namespace, nw.Labels),
|
||||
Driver: nw.Driver,
|
||||
Options: nw.DriverOpts,
|
||||
Internal: nw.Internal,
|
||||
@ -171,7 +176,7 @@ func driverObjectConfig(namespace Namespace, name string, obj composetypes.FileO
|
||||
return swarmFileObject{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: name,
|
||||
Labels: AddStackLabel(namespace, obj.Labels),
|
||||
Labels: addStackLabel(namespace, obj.Labels),
|
||||
},
|
||||
Data: []byte{},
|
||||
}
|
||||
@ -192,7 +197,7 @@ func fileObjectConfig(namespace Namespace, name string, obj composetypes.FileObj
|
||||
return swarmFileObject{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: name,
|
||||
Labels: AddStackLabel(namespace, obj.Labels),
|
||||
Labels: addStackLabel(namespace, obj.Labels),
|
||||
},
|
||||
Data: data,
|
||||
}, nil
|
||||
|
||||
@ -30,7 +30,7 @@ func TestAddStackLabel(t *testing.T) {
|
||||
labels := map[string]string{
|
||||
"something": "labeled",
|
||||
}
|
||||
actual := AddStackLabel(Namespace{name: "foo"}, labels)
|
||||
actual := addStackLabel(Namespace{name: "foo"}, labels)
|
||||
expected := map[string]string{
|
||||
"something": "labeled",
|
||||
LabelNamespace: "foo",
|
||||
|
||||
@ -119,7 +119,7 @@ func Service(
|
||||
serviceSpec := swarm.ServiceSpec{
|
||||
Annotations: swarm.Annotations{
|
||||
Name: name,
|
||||
Labels: AddStackLabel(namespace, service.Deploy.Labels),
|
||||
Labels: addStackLabel(namespace, service.Deploy.Labels),
|
||||
},
|
||||
TaskTemplate: swarm.TaskSpec{
|
||||
ContainerSpec: &swarm.ContainerSpec{
|
||||
@ -131,7 +131,7 @@ func Service(
|
||||
DNSConfig: dnsConfig,
|
||||
Healthcheck: healthcheck,
|
||||
Env: convertEnvironment(service.Environment),
|
||||
Labels: AddStackLabel(namespace, service.Labels),
|
||||
Labels: addStackLabel(namespace, service.Labels),
|
||||
Dir: service.WorkingDir,
|
||||
User: service.User,
|
||||
Mounts: mounts,
|
||||
|
||||
@ -80,7 +80,7 @@ func handleVolumeToMount(
|
||||
return result, nil
|
||||
}
|
||||
|
||||
result.VolumeOptions.Labels = AddStackLabel(namespace, stackVolume.Labels)
|
||||
result.VolumeOptions.Labels = addStackLabel(namespace, stackVolume.Labels)
|
||||
if stackVolume.Driver != "" || stackVolume.DriverOpts != nil {
|
||||
result.VolumeOptions.DriverConfig = &mount.Driver{
|
||||
Name: stackVolume.Driver,
|
||||
|
||||
Reference in New Issue
Block a user