예제 #1
0
func actionEnv(c *cli.Context) {
	fid := checkFidOrFatal(c)

	envVars, err := api.FunctionEnv(fid)
	if err != nil {
		logger.Fatalf("Failed to list runtimes: %s", err)
	}

	t, fn := tab.New()
	defer fn()

	for _, e := range envVars {
		t.Output(e)
	}
}
예제 #2
0
func actionRuntime(c *cli.Context) {
	// Call API
	runtimes, err := api.RuntimeList()
	if err != nil {
		logger.Fatalf("Failed to list runtimes: %s", err)
	}

	if c.Bool("quiet") {
		for _, r := range runtimes {
			fmt.Println(r.ID)
		}
		return
	}

	// Print information
	t, fn := tab.New()
	defer fn()

	t.Output("ID", "NAME", "LABEL", "IMAGE", "DRIVER", "UPDATED")
	for _, r := range runtimes {
		t.Output(r.ID[:shortIDLen], r.Name, r.Label, r.Image, r.Driver, r.Updated.Format(time.RFC822))
	}
}
예제 #3
0
func actionList(c *cli.Context) {
	// Get information from api
	functions, err := api.FunctionList()
	if err != nil {
		logger.Fatalf("Failed to list functions: %s", err)
	}

	if c.Bool("quiet") {
		for _, f := range functions {
			fmt.Println(f.ID)
		}
		return
	}

	// Prepare header
	t, fn := tab.New()
	defer fn()

	// Cache runtime information
	rts := map[string]types.Runtime{}

	// TODO Use channels for enhance performance

	t.Output("ID", "NAME", "RUNTIME", "MEMORY", "UPDATED")
	for _, f := range functions {
		rt, ok := rts[f.Runtime]
		if !ok {
			r, err := api.RuntimeInfo(f.Runtime)
			if err != nil {
				logger.Fatalf("Failed to get runtime information: %s", err)
			}
			rt = r
			rts[f.Runtime] = r
		}
		t.Output(f.ID[:shortIDLen], f.Name, rt.Name, f.Memory, f.Updated.Format(time.RFC822))
	}
}