Skip to content

Commit a82c4b2

Browse files
authored
Make changes to run cli from the appscode/grafana-dashboards CI (#766)
Signed-off-by: sayedppqq <[email protected]> Signed-off-by: Arnob kumar saha <[email protected]>
1 parent a0aab82 commit a82c4b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+322
-246
lines changed

pkg/cmds/monitor.go

+24-1
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,22 @@ var alertExample = templates.Examples(`
8989
--prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090
9090
9191
Valid resource types include:
92+
* connectcluster
93+
* druid
9294
* elasticsearch
9395
* kafka
9496
* mariadb
9597
* mongodb
9698
* mysql
9799
* perconaxtradb
100+
* pgpool
98101
* postgres
99102
* proxysql
103+
* rabbitmq
100104
* redis
105+
* singlestore
106+
* solr
107+
* zookeeper
101108
`)
102109

103110
func AlertCMD(f cmdutil.Factory) *cobra.Command {
@@ -131,15 +138,22 @@ var dashboardExample = templates.Examples(`
131138
--prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090
132139
133140
Valid dashboards include:
141+
* connectcluster
142+
* druid
134143
* elasticsearch
135144
* kafka
136145
* mariadb
137146
* mongodb
138147
* mysql
139148
* perconaxtradb
149+
* pgpool
140150
* postgres
141151
* proxysql
152+
* rabbitmq
142153
* redis
154+
* singlestore
155+
* solr
156+
* zookeeper
143157
144158
If --file is given, that is the local file. absolute or relative path both accepted.
145159
If --url is given, that is the remote file. You have to specify the full raw url.
@@ -152,14 +166,15 @@ func DashboardCMD(f cmdutil.Factory) *cobra.Command {
152166
branch string
153167
file string
154168
url string
169+
isDB bool
155170
)
156171
cmd := &cobra.Command{
157172
Use: "dashboard",
158173
Short: i18n.T("Check availability of a grafana dashboard"),
159174
Long: dashboardLong,
160175

161176
Run: func(cmd *cobra.Command, args []string) {
162-
dashboard.Run(f, args, branch, file, url, prom)
177+
dashboard.Run(f, args, branch, file, url, prom, isDB)
163178
},
164179
Example: dashboardExample,
165180
DisableFlagsInUseLine: true,
@@ -169,6 +184,7 @@ func DashboardCMD(f cmdutil.Factory) *cobra.Command {
169184
cmd.Flags().StringVarP(&file, "file", "f", "", "absolute or relative path of the file containing dashboard")
170185
cmd.Flags().StringVarP(&url, "url", "u", "", "url of the raw file containing dashboard. "+
171186
"For example: https://raw.githubusercontent.com/appscode/grafana-dashboards/master/mongodb/mongodb-summary-dashboard.json")
187+
cmd.Flags().BoolVarP(&isDB, "isdb", "d", true, "for non db object's. just provide the url")
172188
return cmd
173189
}
174190

@@ -186,15 +202,22 @@ var connectionExample = templates.Examples(`
186202
--prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090
187203
188204
Valid resource types include:
205+
* connectcluster
206+
* druid
189207
* elasticsearch
190208
* kafka
191209
* mariadb
192210
* mongodb
193211
* mysql
194212
* perconaxtradb
213+
* pgpool
195214
* postgres
196215
* proxysql
216+
* rabbitmq
197217
* redis
218+
* singlestore
219+
* solr
220+
* zookeeper
198221
`)
199222

200223
func ConnectionCMD(f cmdutil.Factory) *cobra.Command {

pkg/common/mysql.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"context"
2222
"fmt"
2323

24-
api "kubedb.dev/apimachinery/apis/kubedb/v1"
24+
dbapi "kubedb.dev/apimachinery/apis/kubedb/v1"
2525
cs "kubedb.dev/apimachinery/client/clientset/versioned"
2626

2727
cm "github.com/cert-manager/cert-manager/pkg/client/clientset/versioned"
@@ -34,7 +34,7 @@ import (
3434
)
3535

3636
type MySQLOpts struct {
37-
DB *api.MySQL
37+
DB *dbapi.MySQL
3838
DBImage string
3939
Config *rest.Config
4040
Client *kubernetes.Clientset
@@ -75,7 +75,7 @@ func NewMySQLOpts(f cmdutil.Factory, dbName, namespace string) (*MySQLOpts, erro
7575
return nil, err
7676
}
7777

78-
if db.Status.Phase != api.DatabasePhaseReady {
78+
if db.Status.Phase != dbapi.DatabasePhaseReady {
7979
return nil, fmt.Errorf("MySQL %s/%s is not ready", namespace, dbName)
8080
}
8181

pkg/common/postgres.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"context"
2222
"fmt"
2323

24-
api "kubedb.dev/apimachinery/apis/kubedb/v1"
24+
dbapi "kubedb.dev/apimachinery/apis/kubedb/v1"
2525
cs "kubedb.dev/apimachinery/client/clientset/versioned"
2626

2727
cm "github.com/cert-manager/cert-manager/pkg/client/clientset/versioned"
@@ -34,7 +34,7 @@ import (
3434
)
3535

3636
type PostgresOpts struct {
37-
DB *api.Postgres
37+
DB *dbapi.Postgres
3838
DBImage string
3939
Config *rest.Config
4040
Client *kubernetes.Clientset
@@ -77,7 +77,7 @@ func NewPostgresOpts(f cmdutil.Factory, dbName, namespace string) (*PostgresOpts
7777
return nil, err
7878
}
7979

80-
if db.Status.Phase != api.DatabasePhaseReady {
80+
if db.Status.Phase != dbapi.DatabasePhaseReady {
8181
return nil, fmt.Errorf("postgres %s/%s is not ready", namespace, dbName)
8282
}
8383

pkg/connect/elasticsearch.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323
"os"
2424

2525
"kubedb.dev/apimachinery/apis/kubedb"
26-
api "kubedb.dev/apimachinery/apis/kubedb/v1"
26+
dbapi "kubedb.dev/apimachinery/apis/kubedb/v1"
2727
cs "kubedb.dev/apimachinery/client/clientset/versioned"
2828
"kubedb.dev/cli/pkg/lib"
2929

@@ -103,7 +103,7 @@ Example curl commands:
103103
}
104104

105105
type elasticsearchOpts struct {
106-
db *api.Elasticsearch
106+
db *dbapi.Elasticsearch
107107
config *rest.Config
108108
client *kubernetes.Clientset
109109
dbClient *cs.Clientset
@@ -133,7 +133,7 @@ func newElasticsearchOpts(f cmdutil.Factory, dbName, namespace string) (*elastic
133133
return nil, err
134134
}
135135

136-
if db.Status.Phase != api.DatabasePhaseReady {
136+
if db.Status.Phase != dbapi.DatabasePhaseReady {
137137
return nil, fmt.Errorf("elasticsearch %s/%s is not ready", namespace, dbName)
138138
}
139139

@@ -165,7 +165,7 @@ func (opts *elasticsearchOpts) getDockerShellCommand(localPort int, dockerFlags,
165165
dockerCommand = append(dockerCommand, dockerFlags...)
166166

167167
if db.Spec.EnableSSL {
168-
secretName := db.CertificateName(api.ElasticsearchAdminCert)
168+
secretName := db.CertificateName(dbapi.ElasticsearchAdminCert)
169169
certSecret, err := opts.client.CoreV1().Secrets(db.Namespace).Get(context.TODO(), secretName, metav1.GetOptions{})
170170
if err != nil {
171171
return nil, err

pkg/connect/mariadb.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"path/filepath"
2525

2626
"kubedb.dev/apimachinery/apis/kubedb"
27-
api "kubedb.dev/apimachinery/apis/kubedb/v1"
27+
dbapi "kubedb.dev/apimachinery/apis/kubedb/v1"
2828
cs "kubedb.dev/apimachinery/client/clientset/versioned"
2929
"kubedb.dev/cli/pkg/lib"
3030

@@ -154,7 +154,7 @@ Examples:
154154
}
155155

156156
type mariadbOpts struct {
157-
db *api.MariaDB
157+
db *dbapi.MariaDB
158158
dbImage string
159159
config *rest.Config
160160
client *kubernetes.Clientset
@@ -185,7 +185,7 @@ func newmariadbOpts(f cmdutil.Factory, dbName, namespace string) (*mariadbOpts,
185185
return nil, err
186186
}
187187

188-
if db.Status.Phase != api.DatabasePhaseReady {
188+
if db.Status.Phase != dbapi.DatabasePhaseReady {
189189
return nil, fmt.Errorf("mariadb %s/%s is not ready", namespace, dbName)
190190
}
191191

@@ -228,7 +228,7 @@ func (opts *mariadbOpts) getDockerShellCommand(localPort int, dockerFlags, mysql
228228
}
229229

230230
if db.Spec.TLS != nil {
231-
secretName := db.CertificateName(api.MariaDBClientCert)
231+
secretName := db.CertificateName(dbapi.MariaDBClientCert)
232232
certSecret, err := opts.client.CoreV1().Secrets(db.Namespace).Get(context.TODO(), secretName, metav1.GetOptions{})
233233
if err != nil {
234234
return nil, err

pkg/connect/memcached.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"strconv"
2525

2626
"kubedb.dev/apimachinery/apis/kubedb"
27-
api "kubedb.dev/apimachinery/apis/kubedb/v1"
27+
dbapi "kubedb.dev/apimachinery/apis/kubedb/v1"
2828
cs "kubedb.dev/apimachinery/client/clientset/versioned"
2929
"kubedb.dev/cli/pkg/lib"
3030

@@ -81,7 +81,7 @@ func MemcachedConnectCMD(f cmdutil.Factory) *cobra.Command {
8181
}
8282

8383
type memcachedOpts struct {
84-
db *api.Memcached
84+
db *dbapi.Memcached
8585
config *rest.Config
8686
client *kubernetes.Clientset
8787
dbClient *cs.Clientset
@@ -108,7 +108,7 @@ func newMemcachedOpts(f cmdutil.Factory, dbName, namespace string) (*memcachedOp
108108
return nil, err
109109
}
110110

111-
if db.Status.Phase != api.DatabasePhaseReady {
111+
if db.Status.Phase != dbapi.DatabasePhaseReady {
112112
return nil, fmt.Errorf("memcached %s/%s is not ready", namespace, dbName)
113113
}
114114

pkg/connect/mongodb.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"path/filepath"
2525

2626
"kubedb.dev/apimachinery/apis/kubedb"
27-
api "kubedb.dev/apimachinery/apis/kubedb/v1"
27+
dbapi "kubedb.dev/apimachinery/apis/kubedb/v1"
2828
cs "kubedb.dev/apimachinery/client/clientset/versioned"
2929
"kubedb.dev/cli/pkg/lib"
3030

@@ -159,7 +159,7 @@ Examples:
159159
}
160160

161161
type mongodbOpts struct {
162-
db *api.MongoDB
162+
db *dbapi.MongoDB
163163
dbImage string
164164
config *rest.Config
165165
client *kubernetes.Clientset
@@ -190,7 +190,7 @@ func newMongodbOpts(f cmdutil.Factory, dbName, namespace string) (*mongodbOpts,
190190
return nil, err
191191
}
192192

193-
if db.Status.Phase != api.DatabasePhaseReady {
193+
if db.Status.Phase != dbapi.DatabasePhaseReady {
194194
return nil, fmt.Errorf("mongodb %s/%s is not ready", namespace, dbName)
195195
}
196196

@@ -233,7 +233,7 @@ func (opts *mongodbOpts) getDockerShellCommand(localPort int, dockerFlags, mongo
233233
}
234234

235235
if db.Spec.TLS != nil {
236-
secretName := db.GetCertSecretName(api.MongoDBClientCert, "")
236+
secretName := db.GetCertSecretName(dbapi.MongoDBClientCert, "")
237237
certSecret, err := opts.client.CoreV1().Secrets(db.Namespace).Get(context.TODO(), secretName, metav1.GetOptions{})
238238
if err != nil {
239239
return nil, err

pkg/connect/mysql.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"path/filepath"
2525

2626
"kubedb.dev/apimachinery/apis/kubedb"
27-
api "kubedb.dev/apimachinery/apis/kubedb/v1"
27+
dbapi "kubedb.dev/apimachinery/apis/kubedb/v1"
2828
cs "kubedb.dev/apimachinery/client/clientset/versioned"
2929
"kubedb.dev/cli/pkg/lib"
3030

@@ -156,7 +156,7 @@ Examples:
156156
}
157157

158158
type mysqlOpts struct {
159-
db *api.MySQL
159+
db *dbapi.MySQL
160160
dbImage string
161161
config *rest.Config
162162
client *kubernetes.Clientset
@@ -187,7 +187,7 @@ func newmysqlOpts(f cmdutil.Factory, dbName, namespace string) (*mysqlOpts, erro
187187
return nil, err
188188
}
189189

190-
if db.Status.Phase != api.DatabasePhaseReady {
190+
if db.Status.Phase != dbapi.DatabasePhaseReady {
191191
return nil, fmt.Errorf("mysql %s/%s is not ready", namespace, dbName)
192192
}
193193

@@ -230,7 +230,7 @@ func (opts *mysqlOpts) getDockerShellCommand(localPort int, dockerFlags, mysqlEx
230230
}
231231

232232
if db.Spec.TLS != nil {
233-
secretName := db.CertificateName(api.MySQLClientCert)
233+
secretName := db.CertificateName(dbapi.MySQLClientCert)
234234
certSecret, err := opts.client.CoreV1().Secrets(db.Namespace).Get(context.TODO(), secretName, metav1.GetOptions{})
235235
if err != nil {
236236
return nil, err

pkg/connect/postgres.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"path/filepath"
2626

2727
"kubedb.dev/apimachinery/apis/kubedb"
28-
api "kubedb.dev/apimachinery/apis/kubedb/v1"
28+
dbapi "kubedb.dev/apimachinery/apis/kubedb/v1"
2929
cs "kubedb.dev/apimachinery/client/clientset/versioned"
3030
"kubedb.dev/cli/pkg/lib"
3131

@@ -164,7 +164,7 @@ Examples:
164164
}
165165

166166
type postgresOpts struct {
167-
db *api.Postgres
167+
db *dbapi.Postgres
168168
dbImage string
169169
config *rest.Config
170170
client *kubernetes.Clientset
@@ -199,7 +199,7 @@ func newPostgresOpts(f cmdutil.Factory, dbName, namespace, postgresDBName string
199199
return nil, err
200200
}
201201

202-
if db.Status.Phase != api.DatabasePhaseReady {
202+
if db.Status.Phase != dbapi.DatabasePhaseReady {
203203
return nil, fmt.Errorf("postgres %s/%s is not ready", namespace, dbName)
204204
}
205205

@@ -245,7 +245,7 @@ func (opts *postgresOpts) getDockerShellCommand(localPort int, dockerFlags, post
245245
}
246246

247247
if db.Spec.TLS != nil {
248-
secretName := db.CertificateName(api.PostgresClientCert)
248+
secretName := db.CertificateName(dbapi.PostgresClientCert)
249249
certSecret, err := opts.client.CoreV1().Secrets(db.Namespace).Get(context.TODO(), secretName, metav1.GetOptions{})
250250
if err != nil {
251251
return nil, err

pkg/connect/redis.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"strings"
2727

2828
"kubedb.dev/apimachinery/apis/kubedb"
29-
api "kubedb.dev/apimachinery/apis/kubedb/v1"
29+
dbapi "kubedb.dev/apimachinery/apis/kubedb/v1"
3030
cs "kubedb.dev/apimachinery/client/clientset/versioned"
3131
"kubedb.dev/cli/pkg/lib"
3232

@@ -159,7 +159,7 @@ Examples:
159159
}
160160

161161
type redisOpts struct {
162-
db *api.Redis
162+
db *dbapi.Redis
163163
config *rest.Config
164164
client *kubernetes.Clientset
165165
dbClient *cs.Clientset
@@ -191,7 +191,7 @@ func newRedisOpts(f cmdutil.Factory, dbName, namespace string, keys, args []stri
191191
return nil, err
192192
}
193193

194-
if db.Status.Phase != api.DatabasePhaseReady {
194+
if db.Status.Phase != dbapi.DatabasePhaseReady {
195195
return nil, fmt.Errorf("redis %s/%s is not ready", namespace, dbName)
196196
}
197197

0 commit comments

Comments
 (0)