Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: sayedppqq <[email protected]>
  • Loading branch information
sayedppqq committed Dec 20, 2023
1 parent 8c96893 commit 690dadf
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
44 changes: 44 additions & 0 deletions pkg/cmds/grafana_dashboard.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package cmds

import (
"github.com/spf13/cobra"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"k8s.io/kubectl/pkg/util/i18n"
"k8s.io/kubectl/pkg/util/templates"
"kubedb.dev/cli/pkg/dashboard"
)

var dashboardLong = templates.LongDesc(`
Check availability in prometheus server of metrics used in a grafana dashboard.
`)

var dashboardExample = templates.Examples(`
# Check availability of mongodb-summary-dashboard grafana dashboard of mongodb
kubectl dba dashboard mongodb mongodb-summary-dashboard
Valid dashboards include:
* elasticsearch
* mongodb
* mariadb
* mysql
* postgres
* redis
`)

func NewCmdDashboardCMD(f cmdutil.Factory) *cobra.Command {
var branch string
cmd := &cobra.Command{
Use: "dashboard",
Short: i18n.T("Check availability of a grafana dashboard"),
Long: dashboardLong,

Run: func(cmd *cobra.Command, args []string) {
dashboard.Run(f, args, branch)
},
Example: dashboardExample,
DisableFlagsInUseLine: true,
DisableAutoGenTag: true,
}
cmd.Flags().StringVarP(&branch, "branch", "b", "master", "branch name of the github repo")
return cmd
}
23 changes: 23 additions & 0 deletions pkg/dashboard/db.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package dashboard

import (
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"log"
)

type DashboardOpts struct {
Branch string
Database string
Dashboard string
}

func Run(f cmdutil.Factory, args []string, branch string) {
if len(args) < 2 {
log.Fatal("Enter database and grafana dashboard name as argument")
}
dashboardOpts := DashboardOpts{
Branch: branch,
Database: args[0],
Dashboard: args[1],
}
}

0 comments on commit 690dadf

Please sign in to comment.