Removed the fn pods functionality (#594)

This commit is contained in:
Vishal
2018-04-19 14:32:16 +08:00
committed by Ta-Ching Chen
parent 400e19a48f
commit ff01cf2452
4 changed files with 0 additions and 68 deletions
-44
View File
@@ -647,50 +647,6 @@ func fnLogs(c *cli.Context) error {
}
}
func fnPods(c *cli.Context) error {
client := getClient(c.GlobalString("server"))
fmt.Println("This subcommand is deprecated and will be removed in the next release. Please use `kubectl get pods -l functionName=<name> --all-namespaces` instead.")
fnName := c.String("name")
if len(fnName) == 0 {
fatal("Need name of function, use --name")
}
dbType := c.String("dbtype")
if len(dbType) == 0 {
dbType = logdb.INFLUXDB
}
m := &metav1.ObjectMeta{Name: fnName}
f, err := client.FunctionGet(m)
checkErr(err, "get function")
// 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, getServerUrl())
if err != nil {
fatal("failed to connect log database")
}
logFilter := logdb.LogFilter{
Function: f.Metadata.Name,
FuncUid: string(f.Metadata.UID),
}
pods, err := logDB.GetPods(logFilter)
if err != nil {
fatal("failed to get pods of function")
return err
}
fmt.Printf("NAME\t\n")
for _, pod := range pods {
fmt.Println(pod)
}
return err
}
func fnTest(c *cli.Context) error {
fnName := c.String("name")
if len(fnName) == 0 {
-22
View File
@@ -45,28 +45,6 @@ type InfluxDB struct {
endpoint string
}
func (influx InfluxDB) GetPods(filter LogFilter) ([]string, error) {
parameters := make(map[string]interface{})
parameters["funcuid"] = filter.FuncUid
queryCmd := "select * from \"log\" where \"funcuid\" = $funcuid group by \"pod\""
query := influxdbClient.NewQueryWithParameters(queryCmd, INFLUXDB_DATABASE, "", parameters)
response, err := influx.query(query)
if err != nil /*|| response.Err != ""*/ {
return []string{}, err
}
pods := []string{}
for _, r := range response.Results {
for _, series := range r.Series {
for _, pod := range series.Tags {
pods = append(pods, pod)
}
}
}
return pods, nil
}
func makeIndexMap(cols []string) map[string]int {
indexMap := make(map[string]int, len(cols))
for i := range cols {
-1
View File
@@ -27,7 +27,6 @@ const (
)
type LogDatabase interface {
GetPods(LogFilter) ([]string, error)
GetLogs(LogFilter) ([]LogEntry, error)
}
-1
View File
@@ -151,7 +151,6 @@ func main() {
{Name: "delete", Usage: "Delete function", Flags: []cli.Flag{fnNameFlag}, Action: fnDelete},
{Name: "list", Usage: "List all functions", Flags: []cli.Flag{}, Action: fnList},
{Name: "logs", Usage: "Display function logs", Flags: []cli.Flag{fnNameFlag, fnPodFlag, fnFollowFlag, fnDetailFlag, fnLogDBTypeFlag, fnLogCountFlag}, Action: fnLogs},
{Name: "pods", Usage: "(Deprecated) Display function pods", Flags: []cli.Flag{fnNameFlag, fnLogDBTypeFlag}, Action: fnPods},
{Name: "test", Usage: "Test a function", Flags: []cli.Flag{fnNameFlag, fnEnvNameFlag, fnCodeFlag, fnSrcArchiveFlag, htMethodFlag, fnBodyFlag, fnHeaderFlag}, Action: fnTest},
}