diff --git a/docs/plugin/flavor.md b/docs/plugin/flavor.md index 11e39e165..b0b9072ee 100644 --- a/docs/plugin/flavor.md +++ b/docs/plugin/flavor.md @@ -1,6 +1,6 @@ # Flavor plugin API - + ## API diff --git a/pkg/plugin/flavor/swarm/flavor.go b/pkg/plugin/flavor/swarm/flavor.go index 4d1319d18..420f77117 100644 --- a/pkg/plugin/flavor/swarm/flavor.go +++ b/pkg/plugin/flavor/swarm/flavor.go @@ -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 diff --git a/pkg/provider/terraform/instance/softlayer.go b/pkg/provider/terraform/instance/softlayer.go index 59c2b1c3b..a31c6340a 100644 --- a/pkg/provider/terraform/instance/softlayer.go +++ b/pkg/provider/terraform/instance/softlayer.go @@ -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" ) @@ -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 diff --git a/pkg/spi/flavor/spi.go b/pkg/spi/flavor/spi.go index f85926467..3994956c9 100644 --- a/pkg/spi/flavor/spi.go +++ b/pkg/spi/flavor/spi.go @@ -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",