(trafficSplitter schema.APIResponse, env cliconfig.Environment)
| 66 | } |
| 67 | |
| 68 | func trafficSplitTable(trafficSplitter schema.APIResponse, env cliconfig.Environment) (table.Table, error) { |
| 69 | rows := make([][]interface{}, 0, len(trafficSplitter.Spec.APIs)) |
| 70 | |
| 71 | for _, api := range trafficSplitter.Spec.APIs { |
| 72 | apisRes, err := cluster.GetAPI(MustGetOperatorConfig(env.Name), api.Name) |
| 73 | if err != nil { |
| 74 | return table.Table{}, err |
| 75 | } |
| 76 | |
| 77 | apiRes := apisRes[0] |
| 78 | if apiRes.Metadata == nil || apiRes.Status == nil { |
| 79 | continue |
| 80 | } |
| 81 | lastUpdated := time.Unix(apiRes.Metadata.LastUpdated, 0) |
| 82 | |
| 83 | apiName := apiRes.Metadata.Name |
| 84 | if api.Shadow { |
| 85 | apiName += " (shadow)" |
| 86 | } |
| 87 | rows = append(rows, []interface{}{ |
| 88 | env.Name, |
| 89 | apiName, |
| 90 | api.Weight, |
| 91 | fmt.Sprintf("%d/%d", apiRes.Status.Ready, apiRes.Status.Requested), |
| 92 | apiRes.Status.UpToDate, |
| 93 | libtime.SinceStr(&lastUpdated), |
| 94 | }) |
| 95 | } |
| 96 | |
| 97 | return table.Table{ |
| 98 | Headers: []table.Header{ |
| 99 | {Title: _titleEnvironment}, |
| 100 | {Title: _titleAPIs}, |
| 101 | {Title: _trafficSplitterWeights}, |
| 102 | {Title: _titleLive}, |
| 103 | {Title: _titleUpToDate}, |
| 104 | {Title: _titleLastUpdated}, |
| 105 | }, |
| 106 | Rows: rows, |
| 107 | }, nil |
| 108 | } |
| 109 | |
| 110 | func trafficSplitterListTable(trafficSplitter []schema.APIResponse, envNames []string) table.Table { |
| 111 | rows := make([][]interface{}, 0, len(trafficSplitter)) |
no test coverage detected