[resultstore] Style/Tidy cleanup in entity.go
Change-Id: I6ae66a7c0ce55c716eb1ed44be713d02b385ee69
diff --git a/resultstore/entity.go b/resultstore/entity.go
index f1d9b0a..0a4176d 100644
--- a/resultstore/entity.go
+++ b/resultstore/entity.go
@@ -14,43 +14,18 @@
api "google.golang.org/genproto/googleapis/devtools/resultstore/v2"
)
-func timeToProtoTimestamp(input time.Time) *timestamp.Timestamp {
- output, err := ptypes.TimestampProto(input)
- if err != nil {
- // We should never get here unless the caller manually created some strange,
- // invalid time.Time value or the ResultStore API returned a nil value.
- panic(err.Error())
- }
- return output
-}
+const (
+ // The filename to use for a test's log file. Result Store recognizes this file name
+ // and displays it by default when a target is opened in the UI.
+ testLogName = "test.log"
+)
-func durationToProtoDuration(input time.Duration) *duration.Duration {
- return ptypes.DurationProto(input)
-}
-
-func mapToProperties(input map[string]string) []*api.Property {
- var props []*api.Property
- for k, v := range input {
- props = append(props, &api.Property{Key: k, Value: v})
- }
- return props
-}
-
-func lookupFileURI(files []*api.File, fileID string) string {
- for _, file := range files {
- if file.Uid == fileID {
- return file.Uri
- }
- }
- return ""
-}
-
-// Invocation maps to a ResultStore Invocation. See full docs at:
-// https://github.com/googleapis/googleapis/blob/master/google/devtools/resultstore/v2/invocation.proto
+// Invocation maps to a ResultStore Invocation.
+//
+// See https://github.com/googleapis/googleapis/blob/master/google/devtools/resultstore/v2/invocation.proto
+// for more documentation.
type Invocation struct {
- // The name of this Invocation as it appears in ResultStore.
- Name string
- // The ID of this invocation as it appears in ResultStore.
+ Name string
ID string
ProjectID string
Users []string
@@ -106,12 +81,12 @@
}
}
-// Configuration maps to a ResultStore Configuration. See full docs at:
-// https://github.com/googleapis/googleapis/blob/master/google/devtools/resultstore/v2/configuration.proto
+// Configuration maps to a ResultStore Configuration.
+//
+// See https://github.com/googleapis/googleapis/blob/master/google/devtools/resultstore/v2/configuration.proto
+// for more documentation.
type Configuration struct {
- // The name of this Configuration as it appears in ResultStore.
- Name string
- // The ID of this Configuration as it appears in ResultStore.
+ Name string
ID string
InvocationID string
Properties map[string]string
@@ -136,8 +111,10 @@
}
}
-// Target maps to a ResultStore Target. See full docs at:
-// https://github.com/googleapis/googleapis/blob/master/google/devtools/resultstore/v2/target.proto
+// Target maps to a ResultStore Target.
+//
+// See https://github.com/googleapis/googleapis/blob/master/google/devtools/resultstore/v2/target.proto
+// for more documentation.
type Target struct {
Name string
ID *TargetID
@@ -175,7 +152,7 @@
Visible: true,
Files: []*api.File{
&api.File{
- Uid: "test.log",
+ Uid: testLogName,
Uri: t.TestLogURI,
},
},
@@ -192,8 +169,10 @@
}
}
-// ConfiguredTarget maps to a ResultStore ConfiguredTarget. See full docs at:
-// https://github.com/googleapis/googleapis/blob/master/google/devtools/resultstore/v2/configured_target.proto
+// ConfiguredTarget maps to a ResultStore ConfiguredTarget.
+//
+// See https://github.com/googleapis/googleapis/blob/master/google/devtools/resultstore/v2/configured_target.proto
+// for more documentation.
type ConfiguredTarget struct {
Name string
ID *ConfiguredTargetID
@@ -243,8 +222,10 @@
}
}
-// TestAction maps to a ResultStore Action with a child TestAction. See full docs at:
-// https://github.com/googleapis/googleapis/blob/master/google/devtools/resultstore/v2/action.proto
+// TestAction maps to a ResultStore Action with a child TestAction.
+//
+// See https://github.com/googleapis/googleapis/blob/master/google/devtools/resultstore/v2/action.proto
+// for more documentation.
type TestAction struct {
Name string
ID *TestActionID
@@ -286,7 +267,7 @@
},
Files: []*api.File{
&api.File{
- Uid: "test.log",
+ Uid: testLogName,
Uri: a.TestLogURI,
},
},
@@ -309,6 +290,10 @@
}
}
+// Status describes the status of a ResultStore entity.
+//
+// See https://github.com/googleapis/googleapis/blob/master/google/devtools/resultstore/v2/common.proto
+// for more documentation.
type Status string
const (
@@ -337,3 +322,25 @@
return api.Status_UNKNOWN
}
}
+
+func timeToProtoTimestamp(input time.Time) *timestamp.Timestamp {
+ output, err := ptypes.TimestampProto(input)
+ if err != nil {
+ // We should never get here unless the caller manually created some strange,
+ // invalid time.Time value or the ResultStore API returned a nil value.
+ panic(err.Error())
+ }
+ return output
+}
+
+func durationToProtoDuration(input time.Duration) *duration.Duration {
+ return ptypes.DurationProto(input)
+}
+
+func mapToProperties(input map[string]string) []*api.Property {
+ var props []*api.Property
+ for k, v := range input {
+ props = append(props, &api.Property{Key: k, Value: v})
+ }
+ return props
+}