From a085553b932a5200fa78c5c9757e6cd6f5ca081e Mon Sep 17 00:00:00 2001 From: Kelly Deng Date: Tue, 2 Jun 2020 12:20:12 -0400 Subject: [PATCH] renamed DISCOVERY_TYPE envvar to HARDWARE_DATA_MODEL --- packet/client.go | 6 +++--- packet/endpoints.go | 12 ++++++------ packet/models.go | 8 ++++---- packet/models_test.go | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packet/client.go b/packet/client.go index 2d84db47a..dd824f2db 100644 --- a/packet/client.go +++ b/packet/client.go @@ -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") diff --git a/packet/endpoints.go b/packet/endpoints.go index 5c1022e34..b53232c4d 100644 --- a/packet/endpoints.go +++ b/packet/endpoints.go @@ -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(), @@ -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(), diff --git a/packet/models.go b/packet/models.go index 1f9dac03d..9e1ebb651 100644 --- a/packet/models.go +++ b/packet/models.go @@ -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 @@ -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{} diff --git a/packet/models_test.go b/packet/models_test.go index 69d5cbd4a..182a91aa6 100644 --- a/packet/models_test.go +++ b/packet/models_test.go @@ -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) @@ -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) @@ -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)