Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
add root frame, improve default view
Browse files Browse the repository at this point in the history
  • Loading branch information
pnickolov committed Oct 26, 2021
1 parent e57a3d2 commit 959abca
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
2 changes: 2 additions & 0 deletions cmd/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,8 @@ func analyzeApp(app *appmodel.App) {
o.Conclusion = appmodel.CONCLUSION_EXCESSIVE_COST
} else if o.ReliabilityRisk.SafeRiskLevel() >= appmodel.RISK_NONE && o.ReliabilityRisk.SafeRiskLevel() <= appmodel.RISK_LOW {
o.Conclusion = appmodel.CONCLUSION_OK
} else if o.ReliabilityRisk.SafeRiskLevel() == appmodel.RISK_MEDIUM {
o.Conclusion = appmodel.CONCLUSION_RELIABILITY_RISK
}

// add recommendations
Expand Down
14 changes: 7 additions & 7 deletions cmd/ignite.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,17 @@ func runIgnite(cmd *cobra.Command, args []string) {
// }

// auto-enable show-all-apps in case no apps meet requirements
if !showAllApps {
if hideBlocked {
qualified := 0
for _, app := range apps {
if isQualifiedApp(app) {
qualified += 1
}
}
if qualified == 0 && deployment == "" { // if a deployment is specified, it will be shown anyway
showAllApps = true
log.Infof("No highly rated applications found. Showing all applications")
fmt.Fprintf(os.Stderr, "No highly rated applications found. Showing all applications\n")
hideBlocked = false
log.Infof("No applications meet optimization prerequisites. Showing all applications")
fmt.Fprintf(os.Stderr, "No applications meet optimization prerequisites. Showing all applications\n")
}
}

Expand All @@ -149,16 +149,16 @@ func runIgnite(cmd *cobra.Command, args []string) {
display.WriteHeader(table)
for _, app := range apps {
// skip unqualified apps (unless either -a flag or explicitly identified app)
if !isQualifiedApp(app) && !showAllApps && deployment == "" {
if !isQualifiedApp(app) && hideBlocked && deployment == "" {
skipped += 1
continue
}
display.WriteApp(table, app)
}
display.WriteOut(table)
if skipped > 0 {
log.Infof("%v applications were not shown due to low rating", skipped)
fmt.Fprintf(os.Stderr, "%v applications were not shown due to low rating. Use --show-all to see all apps\n", skipped)
log.Infof("%v applications were not shown as they don't meet optimization prerequisites", skipped)
fmt.Fprintf(os.Stderr, "%v applications were not shown as they don't meet optimization prerequisites. Remove the --hide-blocked option to see all apps\n", skipped)
}

}
8 changes: 7 additions & 1 deletion cmd/interactive.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,14 @@ func (table *AppTable) outputInteractiveRun() {
}
})

// create frame
f := tview.NewFrame(t)
f.AddText("Sign up for Opsani at https://opsani.com/create-your-account2/#ignite", false /*header*/, tview.AlignCenter, 0 /*color*/)
f.SetBorders(0 /*top*/, 0 /*bottom*/, 0 /*header*/, 1 /*footer*/, 0 /*left*/, 0 /*right*/)

// create pages and run
table.i.pages = tview.NewPages()
table.i.pages.AddPage("applist", t, true, true)
table.i.pages.AddPage("applist", f, true, true)
if err := app.SetRoot(table.i.pages, true).SetFocus(table.i.pages).Run(); err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func appEfficiencyColor(app *appmodel.App) (color int) {
} else if *rate >= 30 {
color = colorYellow
} else {
color = colorOrange
color = colorYellow //colorOrange
}
return
}
Expand Down
13 changes: 7 additions & 6 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var timeStart time.Time
var timeEnd time.Time
var timeStep time.Duration
var outputFormat string
var showAllApps bool
var hideBlocked bool
var showDebug bool
var suppressWarnings bool

Expand All @@ -48,8 +48,9 @@ func getOutputFormats() []string {
var rootCmd = &cobra.Command{
Use: "opsani-ignite [<namespace> [<deployment>]]",
Short: "Opsani Ignite for Kubernetes",
Long: `Opsani Ignite looks through the performance history of
application workloads running on Kubernetes and identifies optimization opportunities.
Long: `Opsani Ignite looks through the performance history of application workloads
running on Kubernetes and identifies reliability risks and optimization
opportunities.
For each application it finds, it evaluates what can be optimized and displays
a list of optimization candidates in preferred order of onboarding.`,
Expand Down Expand Up @@ -81,7 +82,7 @@ func init() {
rootCmd.PersistentFlags().StringVar(&timeStepString, "step", "1d", "Time resolution, in relative form")

rootCmd.PersistentFlags().StringVarP(&outputFormat, "output", "o", "", fmt.Sprintf("Output format (%v)", strings.Join(getOutputFormats(), "|")))
rootCmd.PersistentFlags().BoolVarP(&showAllApps, "show-all", "a", false, "Show all apps, including unoptimizable")
rootCmd.PersistentFlags().BoolVarP(&hideBlocked, "hide-blocked", "b", false, "Hide applications that don't meet optimization prerequisites")
rootCmd.PersistentFlags().BoolVar(&showDebug, "debug", false, "Display tracing/debug information to stderr")
rootCmd.PersistentFlags().BoolVarP(&suppressWarnings, "quiet", "q", false, "Suppress warning and info level messages")
}
Expand Down Expand Up @@ -148,11 +149,11 @@ func validateFlags(cmd *cobra.Command, args []string) error {

// check output format
if outputFormat == "" {
// smart select: detail view if a single app is specified; table view for multiple apps
// smart select: interactive view by default; if a single app is specified, then just show the detail view for it
if len(args) >= 2 { // namespace + deployment specifies a single app
outputFormat = OUTPUT_DETAIL
} else {
outputFormat = OUTPUT_TABLE
outputFormat = OUTPUT_INTERACTIVE
}
} else {
outputFormatValid := false
Expand Down

0 comments on commit 959abca

Please sign in to comment.