github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/table/storage/table.go (about) 1 package storageTable 2 3 import ( 4 "strconv" 5 "strings" 6 "time" 7 8 "github.com/taubyte/go-project-schema/common" 9 structureSpec "github.com/taubyte/go-specs/structure" 10 ) 11 12 func getNetworkDisplay(public bool) []string { 13 if public { 14 return []string{"\tNetwork", "all"} 15 } 16 17 return []string{"\tNetwork", "host"} 18 } 19 20 func getTableData(storage *structureSpec.Storage, showId bool) (toRender [][]string) { 21 if showId { 22 toRender = [][]string{ 23 {"ID", storage.Id}, 24 } 25 } 26 27 toRender = append(toRender, [][]string{ 28 {"Name", storage.Name}, 29 {"Description", storage.Description}, 30 {"Tags", strings.Join(storage.Tags, ", ")}, 31 {"Access", ""}, 32 getNetworkDisplay(storage.Public), 33 }...) 34 35 switch storage.Type { 36 case "Object": 37 toRender = append(toRender, [][]string{ 38 {storage.Type, ""}, 39 {"\tVersioning", strconv.FormatBool(storage.Versioning)}, 40 {"\tSize", common.UnitsToString(storage.Size)}, 41 }...) 42 case "Streaming": 43 _time := common.TimeToString(storage.Ttl) 44 parsedTime, err := time.ParseDuration(_time) 45 if err == nil { 46 _time = parsedTime.Abs().String() 47 } 48 49 toRender = append(toRender, [][]string{ 50 {storage.Type, ""}, 51 {"\tTTL", _time}, 52 {"\tSize", common.UnitsToString(storage.Size)}, 53 }...) 54 } 55 56 return toRender 57 }