Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: move progress to a separate file #423

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 0 additions & 109 deletions sztp-agent/pkg/secureagent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,115 +16,6 @@ const (
ARTIFACTS_PATH = "/tmp/"
)

type ProgressType int64

const (
ProgressTypeBootstrapInitiated ProgressType = iota
ProgressTypeParsingInitiated
ProgressTypeParsingWarning
ProgressTypeParsingError
ProgressTypeParsingComplete
ProgressTypeBootImageInitiated
ProgressTypeBootImageWarning
ProgressTypeBootImageError
ProgressTypeBootImageMismatch
ProgressTypeBootImageInstalledRebooting
ProgressTypeBootImageComplete
ProgressTypePreScriptInitiated
ProgressTypePreScriptWarning
ProgressTypePreScriptError
ProgressTypePreScriptComplete
ProgressTypeConfigInitiated
ProgressTypeConfigWarning
ProgressTypeConfigError
ProgressTypeConfigComplete
ProgressTypePostScriptInitiated
ProgressTypePostScriptWarning
ProgressTypePostScriptError
ProgressTypePostScriptComplete
ProgressTypeBootstrapWarning
ProgressTypeBootstrapError
ProgressTypeBootstrapComplete
ProgressTypeInformational
)

//nolint:funlen
func (s ProgressType) String() string {
switch s {
case ProgressTypeBootstrapInitiated:
return "bootstrap-initiated"
case ProgressTypeParsingInitiated:
return "parsing-initiated"
case ProgressTypeParsingWarning:
return "parsing-warning"
case ProgressTypeParsingError:
return "parsing-error"
case ProgressTypeParsingComplete:
return "parsing-complete"
case ProgressTypeBootImageInitiated:
return "boot-image-initiated"
case ProgressTypeBootImageWarning:
return "boot-image-warning"
case ProgressTypeBootImageError:
return "boot-image-error"
case ProgressTypeBootImageMismatch:
return "boot-image-mismatch"
case ProgressTypeBootImageInstalledRebooting:
return "boot-image-installed-rebooting"
case ProgressTypeBootImageComplete:
return "boot-image-complete"
case ProgressTypePreScriptInitiated:
return "pre-script-initiated"
case ProgressTypePreScriptWarning:
return "pre-script-warning"
case ProgressTypePreScriptError:
return "pre-script-error"
case ProgressTypePreScriptComplete:
return "pre-script-complete"
case ProgressTypeConfigInitiated:
return "config-initiated"
case ProgressTypeConfigWarning:
return "config-warning"
case ProgressTypeConfigError:
return "config-error"
case ProgressTypeConfigComplete:
return "config-complete"
case ProgressTypePostScriptInitiated:
return "post-script-initiated"
case ProgressTypePostScriptWarning:
return "post-script-warning"
case ProgressTypePostScriptError:
return "post-script-error"
case ProgressTypePostScriptComplete:
return "post-script-complete"
case ProgressTypeBootstrapWarning:
return "bootstrap-warning"
case ProgressTypeBootstrapError:
return "bootstrap-error"
case ProgressTypeBootstrapComplete:
return "bootstrap-complete"
case ProgressTypeInformational:
return "informational"
}
return "unknown"
}

type ProgressJSON struct {
IetfSztpBootstrapServerInput struct {
ProgressType string `json:"progress-type"`
Message string `json:"message"`
SSHHostKeys struct {
SSHHostKey []struct {
Algorithm string `json:"algorithm"`
KeyData string `json:"key-data"`
} `json:"ssh-host-key,omitempty"`
} `json:"ssh-host-keys,omitempty"`
TrustAnchorCerts struct {
TrustAnchorCert []string `json:"trust-anchor-cert,omitempty"`
} `json:"trust-anchor-certs,omitempty"`
} `json:"ietf-sztp-bootstrap-server:input"`
}

type InputJSON struct {
IetfSztpBootstrapServerInput struct {
HwModel string `json:"hw-model"`
Expand Down
119 changes: 119 additions & 0 deletions sztp-agent/pkg/secureagent/progress.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright (C) 2022-2023 Intel Corporation
Copyright (c) 2022 Dell Inc, or its subsidiaries.
Copyright (C) 2022 Red Hat.
*/

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

type ProgressType int64

const (
ProgressTypeBootstrapInitiated ProgressType = iota
ProgressTypeParsingInitiated
ProgressTypeParsingWarning
ProgressTypeParsingError
ProgressTypeParsingComplete
ProgressTypeBootImageInitiated
ProgressTypeBootImageWarning
ProgressTypeBootImageError
ProgressTypeBootImageMismatch
ProgressTypeBootImageInstalledRebooting
ProgressTypeBootImageComplete
ProgressTypePreScriptInitiated
ProgressTypePreScriptWarning
ProgressTypePreScriptError
ProgressTypePreScriptComplete
ProgressTypeConfigInitiated
ProgressTypeConfigWarning
ProgressTypeConfigError
ProgressTypeConfigComplete
ProgressTypePostScriptInitiated
ProgressTypePostScriptWarning
ProgressTypePostScriptError
ProgressTypePostScriptComplete
ProgressTypeBootstrapWarning
ProgressTypeBootstrapError
ProgressTypeBootstrapComplete
ProgressTypeInformational
)

//nolint:funlen
func (s ProgressType) String() string {
switch s {
case ProgressTypeBootstrapInitiated:
return "bootstrap-initiated"
case ProgressTypeParsingInitiated:
return "parsing-initiated"
case ProgressTypeParsingWarning:
return "parsing-warning"
case ProgressTypeParsingError:
return "parsing-error"
case ProgressTypeParsingComplete:
return "parsing-complete"
case ProgressTypeBootImageInitiated:
return "boot-image-initiated"
case ProgressTypeBootImageWarning:
return "boot-image-warning"
case ProgressTypeBootImageError:
return "boot-image-error"
case ProgressTypeBootImageMismatch:
return "boot-image-mismatch"
case ProgressTypeBootImageInstalledRebooting:
return "boot-image-installed-rebooting"
case ProgressTypeBootImageComplete:
return "boot-image-complete"
case ProgressTypePreScriptInitiated:
return "pre-script-initiated"
case ProgressTypePreScriptWarning:
return "pre-script-warning"
case ProgressTypePreScriptError:
return "pre-script-error"
case ProgressTypePreScriptComplete:
return "pre-script-complete"
case ProgressTypeConfigInitiated:
return "config-initiated"
case ProgressTypeConfigWarning:
return "config-warning"
case ProgressTypeConfigError:
return "config-error"
case ProgressTypeConfigComplete:
return "config-complete"
case ProgressTypePostScriptInitiated:
return "post-script-initiated"
case ProgressTypePostScriptWarning:
return "post-script-warning"
case ProgressTypePostScriptError:
return "post-script-error"
case ProgressTypePostScriptComplete:
return "post-script-complete"
case ProgressTypeBootstrapWarning:
return "bootstrap-warning"
case ProgressTypeBootstrapError:
return "bootstrap-error"
case ProgressTypeBootstrapComplete:
return "bootstrap-complete"
case ProgressTypeInformational:
return "informational"
}
return "unknown"
}

type ProgressJSON struct {
IetfSztpBootstrapServerInput struct {
ProgressType string `json:"progress-type"`
Message string `json:"message"`
SSHHostKeys struct {
SSHHostKey []struct {
Algorithm string `json:"algorithm"`
KeyData string `json:"key-data"`
} `json:"ssh-host-key,omitempty"`
} `json:"ssh-host-keys,omitempty"`
TrustAnchorCerts struct {
TrustAnchorCert []string `json:"trust-anchor-cert,omitempty"`
} `json:"trust-anchor-certs,omitempty"`
} `json:"ietf-sztp-bootstrap-server:input"`
}
Loading