Retrieve function logs from controller (#207)
Establish a proxy server from the controller to the log database. Redirect query commands send from client to database then proxy back the db response. Use parameter binding instead of fmt.Sprintf to prevent SQL injection.
This commit is contained in:
committed by
Soam Vasani
parent
531f69a037
commit
990d943f21
+7
-24
@@ -288,11 +288,6 @@ func fnLogs(c *cli.Context) error {
|
||||
fatal("Need name of function, use --name")
|
||||
}
|
||||
|
||||
dbHost := c.String("dbhost")
|
||||
if len(dbHost) == 0 {
|
||||
fatal("Need host address of log database, use --dbhost")
|
||||
}
|
||||
|
||||
dbType := c.String("dbtype")
|
||||
if len(dbType) == 0 {
|
||||
dbType = logdb.INFLUXDB
|
||||
@@ -304,13 +299,9 @@ func fnLogs(c *cli.Context) error {
|
||||
f, err := client.FunctionGet(m)
|
||||
checkErr(err, "get function")
|
||||
|
||||
auth := logdb.DBConfig{
|
||||
DBType: dbType,
|
||||
Endpoint: dbHost,
|
||||
Username: c.String("username"),
|
||||
Password: c.String("password"),
|
||||
}
|
||||
logDB, err := logdb.GetLogDB(auth)
|
||||
// client first send db query to controller, then controller will
|
||||
// establishe a proxy server that bridges the client and the database.
|
||||
logDB, err := logdb.GetLogDB(dbType, c.GlobalString("server"))
|
||||
if err != nil {
|
||||
fatal("failed to connect log database")
|
||||
}
|
||||
@@ -369,11 +360,6 @@ func fnPods(c *cli.Context) error {
|
||||
fatal("Need name of function, use --name")
|
||||
}
|
||||
|
||||
dbHost := c.String("dbhost")
|
||||
if len(dbHost) == 0 {
|
||||
fatal("Need host address of log database, use --dbhost")
|
||||
}
|
||||
|
||||
dbType := c.String("dbtype")
|
||||
if len(dbType) == 0 {
|
||||
dbType = logdb.INFLUXDB
|
||||
@@ -384,13 +370,9 @@ func fnPods(c *cli.Context) error {
|
||||
f, err := client.FunctionGet(m)
|
||||
checkErr(err, "get function")
|
||||
|
||||
auth := logdb.DBConfig{
|
||||
DBType: dbType,
|
||||
Endpoint: dbHost,
|
||||
Username: c.String("username"),
|
||||
Password: c.String("password"),
|
||||
}
|
||||
logDB, err := logdb.GetLogDB(auth)
|
||||
// client first sends db query to the controller, then the controller
|
||||
// will establish a proxy server that bridges the client and the database.
|
||||
logDB, err := logdb.GetLogDB(dbType, c.GlobalString("server"))
|
||||
if err != nil {
|
||||
fatal("failed to connect log database")
|
||||
}
|
||||
@@ -404,6 +386,7 @@ func fnPods(c *cli.Context) error {
|
||||
fatal("failed to get pods of function")
|
||||
return err
|
||||
}
|
||||
fmt.Printf("NAME\t\n")
|
||||
for _, pod := range pods {
|
||||
fmt.Println(pod)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user