Skip to content

Commit

Permalink
fix: linter
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 8f455c5 commit 7aab2e5
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 14 deletions.
2 changes: 2 additions & 0 deletions sztp-agent/cmd/daemon_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2022-2023 Red Hat.

// Package cmd implements the CLI commands
package cmd

import (
Expand Down
1 change: 1 addition & 0 deletions sztp-agent/cmd/disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

// Package cmd implements the CLI commands
package cmd

Expand Down
2 changes: 2 additions & 0 deletions sztp-agent/cmd/disable_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2022-2023 Red Hat.

// Package cmd implements the CLI commands
package cmd

import (
Expand Down
1 change: 1 addition & 0 deletions sztp-agent/cmd/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

// Package cmd implements the CLI commands
package cmd

Expand Down
2 changes: 2 additions & 0 deletions sztp-agent/cmd/enable_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2022-2023 Red Hat.

// Package cmd implements the CLI commands
package cmd

import (
Expand Down
1 change: 1 addition & 0 deletions sztp-agent/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

// Package cmd implements the CLI commands
package cmd

Expand Down
2 changes: 2 additions & 0 deletions sztp-agent/cmd/run_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2022-2023 Red Hat.

// Package cmd implements the CLI commands
package cmd

import (
Expand Down
1 change: 1 addition & 0 deletions sztp-agent/cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

// Package cmd implements the CLI commands
package cmd

Expand Down
2 changes: 2 additions & 0 deletions sztp-agent/cmd/status_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2022-2023 Red Hat.

// Package cmd implements the CLI commands
package cmd

import (
Expand Down
1 change: 1 addition & 0 deletions sztp-agent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

// Package main
package main

import (
Expand Down
3 changes: 2 additions & 1 deletion sztp-agent/pkg/secureagent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/
// Package secureAgent implements the secure agent

// Package secureagent implements the secure agent
package secureagent

const (
Expand Down
3 changes: 2 additions & 1 deletion sztp-agent/pkg/secureagent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/
// Package secureAgent implements the secure agent

// Package secureagent implements the secure agent
package secureagent

import (
Expand Down
33 changes: 27 additions & 6 deletions sztp-agent/pkg/secureagent/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/
// Package secureAgent implements the secure agent

// Package secureagent implements the secure agent
package secureagent

import (
Expand Down Expand Up @@ -246,8 +247,16 @@ func (a *Agent) downloadAndValidateImage() error {
if err != nil {
return err
}
defer file.Close()
defer response.Body.Close()
defer func() {
if err := file.Close(); err != nil {
log.Println("[ERROR] Error when closing:", err)
}
}()
defer func() {
if err := response.Body.Close(); err != nil {
log.Println("[ERROR] Error when closing:", err)
}
}()

log.Printf("[INFO] Downloaded file: %s with size: %d", ARTIFACTS_PATH+a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference+filepath.Base(item), size)
log.Println("[INFO] Verify the file checksum: ", ARTIFACTS_PATH+a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.InfoTimestampReference+filepath.Base(item))
Expand All @@ -259,7 +268,11 @@ func (a *Agent) downloadAndValidateImage() error {
log.Panic(err)
return err
}
defer f.Close()
defer func() {
if err := f.Close(); err != nil {
log.Println("[ERROR] Error when closing:", err)
}
}()
h := sha256.New()
if _, err := io.Copy(h, f); err != nil {
return err
Expand Down Expand Up @@ -290,7 +303,11 @@ func (a *Agent) copyConfigurationFile() error {
log.Println("[ERROR] creating the configuration file", err.Error())
return err
}
defer file.Close()
defer func() {
if err := file.Close(); err != nil {
log.Println("[ERROR] Error when closing:", err)
}
}()

plainTest, _ := base64.StdEncoding.DecodeString(a.BootstrapServerOnboardingInfo.IetfSztpConveyedInfoOnboardingInformation.Configuration)
_, err = file.WriteString(string(plainTest))
Expand Down Expand Up @@ -330,7 +347,11 @@ func (a *Agent) launchScriptsConfiguration(typeOf string) error {
log.Println("[ERROR] creating the "+scriptName+"-configuration script", err.Error())
return err
}
defer file.Close()
defer func() {
if err := file.Close(); err != nil {
log.Println("[ERROR] Error when closing:", err)
}
}()

plainTest, _ := base64.StdEncoding.DecodeString(script)
_, err = file.WriteString(string(plainTest))
Expand Down
2 changes: 1 addition & 1 deletion sztp-agent/pkg/secureagent/daemon_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2022-2023 Red Hat.

// Package secureAgent implements the secure agent
// Package secureagent implements the secure agent
package secureagent

import (
Expand Down
1 change: 1 addition & 0 deletions sztp-agent/pkg/secureagent/disable.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

// Package secureAgent implements the secure agent
package secureagent

Expand Down
2 changes: 2 additions & 0 deletions sztp-agent/pkg/secureagent/disable_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2022-2023 Red Hat.

// Package secureagent implements the secure agent
package secureagent

import "testing"
Expand Down
3 changes: 2 additions & 1 deletion sztp-agent/pkg/secureagent/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/
// Package secureAgent implements the secure agent

// Package secureagent implements the secure agent
package secureagent

import "log"
Expand Down
2 changes: 2 additions & 0 deletions sztp-agent/pkg/secureagent/enable_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2022-2023 Red Hat.

// Package secureagent implements the secure agent
package secureagent

import "testing"
Expand Down
3 changes: 2 additions & 1 deletion sztp-agent/pkg/secureagent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/
// Package secureAgent implements the secure agent

// Package secureagent implements the secure agent
package secureagent

import "log"
Expand Down
2 changes: 2 additions & 0 deletions sztp-agent/pkg/secureagent/run_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2022-2023 Red Hat.

// Package secureagent implements the secure agent
package secureagent

import "testing"
Expand Down
3 changes: 2 additions & 1 deletion sztp-agent/pkg/secureagent/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/
// Package secureAgent implements the secure agent

// Package secureagent implements the secure agent
package secureagent

import "log"
Expand Down
2 changes: 2 additions & 0 deletions sztp-agent/pkg/secureagent/status_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2022-2023 Red Hat.

// Package secureagent implements the secure agent
package secureagent

import "testing"
Expand Down
9 changes: 7 additions & 2 deletions sztp-agent/pkg/secureagent/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/
// Package secureAgent implements the secure agent

// Package secureagent implements the secure agent
package secureagent

import (
Expand Down Expand Up @@ -81,7 +82,11 @@ func (a *Agent) doTLSRequest(input string, url string, empty bool) (*BootstrapSe
log.Println("Error doing the request", err.Error())
return nil, err
}
defer res.Body.Close()
defer func() {
if err := res.Body.Close(); err != nil {
log.Println("Error when closing:", err)
}
}()

bodyBytes, err := io.ReadAll(res.Body)
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions sztp-agent/pkg/secureagent/utils_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright (C) 2022-2023 Red Hat.

// Package secureagent implements the secure agent
package secureagent

import (
Expand Down

0 comments on commit 7aab2e5

Please sign in to comment.