-
Notifications
You must be signed in to change notification settings - Fork 104
/
ui.go
35 lines (30 loc) · 954 Bytes
/
ui.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2020 VMware, Inc.
// SPDX-License-Identifier: Apache-2.0
package clusterapply
import (
ctlresm "github.com/k14s/kapp/pkg/kapp/resourcesmisc"
)
type UI interface {
NotifySection(msg string, args ...interface{})
Notify(msgs []string)
}
type DoneApplyStateUI struct {
State string
Message string
Error bool
}
func NewDoneApplyStateUI(state ctlresm.DoneApplyState, err error) DoneApplyStateUI {
if err != nil {
return DoneApplyStateUI{State: "error", Message: err.Error(), Error: true}
}
switch {
case state.Done && state.Successful:
return DoneApplyStateUI{State: "ok", Message: state.Message, Error: false}
case state.Done && !state.Successful:
return DoneApplyStateUI{State: "fail", Message: state.Message, Error: true}
case !state.Done:
return DoneApplyStateUI{State: "ongoing", Message: state.Message, Error: true}
default:
return DoneApplyStateUI{State: "unknown", Message: state.Message, Error: true}
}
}