Skip to content
This repository has been archived by the owner on Aug 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #31 from ibuildthecloud/labels
Browse files Browse the repository at this point in the history
Support labels on Load Balancers
  • Loading branch information
ibuildthecloud committed Jun 25, 2015
2 parents 0b09d6d + 8914417 commit 43423a0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions librcompose/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ func Convert(src, target interface{}) error {

return yaml.Unmarshal(newBytes, target)
}

func ConvertToInterfaceMap(input map[string]string) map[string]interface{} {
result := map[string]interface{}{}
for k, v := range input {
result[k] = v
}

return result
}
4 changes: 3 additions & 1 deletion rancher/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/rancherio/go-rancher/hostaccess"
"github.com/rancherio/rancher-compose/librcompose/docker"
"github.com/rancherio/rancher-compose/librcompose/project"
"github.com/rancherio/rancher-compose/librcompose/util"
)

const (
Expand Down Expand Up @@ -227,7 +228,8 @@ func (r *RancherService) createLbService() (*rancherClient.Service, error) {
Name: r.name,
LoadBalancerConfig: lbConfig,
LaunchConfig: rancherClient.LaunchConfig{
Ports: r.serviceConfig.Ports,
Ports: r.serviceConfig.Ports,
Labels: util.ConvertToInterfaceMap(r.serviceConfig.Labels.MapParts()),
},
Scale: int64(r.getConfiguredScale()),
EnvironmentId: r.context.Environment.Id,
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/cattletest/core/test_compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ def test_up_relink(client, compose):
image: rancher/load-balancer-service
links:
- web
labels:
a: b
c: d
web:
image: nginx
'''
Expand All @@ -535,6 +538,11 @@ def test_up_relink(client, compose):
assert len(consumed) == 1
assert consumed[0].name == 'web'

assert lb.launchConfig.labels == {
'a': 'b',
'c': 'd',
}

template2 = '''
lb:
image: nginx
Expand Down

0 comments on commit 43423a0

Please sign in to comment.