Skip to content

Commit

Permalink
refactor: rename getBootstrapURL to discoverBootstrapURLs
Browse files Browse the repository at this point in the history
this better reflects what function is doing.
and it separates from public `GetBootstrapURL` func

`discoverBootstrapURLs` retrieves URLs from dhcp lease file

In the next patches it will also fetch them from network manager

Signed-off-by: Boris Glimcher <Boris.Glimcher@emc.com>
  • Loading branch information
glimchb committed Jul 22, 2024
1 parent 94f5d8a commit 28c2e14
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions sztp-agent/pkg/secureagent/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (a *Agent) RunCommandDaemon() error {
func (a *Agent) performBootstrapSequence() error {
var err error
if a.GetBootstrapURL() == "" {
err = a.getBootstrapURL()
err = a.discoverBootstrapURLs()
if err != nil {
return err
}
Expand Down Expand Up @@ -90,7 +90,7 @@ func (a *Agent) performBootstrapSequence() error {
return nil
}

func (a *Agent) getBootstrapURL() error {
func (a *Agent) discoverBootstrapURLs() error {
log.Println("[INFO] Get the Bootstrap URL from DHCP client")
var line string
if _, err := os.Stat(a.DhcpLeaseFile); err == nil {
Expand Down
4 changes: 2 additions & 2 deletions sztp-agent/pkg/secureagent/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const DHCPTestContent = `lease {
}`

//nolint:funlen
func TestAgent_getBootstrapURL(t *testing.T) {
func TestAgent_discoverBootstrapURLs(t *testing.T) {
dhcpTestFileOK := "/tmp/test.dhcp"
createTempTestFile(dhcpTestFileOK, DHCPTestContent, true)

Expand Down Expand Up @@ -95,7 +95,7 @@ func TestAgent_getBootstrapURL(t *testing.T) {
InputJSONContent: tt.fields.InputJSONContent,
DhcpLeaseFile: tt.fields.DhcpLeasesFile,
}
if err := a.getBootstrapURL(); (err != nil) != tt.wantErr {
if err := a.discoverBootstrapURLs(); (err != nil) != tt.wantErr {
t.Errorf("runDaemon() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down

0 comments on commit 28c2e14

Please sign in to comment.