-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: sayedppqq <[email protected]>
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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], | ||
} | ||
} |