This repository has been archived by the owner on Feb 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete the implementation of the Go resolver (#435)
* Implement YAML walker for resolver * Return resolved yaml * Fully implement resolver & add unit test for walker * Undo local test edit * buildifier * Add grpc go deps for tests * Validate tags using strict validation * Move deleting seen images to top of resolver. * Update e2e test to use v2_2 image instead of v2 image.
- Loading branch information
Showing
8 changed files
with
264 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
) | ||
|
||
// TestYAMLWalk ensures the YAML walker in the resolver visits all strings in | ||
// an arbitrary YAML teplate with nested maps & lists. | ||
func TestYAMLWalk(t *testing.T) { | ||
y := []byte(`val1: val2 | ||
val3: val4 | ||
val5: | ||
val6: val7 | ||
val8: | ||
val9: val10 | ||
val11: | ||
val12: | ||
val13: | ||
val14: val15 | ||
val16: | ||
val17: | ||
- val18: val19 | ||
val20: val21 | ||
val22: val23 | ||
val24: | ||
- val25: val26 | ||
`) | ||
got := make(map[string]bool) | ||
sr := func(r *resolver, s string) (string, error) { | ||
got[s] = true | ||
return s, nil | ||
} | ||
r := &resolver{ | ||
strResolver: sr, | ||
} | ||
if _, err := r.resolveYAML(y); err != nil { | ||
t.Fatalf("Failed to resolve YAML: %v", err) | ||
} | ||
want := make(map[string]bool) | ||
for i := 1; i <= 26; i++ { | ||
want[fmt.Sprintf("val%d", i)] = true | ||
} | ||
|
||
if diff := cmp.Diff(want, got); diff != "" { | ||
t.Errorf("YAML walker did not visit all strings (-want +got):\n%s", diff) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters