Initial upgrade flow for control-plane
This commit is contained in:
@@ -2,6 +2,7 @@ package uboot
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -11,6 +12,8 @@ import (
|
||||
"example.com/monok8s/pkg/system"
|
||||
)
|
||||
|
||||
var ErrEnvNotFound = errors.New("fw env not found")
|
||||
|
||||
func NewFWEnvWriter(configPath string, ctlPath string) *FWEnvWriter {
|
||||
return &FWEnvWriter{
|
||||
Runner: system.NewRunner(system.RunnerConfig{
|
||||
@@ -38,8 +41,12 @@ func (w *FWEnvWriter) GetEnv(ctx context.Context, key string) (string, error) {
|
||||
res, err := w.Runner.RunWithOptions(ctx, w.CtlPath, args, system.RunOptions{Quiet: true})
|
||||
if err != nil {
|
||||
if res != nil {
|
||||
return "", fmt.Errorf("fw-printenv %q: %w (stdout=%q stderr=%q)",
|
||||
key, err, strings.TrimSpace(res.Stdout), strings.TrimSpace(res.Stderr))
|
||||
if strings.Contains(res.Stderr, "not defined") {
|
||||
return "", ErrEnvNotFound
|
||||
} else {
|
||||
return "", fmt.Errorf("fw-printenv %q: %w (stdout=%q stderr=%q)",
|
||||
key, err, strings.TrimSpace(res.Stdout), strings.TrimSpace(res.Stderr))
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("fw-printenv %q: %w", key, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user