github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/table/function/table.go (about)

     1  package functionTable
     2  
     3  import (
     4  	"strconv"
     5  	"strings"
     6  
     7  	commonSchema "github.com/taubyte/go-project-schema/common"
     8  	structureSpec "github.com/taubyte/go-specs/structure"
     9  	"github.com/taubyte/tau-cli/common"
    10  )
    11  
    12  func getTableData(function *structureSpec.Function, showId bool) (toRender [][]string) {
    13  	if showId {
    14  		toRender = [][]string{
    15  			{"ID", function.Id},
    16  		}
    17  	}
    18  
    19  	toRender = append(toRender, [][]string{
    20  		{"Name", function.Name},
    21  		{"Description", function.Description},
    22  		{"Tags", strings.Join(function.Tags, ", ")},
    23  		{"Type", function.Type},
    24  		{"Timeout", commonSchema.TimeToString(function.Timeout)},
    25  		{"Memory", commonSchema.UnitsToString(function.Memory)},
    26  	}...)
    27  
    28  	switch function.Type {
    29  	case common.FunctionTypeHttp, common.FunctionTypeHttps:
    30  		toRender = append(toRender, [][]string{
    31  			{"Method", function.Method},
    32  			{"Domains", strings.Join(function.Domains, ", ")},
    33  			{"Paths", strings.Join(function.Paths, ", ")},
    34  		}...)
    35  	case common.FunctionTypeP2P:
    36  		toRender = append(toRender, [][]string{
    37  			{"Protocol", function.Protocol},
    38  			{"Command", function.Command},
    39  			{"Local", strconv.FormatBool(function.Local)},
    40  		}...)
    41  	case common.FunctionTypePubSub:
    42  		toRender = append(toRender, [][]string{
    43  			{"Channel", function.Channel},
    44  			{"Local", strconv.FormatBool(function.Local)},
    45  		}...)
    46  	}
    47  
    48  	toRender = append(toRender, [][]string{
    49  		{"Source", function.Source},
    50  		{"Call", function.Call},
    51  	}...)
    52  
    53  	return toRender
    54  }