-
Notifications
You must be signed in to change notification settings - Fork 85
/
datacenter.go
35 lines (28 loc) · 1.07 KB
/
datacenter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package nodepool
import (
"github.com/hashicorp/nomad-autoscaler/sdk"
"github.com/hashicorp/nomad/api"
)
type nodeDatacenterClusterPoolIdentifier struct {
id string
}
// NewNodeDatacenterPoolIdentifier returns a new
// nodeDatacenterClusterPoolIdentifier implementation of the
// ClusterNodePoolIdentifier interface.
func NewNodeDatacenterPoolIdentifier(id string) ClusterNodePoolIdentifier {
return &nodeDatacenterClusterPoolIdentifier{
id: id,
}
}
// IsPoolMember satisfies the IsPoolMember function on the
// ClusterNodePoolIdentifier interface.
func (n nodeDatacenterClusterPoolIdentifier) IsPoolMember(node *api.NodeListStub) bool {
return node.Datacenter == n.id
}
// Key satisfies the Key function on the ClusterNodePoolIdentifier interface.
func (n nodeDatacenterClusterPoolIdentifier) Key() string { return sdk.TargetConfigKeyDatacenter }
// Value satisfies the Value function on the ClusterNodePoolIdentifier
// interface.
func (n nodeDatacenterClusterPoolIdentifier) Value() string { return n.id }