mirror of
https://github.com/kubescape/kubescape.git
synced 2026-02-14 18:09:55 +00:00
- Introduced a single context in main() to handle interrupt signals (os.Interrupt, syscall.SIGTERM). - Removed repetitive context creation in the program by reusing the propagated context. - Improved code readability and maintainability by centralizing context management. - Ensured consistent handling of graceful shutdown across the program. Signed-off-by: Ruslan Semagin <pixel.365.24@gmail.com>
25 lines
712 B
Go
25 lines
712 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/kubescape/go-logger"
|
|
"github.com/kubescape/go-logger/helpers"
|
|
"github.com/kubescape/kubescape/v3/core/core"
|
|
metav1 "github.com/kubescape/kubescape/v3/core/meta/datastructures/v1"
|
|
)
|
|
|
|
func main() {
|
|
ctx := context.TODO()
|
|
ks := core.NewKubescape(ctx)
|
|
downloads := []metav1.DownloadInfo{
|
|
{Target: "artifacts"}, // download all artifacts
|
|
{Target: "framework", Identifier: "security"}, // force add the "security" framework
|
|
}
|
|
for _, download := range downloads {
|
|
if err := ks.Download(&download); err != nil {
|
|
logger.L().Error("failed to download artifact", helpers.Error(err), helpers.String("target", download.Target))
|
|
}
|
|
}
|
|
}
|