Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
366 changes: 182 additions & 184 deletions pb/config/config.pb.go

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions pb/config/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ message TestGroup {

// Where to gather linked issues from. (Currently a no-op).
IssueGatherOptions issue_gather_options = 63;

reserved 64;
}

// GCSConfig specifies results stored in GCS, typically created by prow.
Expand Down Expand Up @@ -395,10 +397,8 @@ message TestMetadataOptions {
}

message AutoBugOptions {
// [BETA] When specified, file bugs to this component, using the beta AutoBug.
// If you do not want to opt into the beta, specify `bug_component` in your
// TestGroup instead.
// TODO(b/154866134): Rename to autobug_component once we've migrated.
// When specified, file bugs to this component using AutoBug.
// TODO(b/342203680): Rename or alias to remove 'beta'.
int32 beta_autobug_component = 10;

// Whether to auto-close auto-filed bugs.
Expand Down Expand Up @@ -476,7 +476,7 @@ message AutoBugOptions {
// playbook.
string note = 14;

reserved 15, 16;
reserved 15 to 22;
}

message HotlistIdFromSource {
Expand Down Expand Up @@ -673,6 +673,8 @@ message DashboardTabAlertOptions {

// A custom message
string alert_mail_failure_message = 9;

reserved 10;
}

// Configuration options for dashboard tab flakiness alerts.
Expand Down
215 changes: 108 additions & 107 deletions pb/state/state.pb.go

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion pb/state/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,11 @@ message AlertInfo {
// defaults.
repeated string email_addresses = 15;

// Maps (custom column headers name):(custom column headers value) for arbitrary alert properties.
// Maps (custom column headers name):(custom column headers value) for
// arbitrary alert properties.
map<string,string> custom_column_headers = 16;

reserved 17;
}

// Info on default test metadata for a dashboard tab.
Expand Down
70 changes: 70 additions & 0 deletions pkg/api/v1/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,76 @@ func TestListRows(t *testing.T) {
},
},
},
{
name: "Returns tab from state with row info missing",
config: map[string]*pb.Configuration{
"gs://default/config": {
Dashboards: []*pb.Dashboard{
{
Name: "Dashboard1",
DashboardTab: []*pb.DashboardTab{
{
Name: "tab 1",
TestGroupName: "testgroupname",
},
},
},
},
},
},
grid: map[string]*statepb.Grid{
"gs://default/look-ma-tabs/Dashboard1/tab%201": {
Rows: []*statepb.Row{
{
Name: "tabrow1",
Id: "tabrow1",
Results: []int32{1, 2},
CellIds: []string{"cell-1", "cell-2"},
Messages: []string{"tab soda", ""},
Icons: []string{"", ""},
},
{
Name: "tabrow1@TESTGRID@method-a",
Id: "tabrow1",
Results: []int32{1, 2},
},
},
},
},
patch: func(s *Server) {
s.TabPathPrefix = "look-ma-tabs"
},
req: &apipb.ListRowsRequest{
Scope: "gs://default",
Dashboard: "dashboard1",
Tab: "tab1",
},
want: &apipb.ListRowsResponse{
Rows: []*apipb.ListRowsResponse_Row{
{
Name: "tabrow1",
Cells: []*apipb.ListRowsResponse_Cell{
{
Result: 1,
CellId: "cell-1",
Message: "tab soda",
},
{
Result: 1,
CellId: "cell-2",
},
},
},
{
Name: "tabrow1@TESTGRID@method-a",
Cells: []*apipb.ListRowsResponse_Cell{
{Result: 1},
{Result: 1},
},
},
},
},
},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion util/gcs/fake/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (cc *ConditionalClient) check(ctx context.Context, from, to *gcs.Path) erro
if to != nil && cc.write != nil {
attrs, err := cc.UploadClient.Stat(ctx, *to)
switch {
case err == storage.ErrObjectNotExist:
case errors.Is(err, storage.ErrObjectNotExist):
if cc.write.GenerationMatch != 0 {
return fmt.Errorf("bad generation: %w", &googleapi.Error{
Code: http.StatusPreconditionFailed,
Expand Down
5 changes: 5 additions & 0 deletions util/gcs/gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ func (g *Path) Set(v string) error {
return g.SetURL(u)
}

// Get the current value of the path
func (g *Path) Get() interface{} {
return g
}

// SetURL updates value to the passed in gs://bucket/obj url
func (g *Path) SetURL(u *url.URL) error {
switch {
Expand Down
2 changes: 1 addition & 1 deletion util/gcs/sort.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func LeastRecentlyUpdated(ctx context.Context, log logrus.FieldLogger, client St
for i, path := range paths {
attrs, err := attrs[i].Attrs, attrs[i].Err
switch {
case err == storage.ErrObjectNotExist:
case errors.Is(err, storage.ErrObjectNotExist):
generations[path] = 0
case err != nil:
log.WithError(err).WithField("path", path).Warning("Stat failed")
Expand Down
20 changes: 13 additions & 7 deletions util/links.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,33 +80,39 @@ func Tokens(template *configpb.LinkTemplate) []string {

// ExpandTemplate expands the given link template with given parameters.
func ExpandTemplate(template *configpb.LinkTemplate, parameters map[string]string) (string, error) {
rawUrl := expandTemplateString(template.GetUrl(), parameters, false)
baseUrl, err := url.Parse(rawUrl)
rawURL := expandTemplateString(template.GetUrl(), parameters, false, true)
baseURL, err := url.Parse(rawURL)
if err != nil {
return "", err
}
options := url.Values{}
for _, optionTemplate := range template.GetOptions() {
k := expandTemplateString(optionTemplate.GetKey(), parameters, true)
v := expandTemplateString(optionTemplate.GetValue(), parameters, true)
k := expandTemplateString(optionTemplate.GetKey(), parameters, true, true)
v := expandTemplateString(optionTemplate.GetValue(), parameters, true, true)
options.Add(k, v)
}
baseUrl.RawQuery = options.Encode()
return baseUrl.String(), nil
baseURL.RawQuery = options.Encode()
return baseURL.String(), nil
}

// expandTemplateString substitutes given parameters into the given link template.
func expandTemplateString(template string, parameters map[string]string, isQuery bool) string {
func expandTemplateString(template string, parameters map[string]string, isQuery bool, isEscaped bool) string {
// TODO: Handle start/end tokens.
// Substitute parameters for simple tokens.
for token, value := range parameters {
template = strings.ReplaceAll(template, token, value)
}

if !isEscaped {
return template
}

escape := url.PathEscape
if isQuery {
// Don't encode here; options.Encode() will do that.
escape = func(s string) string { return s }
}

// Encode specified parameters.
return encodeTokenRe.ReplaceAllStringFunc(
template,
Expand Down
2 changes: 1 addition & 1 deletion util/links_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ func TestExpandTemplateString(t *testing.T) {

for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
got := expandTemplateString(tc.templateStr, tc.parameters, tc.isQuery)
got := expandTemplateString(tc.templateStr, tc.parameters, tc.isQuery, true)
if diff := cmp.Diff(tc.want, got); diff != "" {
t.Errorf("expandTemplateString() differed (-want, +got): %s", diff)
}
Expand Down
Loading