Skip to content

Commit

Permalink
Update swarm ID tag to const in flavor SPI (docker-archive#835)
Browse files Browse the repository at this point in the history
* Update swarm ID tag to const in flavor SPI

Similiar to docker-archive#810

Signed-off-by: Steven Kaufer <[email protected]>

* Update swarm ID tag to cluster ID

Based on review comments.

Signed-off-by: Steven Kaufer <[email protected]>
  • Loading branch information
kaufers authored Jan 18, 2018
1 parent befbf5e commit 7e467bd
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/plugin/flavor.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Flavor plugin API

<!-- SOURCE-CHECKSUM pkg/spi/flavor/* f8592646751fecf235b8fa19ef8ab5b0d958c24f -->
<!-- SOURCE-CHECKSUM pkg/spi/flavor/* 3994956c9645940bda14eff43681ce48c7f24095 -->

## API

Expand Down
2 changes: 1 addition & 1 deletion pkg/plugin/flavor/swarm/flavor.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ func (s *baseFlavor) prepare(role string, flavorProperties *types.Any, instanceS

// TODO(wfarner): Use the cluster UUID to scope instances for this swarm separately from instances in another
// swarm. This will require plumbing back to Scaled (membership tags).
instanceSpec.Tags["swarm-id"] = swarmID
instanceSpec.Tags[flavor.ClusterIDTag] = swarmID
link.WriteMap(instanceSpec.Tags)

return instanceSpec, nil
Expand Down
3 changes: 2 additions & 1 deletion pkg/provider/terraform/instance/softlayer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strings"

"github.com/docker/infrakit/pkg/provider/ibmcloud/client"
"github.com/docker/infrakit/pkg/spi/flavor"
"github.com/softlayer/softlayer-go/datatypes"
"github.com/softlayer/softlayer-go/filter"
)
Expand Down Expand Up @@ -61,7 +62,7 @@ func GetIBMCloudVMByTag(username, apiKey string, tags []string) (*int, error) {
// Use the swarm ID as the filter
var filters *string
for _, tag := range tags {
if strings.HasPrefix(tag, "swarm-id:") {
if strings.HasPrefix(tag, fmt.Sprintf("%s:", flavor.ClusterIDTag)) {
f := filter.New(filter.Path("virtualGuests.tagReferences.tag.name").Eq(tag)).Build()
logger.Info("GetIBMCloudVMByTag", "msg", fmt.Sprintf("Querying IBM Cloud for VMs with tag filter: %v", f))
filters = &f
Expand Down
5 changes: 5 additions & 0 deletions pkg/spi/flavor/spi.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ import (
"github.com/docker/infrakit/pkg/types"
)

const (
// ClusterIDTag is the name of the tag that contains unique ID for the cluster
ClusterIDTag = "infrakit.cluster.id"
)

// InterfaceSpec is the current name and version of the Flavor API.
var InterfaceSpec = spi.InterfaceSpec{
Name: "Flavor",
Expand Down

0 comments on commit 7e467bd

Please sign in to comment.