-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathspecs.go
More file actions
77 lines (72 loc) · 2.81 KB
/
specs.go
File metadata and controls
77 lines (72 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package printer
import (
"fmt"
"strings"
"github.com/gojek/feast/cli/feast/pkg/timeutil"
"github.com/gojek/feast/protos/generated/go/feast/core"
)
// PrintFeatureDetail prints the details about the feature.
// Prints and returns the resultant formatted string.
func PrintFeatureDetail(featureDetail *core.UIServiceTypes_FeatureDetail) string {
spec := featureDetail.GetSpec()
lines := []string{
fmt.Sprintf("%s:\t%s", "Id", spec.GetId()),
fmt.Sprintf("%s:\t%s", "Entity", spec.GetEntity()),
fmt.Sprintf("%s:\t%s", "Owner", spec.GetOwner()),
fmt.Sprintf("%s:\t%s", "Description", spec.GetDescription()),
fmt.Sprintf("%s:\t%s", "ValueType", spec.GetValueType()),
fmt.Sprintf("%s:\t%s", "Uri", spec.GetUri()),
}
lines = append(lines, fmt.Sprintf("%s:\t%s", "Created", timeutil.FormatToRFC3339(*featureDetail.GetCreated())))
lines = append(lines, fmt.Sprintf("%s:\t%s", "LastUpdated", timeutil.FormatToRFC3339(*featureDetail.GetLastUpdated())))
if jobs := featureDetail.GetJobs(); len(jobs) > 0 {
lines = append(lines, "Related Jobs:")
for _, job := range jobs {
lines = append(lines, fmt.Sprintf("- %s", job))
}
}
if tags := spec.GetTags(); len(tags) > 0 {
lines = append(lines, fmt.Sprintf("Tags: %s", strings.Join(tags, ",")))
}
out := strings.Join(lines, "\n")
fmt.Println(out)
return out
}
// PrintEntityDetail prints the details about the feature.
// Prints and returns the resultant formatted string.
func PrintEntityDetail(entityDetail *core.UIServiceTypes_EntityDetail) string {
spec := entityDetail.GetSpec()
lines := []string{
fmt.Sprintf("%s:\t%s", "Name", spec.GetName()),
fmt.Sprintf("%s:\t%s", "Description", spec.GetDescription()),
}
if tags := spec.GetTags(); len(tags) > 0 {
lines = append(lines, fmt.Sprintf("Tags: %s", strings.Join(tags, ",")))
}
lines = append(lines, fmt.Sprintf("%s:\t%s", "LastUpdated", timeutil.FormatToRFC3339(*entityDetail.GetLastUpdated())))
lines = append(lines, "Related Jobs:")
for _, job := range entityDetail.GetJobs() {
lines = append(lines, fmt.Sprintf("- %s", job))
}
out := strings.Join(lines, "\n")
fmt.Println(out)
return out
}
// PrintStorageDetail prints the details about the feature.
// Prints and returns the resultant formatted string.
// This function is deprecated, and may be removed in subsequent versions.
func PrintStorageDetail(storageDetail *core.UIServiceTypes_StorageDetail) string {
spec := storageDetail.GetSpec()
lines := []string{
fmt.Sprintf("%s:\t%s", "Id", spec.GetId()),
fmt.Sprintf("%s:\t%s", "Type", spec.GetType()),
fmt.Sprintf("Options:"),
}
for k, v := range spec.GetOptions() {
lines = append(lines, fmt.Sprintf(" %s: %s", k, v))
}
lines = append(lines, fmt.Sprintf("%s:\t%s", "LastUpdated", timeutil.FormatToRFC3339(*storageDetail.GetLastUpdated())))
out := strings.Join(lines, "\n")
fmt.Println(out)
return out
}