cleaning up
parent
ca317cbdef
commit
dc49596f9c
|
|
@ -28,7 +28,9 @@ const (
|
|||
cacheMXKey = "metrics"
|
||||
cacheMXAPIKey = "metricsAPI"
|
||||
checkConnTimeout = 10 * time.Second
|
||||
CallTimeout = 5 * time.Second
|
||||
|
||||
// CallTimeout represents default api call timeout.
|
||||
CallTimeout = 5 * time.Second
|
||||
)
|
||||
|
||||
var supportedMetricsAPIVersions = []string{"v1beta1"}
|
||||
|
|
|
|||
|
|
@ -101,11 +101,12 @@ func (p *Popeye) List(ctx context.Context, _ string) ([]runtime.Object, error) {
|
|||
return oo, nil
|
||||
}
|
||||
|
||||
// Get fetch a resource.
|
||||
func (a *Popeye) Get(_ context.Context, _ string) (runtime.Object, error) {
|
||||
// Get retrieves a resource.
|
||||
func (p *Popeye) Get(_ context.Context, _ string) (runtime.Object, error) {
|
||||
return nil, errors.New("NYI!!")
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Helpers...
|
||||
|
||||
type popFactory struct {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ func (f *FishBuff) SetSuggestionFn(fn SuggestionFunc) {
|
|||
f.suggestionFn = fn
|
||||
}
|
||||
|
||||
// Activate activates the command.
|
||||
func (f *FishBuff) Activate() {
|
||||
if f.suggestionFn == nil {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ func NewHistory(limit int) *History {
|
|||
return &History{limit: limit}
|
||||
}
|
||||
|
||||
// List returns the current command history.
|
||||
func (h *History) List() []string {
|
||||
return h.commands
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,9 +71,8 @@ func (Popeye) Render(o interface{}, ns string, r *Row) error {
|
|||
// ----------------------------------------------------------------------------
|
||||
// Helpers...
|
||||
|
||||
// BOZO!! export!
|
||||
type (
|
||||
// Builder represents sanitizer
|
||||
// Builder represents a popeye report.
|
||||
Builder struct {
|
||||
Report Report `json:"popeye" yaml:"popeye"`
|
||||
}
|
||||
|
|
@ -96,9 +95,13 @@ type (
|
|||
Outcome Outcome `json:"issues,omitempty" yaml:"issues,omitempty"`
|
||||
}
|
||||
|
||||
// Outcomes represents a classification of report outcomes
|
||||
Outcome map[string]Issues
|
||||
Issues []Issue
|
||||
|
||||
// Issues represents a collection of issues.
|
||||
Issues []Issue
|
||||
|
||||
// Issue represents a sanitization issue.
|
||||
Issue struct {
|
||||
Group string `yaml:"group" json:"group"`
|
||||
GVR string `yaml:"gvr" json:"gvr"`
|
||||
|
|
@ -106,16 +109,19 @@ type (
|
|||
Message string `yaml:"message" json:"message"`
|
||||
}
|
||||
|
||||
// Tally tracks a section scores.
|
||||
Tally struct {
|
||||
OK, Info, Warning, Error int
|
||||
Count int
|
||||
}
|
||||
)
|
||||
|
||||
// Sum sums up tally counts.
|
||||
func (t *Tally) Sum() int {
|
||||
return t.OK + t.Info + t.Warning + t.Error
|
||||
}
|
||||
|
||||
// Score returns the overall sections score in percent.
|
||||
func (t *Tally) Score() int {
|
||||
oks := t.OK + t.Info
|
||||
return toPerc(float64(oks), float64(oks+t.Warning+t.Error))
|
||||
|
|
@ -128,14 +134,17 @@ func toPerc(v1, v2 float64) int {
|
|||
return int(math.Floor((v1 / v2) * 100))
|
||||
}
|
||||
|
||||
// Len returns a section length.
|
||||
func (s Sections) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
// Swap swaps values.
|
||||
func (s Sections) Swap(i, j int) {
|
||||
s[i], s[j] = s[j], s[i]
|
||||
}
|
||||
|
||||
// Less compares section scores.
|
||||
func (s Sections) Less(i, j int) bool {
|
||||
t1, t2 := s[i].Tally, s[j].Tally
|
||||
return t1.Score() < t2.Score()
|
||||
|
|
|
|||
|
|
@ -29,14 +29,7 @@ func (s *Section) Render(ctx context.Context, ns string, o interface{}) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func cleanse(s string) string {
|
||||
s = strings.Replace(s, "[", "(", -1)
|
||||
s = strings.Replace(s, "]", ")", -1)
|
||||
s = strings.Replace(s, "/", "::", -1)
|
||||
return s
|
||||
}
|
||||
|
||||
func (c *Section) outcomeRefs(parent *TreeNode, section render.Section) {
|
||||
func (*Section) outcomeRefs(parent *TreeNode, section render.Section) {
|
||||
for k, issues := range section.Outcome {
|
||||
p := NewTreeNode(section.GVR, cleanse(k))
|
||||
parent.Add(p)
|
||||
|
|
@ -58,6 +51,9 @@ func (c *Section) outcomeRefs(parent *TreeNode, section render.Section) {
|
|||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Helpers...
|
||||
|
||||
func colorize(s string, l config.Level) string {
|
||||
c := "green"
|
||||
switch l {
|
||||
|
|
@ -70,3 +66,10 @@ func colorize(s string, l config.Level) string {
|
|||
}
|
||||
return fmt.Sprintf("[%s::]%s", c, s)
|
||||
}
|
||||
|
||||
func cleanse(s string) string {
|
||||
s = strings.Replace(s, "[", "(", -1)
|
||||
s = strings.Replace(s, "]", ")", -1)
|
||||
s = strings.Replace(s, "/", "::", -1)
|
||||
return s
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue