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

     1  package databaseTable
     2  
     3  import (
     4  	"strconv"
     5  	"strings"
     6  
     7  	"github.com/taubyte/go-project-schema/common"
     8  	structureSpec "github.com/taubyte/go-specs/structure"
     9  )
    10  
    11  func getNetworkDisplay(local bool) []string {
    12  	if local {
    13  		return []string{"\tNetwork", "host"}
    14  	}
    15  
    16  	return []string{"\tNetwork", "all"}
    17  }
    18  
    19  func getTableData(database *structureSpec.Database, showId bool) (toRender [][]string) {
    20  	if showId {
    21  		toRender = [][]string{
    22  			{"ID", database.Id},
    23  		}
    24  	}
    25  
    26  	secret := len(database.Key) > 0
    27  
    28  	toRender = append(toRender, [][]string{
    29  		{"Name", database.Name},
    30  		{"Description", database.Description},
    31  		{"Tags", strings.Join(database.Tags, ", ")},
    32  		{"Encryption", strconv.FormatBool(secret)},
    33  		{"Access", ""},
    34  		getNetworkDisplay(database.Local),
    35  		{"Replicas", ""},
    36  		{"\tMin", strconv.Itoa(int(database.Min))},
    37  		{"\tMax", strconv.Itoa(int(database.Max))},
    38  		{"Storage", ""},
    39  		{"\tSize", common.UnitsToString(database.Size)},
    40  	}...)
    41  
    42  	return toRender
    43  }