Skip to content

Commit

Permalink
fix(progress): remove redundant function argument
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Jun 10, 2024
1 parent ef66dd5 commit 98e0f42
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ docker-compose up --build web
## Test HTTP server from agent

```text
docker-compose run --rm -T agent curl --fail --key /private_key.pem --cert /my_cert.pem --cacert /opi.pem https://web:443/var/lib/
docker-compose run --rm -T agent curl --fail --key /private_key.pem --cert /my_cert.pem --cacert /opi.pem https://web:443/
```

OR
Expand Down
20 changes: 10 additions & 10 deletions sztp-agent/pkg/secureagent/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (a *Agent) RunCommandDaemon() error {
if err != nil {
return err
}
_ = a.doReportProgress(ProgressTypeBootstrapComplete, true)
_ = a.doReportProgress(ProgressTypeBootstrapComplete)
return nil
}

Expand All @@ -92,7 +92,7 @@ func (a *Agent) getBootstrapURL() error {
return nil
}

func (a *Agent) doReportProgress(s ProgressType, needssh bool) error {
func (a *Agent) doReportProgress(s ProgressType) error {
log.Println("[INFO] Starting the Report Progress request.")
url := strings.ReplaceAll(a.GetBootstrapURL(), "get-bootstrapping-data", "report-progress")
p := ProgressJSON{
Expand All @@ -110,7 +110,7 @@ func (a *Agent) doReportProgress(s ProgressType, needssh bool) error {
Message: "message sent via JSON",
},
}
if needssh {
if s == ProgressTypeBootstrapComplete {
// TODO: generate real key here
encodedKey := base64.StdEncoding.EncodeToString([]byte("mysshpass"))
p.IetfSztpBootstrapServerInput.SSHHostKeys = struct {
Expand Down Expand Up @@ -175,7 +175,7 @@ func (a *Agent) doRequestBootstrapServerOnboardingInfo() error {
return err
}
log.Println("[INFO] Response retrieved successfully")
_ = a.doReportProgress(ProgressTypeBootstrapInitiated, false)
_ = a.doReportProgress(ProgressTypeBootstrapInitiated)
crypto := res.IetfSztpBootstrapServerOutput.ConveyedInformation
newVal, err := base64.StdEncoding.DecodeString(crypto)
if err != nil {
Expand Down Expand Up @@ -215,7 +215,7 @@ func (a *Agent) doRequestBootstrapServerOnboardingInfo() error {
//nolint:funlen
func (a *Agent) downloadAndValidateImage() error {
log.Printf("[INFO] Starting the Download Image: %v", a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.BootImage.DownloadURI)
_ = a.doReportProgress(ProgressTypeBootImageInitiated, false)
_ = a.doReportProgress(ProgressTypeBootImageInitiated)
// Download the image from DownloadURI and save it to a file
a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference = fmt.Sprintf("%8d", time.Now().Unix())
for i, item := range a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.BootImage.DownloadURI {
Expand Down Expand Up @@ -300,7 +300,7 @@ func (a *Agent) downloadAndValidateImage() error {
return errors.New("Checksum mismatch")
}
log.Println("[INFO] Checksum verified successfully")
_ = a.doReportProgress(ProgressTypeBootImageComplete, false)
_ = a.doReportProgress(ProgressTypeBootImageComplete)
return nil
default:
return errors.New("Unsupported hash algorithm")
Expand All @@ -311,7 +311,7 @@ func (a *Agent) downloadAndValidateImage() error {

func (a *Agent) copyConfigurationFile() error {
log.Println("[INFO] Starting the Copy Configuration.")
_ = a.doReportProgress(ProgressTypeConfigInitiated, false)
_ = a.doReportProgress(ProgressTypeConfigInitiated)
// Copy the configuration file to the device
file, err := os.Create(ARTIFACTS_PATH + a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference + "-config")
if err != nil {
Expand All @@ -336,7 +336,7 @@ func (a *Agent) copyConfigurationFile() error {
return err
}
log.Println("[INFO] Configuration file copied successfully")
_ = a.doReportProgress(ProgressTypeConfigComplete, false)
_ = a.doReportProgress(ProgressTypeConfigComplete)
return nil
}

Expand All @@ -356,7 +356,7 @@ func (a *Agent) launchScriptsConfiguration(typeOf string) error {
reportEnd = ProgressTypePreScriptComplete
}
log.Println("[INFO] Starting the " + scriptName + "-configuration.")
_ = a.doReportProgress(reportStart, false)
_ = a.doReportProgress(reportStart)
file, err := os.Create(ARTIFACTS_PATH + a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference + scriptName + "configuration.sh")

Check failure on line 360 in sztp-agent/pkg/secureagent/daemon.go

View workflow job for this annotation

GitHub Actions / golangci

G304: Potential file inclusion via variable (gosec)
if err != nil {
log.Println("[ERROR] creating the "+scriptName+"-configuration script", err.Error())
Expand Down Expand Up @@ -387,7 +387,7 @@ func (a *Agent) launchScriptsConfiguration(typeOf string) error {
return err
}
log.Println(string(out)) // remove it
_ = a.doReportProgress(reportEnd, false)
_ = a.doReportProgress(reportEnd)
log.Println("[INFO] " + scriptName + "-Configuration script executed successfully")
return nil
}
2 changes: 1 addition & 1 deletion sztp-agent/pkg/secureagent/daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ func TestAgent_doReportProgress(t *testing.T) {
DhcpLeaseFile: tt.fields.DhcpLeaseFile,
ProgressJSON: tt.fields.ProgressJSON,
}
if err := a.doReportProgress(ProgressTypeBootstrapInitiated, false); (err != nil) != tt.wantErr {
if err := a.doReportProgress(ProgressTypeBootstrapInitiated); (err != nil) != tt.wantErr {
t.Errorf("doReportProgress() error = %v, wantErr %v", err, tt.wantErr)
}
})
Expand Down

0 comments on commit 98e0f42

Please sign in to comment.