Skip to content

Commit

Permalink
fix: report more progress in new places
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb committed Jun 7, 2024
1 parent 97858c3 commit 5bb9036
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions sztp-agent/pkg/secureagent/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func (a *Agent) downloadAndValidateImage() error {
return errors.New("Checksum mismatch")
}
log.Println("[INFO] Checksum verified successfully")
_ = a.doReportProgress(ProgressTypeBootImageComplete)
return nil
default:
return errors.New("Unsupported hash algorithm")
Expand All @@ -254,6 +255,7 @@ func (a *Agent) downloadAndValidateImage() error {

func (a *Agent) copyConfigurationFile() error {
log.Println("[INFO] Starting the Copy Configuration.")
_ = 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 @@ -274,24 +276,27 @@ func (a *Agent) copyConfigurationFile() error {
return err
}
log.Println("[INFO] Configuration file copied successfully")
_ = a.doReportProgress(ProgressTypeConfigComplete)
return nil
}

func (a *Agent) launchScriptsConfiguration(typeOf string) error {
var script, scriptName string
var report ProgressType
var reportStart, reportEnd ProgressType
switch typeOf {
case "post":
script = a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.PostConfigurationScript
scriptName = "post"
report = ProgressTypePostScriptInitiated
reportStart = ProgressTypePostScriptInitiated
reportEnd = ProgressTypePostScriptComplete
default: // pre or default
script = a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.PreConfigurationScript
scriptName = "pre"
report = ProgressTypePreScriptInitiated
reportStart = ProgressTypePreScriptInitiated
reportEnd = ProgressTypePreScriptComplete
}
log.Println("[INFO] Starting the " + scriptName + "-configuration.")
_ = a.doReportProgress(report)
_ = a.doReportProgress(reportStart)
file, err := os.Create(ARTIFACTS_PATH + a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference + scriptName + "configuration.sh")

Check failure on line 300 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 All @@ -318,6 +323,7 @@ func (a *Agent) launchScriptsConfiguration(typeOf string) error {
return err
}
log.Println(string(out)) // remove it
_ = a.doReportProgress(reportEnd)
log.Println("[INFO] " + scriptName + "-Configuration script executed successfully")
return nil
}

0 comments on commit 5bb9036

Please sign in to comment.