Skip to content

Commit

Permalink
renamed DISCOVERY_TYPE envvar to HARDWARE_DATA_MODEL
Browse files Browse the repository at this point in the history
  • Loading branch information
kqdeng committed Jun 2, 2020
1 parent c46a9c4 commit a085553
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
6 changes: 3 additions & 3 deletions packet/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func NewClient(consumerToken, authToken string, baseURL *url.URL) (*Client, erro

var hg hardwareGetter
var err error
discoveryType := os.Getenv("DISCOVERY_TYPE")
switch discoveryType {
case discoveryTypeTinkerbell:
hardwareDataModel := os.Getenv("HARDWARE_DATA_MODEL")
switch hardwareDataModel {
case hardwareDataModelTinkerbell:
hg, err = tinkClient.NewTinkerbellClient()
if err != nil {
return nil, errors.Wrap(err, "connect to tink")
Expand Down
12 changes: 6 additions & 6 deletions packet/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ func (c *Client) DiscoverHardwareFromDHCP(mac net.HardwareAddr, giaddr net.IP, c
metrics.CacherRequestsInProgress.With(labels).Inc()
metrics.CacherTotal.With(labels).Inc()

discoveryType := os.Getenv("DISCOVERY_TYPE")
switch discoveryType {
case discoveryTypeTinkerbell:
hardwareDataModel := os.Getenv("HARDWARE_DATA_MODEL")
switch hardwareDataModel {
case hardwareDataModelTinkerbell:
tc := c.hardwareClient.(tink.HardwareServiceClient)
msg := &tink.GetRequest{
Mac: mac.String(),
Expand Down Expand Up @@ -134,9 +134,9 @@ func (c *Client) DiscoverHardwareFromIP(ip net.IP) (*Discovery, error) {
defer metrics.CacherRequestsInProgress.With(labels).Dec()

var b []byte
discoveryType := os.Getenv("DISCOVERY_TYPE")
switch discoveryType {
case discoveryTypeTinkerbell:
hardwareDataModel := os.Getenv("HARDWARE_DATA_MODEL")
switch hardwareDataModel {
case hardwareDataModelTinkerbell:
tc := c.hardwareClient.(tink.HardwareServiceClient)
msg := &tink.GetRequest{
Ip: ip.String(),
Expand Down
8 changes: 4 additions & 4 deletions packet/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"github.com/tinkerbell/boots/files/ignition"
)

const discoveryTypeTinkerbell = "tinkerbell"
const hardwareDataModelTinkerbell = "tinkerbell"

// BondingMode is the hardware bonding mode
type BondingMode int
Expand Down Expand Up @@ -112,9 +112,9 @@ func NewDiscovery(b []byte) (*Discovery, error) {
return nil, errors.New("empty response from db")
}

discoveryType := os.Getenv("DISCOVERY_TYPE")
switch discoveryType {
case discoveryTypeTinkerbell:
hardwareDataModel := os.Getenv("HARDWARE_DATA_MODEL")
switch hardwareDataModel {
case hardwareDataModelTinkerbell:
res = &DiscoveryTinkerbell{}
default:
res = &DiscoveryCacher{}
Expand Down
10 changes: 5 additions & 5 deletions packet/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestInterfaces(t *testing.T) {
}

func TestNewDiscoveryCacher(t *testing.T) {
t.Log("DISCOVERY_TYPE (should be empty to use cacher):", os.Getenv("DISCOVERY_TYPE"))
t.Log("HARDWARE_DATA_MODEL (should be empty to use cacher):", os.Getenv("HARDWARE_DATA_MODEL"))

for name, test := range tests {
t.Log(name)
Expand All @@ -31,8 +31,8 @@ func TestNewDiscoveryCacher(t *testing.T) {
}

func TestNewDiscoveryTinkerbell(t *testing.T) {
os.Setenv("DISCOVERY_TYPE", "tinkerbell")
t.Log("DISCOVERY_TYPE:", os.Getenv("DISCOVERY_TYPE"))
os.Setenv("HARDWARE_DATA_MODEL", "tinkerbell")
t.Log("HARDWARE_DATA_MODEL:", os.Getenv("HARDWARE_DATA_MODEL"))

for name, test := range tinkerbellTests {
t.Log(name)
Expand Down Expand Up @@ -61,8 +61,8 @@ func TestNewDiscoveryMismatch(t *testing.T) {
}
}()

os.Setenv("DISCOVERY_TYPE", "tinkerbell")
t.Log("DISCOVERY_TYPE:", os.Getenv("DISCOVERY_TYPE"))
os.Setenv("HARDWARE_DATA_MODEL", "tinkerbell")
t.Log("HARDWARE_DATA_MODEL:", os.Getenv("HARDWARE_DATA_MODEL"))

for name, test := range tinkerbellTests {
t.Log(name)
Expand Down

0 comments on commit a085553

Please sign in to comment.