-
Notifications
You must be signed in to change notification settings - Fork 1.8k
*: add back service account #629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
*: add back service account #629
Conversation
This adds service account support back to the sdk, as well as updates some documentation and fixes the `dep` warning when creating a new project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
a733bd5
to
120ec75
Compare
/cc @shawn-hurley just a heads up that we'll now have a service account by default for the ansible-operator as well. |
b1721da
to
0c944b1
Compare
@@ -207,7 +207,9 @@ $ sed -i 's|REPLACE_IMAGE|quay.io/example/memcached-operator:v0.0.1|g' deploy/op | |||
Deploy the memcached-operator: | |||
|
|||
```sh | |||
$ kubectl create -f deploy/rbac.yaml | |||
$ kubectl create -f deploy/service_account.yaml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 thank you for updating this file
if serviceAccountExp != buf.String() { | ||
dmp := diffmatchpatch.New() | ||
diffs := diffmatchpatch.New().DiffMain(serviceAccountExp, buf.String(), false) | ||
t.Fatalf("expected vs actual differs. Red text is missing and green text is extra.\n%v", dmp.DiffPrettyText(diffs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This library did not work for me. I did not see a diff with different colors. it would be easier if we just printed out the mismatched lines IMO. Is there some section of a user guide that I have not updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does seem a bit iffy. I think my macbook wasn't showing different colors, but it seems to be working right now on my thinkpad and in travis. It might have something to do with the way that the terminals handle escapes and color. This is the the way it's handled in diffmergepatch: https://github.com/sergi/go-diff/blob/master/diffmatchpatch/diff.go#L1183
If we want to keep using this library, we can either keep it like this or change to DiffToDelta, which would have an output like this instead (the numbers after =
, -
, and +
are characters to keep, remove, or add respectively):
--- FAIL: TestGopkgtoml (0.00s)
gopkgtoml_test.go:33: expected vs actual differs.
=1548 -3 =72 + unused-packages = false%0A
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexNPavel Is there any way to print out only the lines that differ for expected vs actual?
The above output is a little hard to comprehend.
The colorized diff works for me but like you pointed out its dependent on the terminal settings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like the diffmergepatch
library has any tools for printing lines that differ or outputting a more diff
-like output. So we're kinda stuck with the above two options unless we move to a new library or make our own helper functions, which may not be that simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it helps, I've been playing with this same library to get diffs out of the helm operator. Here's where I've ended up so far:
func diff(a, b string) string {
dmp := diffmatchpatch.New()
wSrc, wDst, warray := dmp.DiffLinesToRunes(a, b)
diffs := dmp.DiffMainRunes(wSrc, wDst, false)
diffs = dmp.DiffCharsToLines(diffs, warray)
var buff bytes.Buffer
for _, diff := range diffs {
text := diff.Text
switch diff.Type {
case diffmatchpatch.DiffInsert:
_, _ = buff.WriteString(prefixLines(text, "+"))
case diffmatchpatch.DiffDelete:
_, _ = buff.WriteString(prefixLines(text, "-"))
case diffmatchpatch.DiffEqual:
_, _ = buff.WriteString(prefixLines(text, " "))
}
}
return buff.String()
}
func prefixLines(s, prefix string) string {
var buf bytes.Buffer
lines := strings.Split(s, "\n")
ls := regexp.MustCompile("^")
for _, line := range lines[:len(lines)-1] {
buf.WriteString(ls.ReplaceAllString(line, prefix))
buf.WriteString("\n")
}
return buf.String()
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joelanford that works very well. Thanks. Since this diff work is unrelated to this PR, I'll leave this PR as is and make a new PR to change that replaces the diffs in the current tests with your methods, plus color as that can improve readability in terminals that support it. The lines based method is much easier to read, especially if you're only modifying a couple characters in a line, which can become really messy with the DiffPrettyText
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah let's add in Joe's diff changes in a new PR.
*/ | ||
sa, err := ioutil.ReadFile("deploy/service_account.yaml") | ||
if err != nil { | ||
log.Fatalf("could not find sa manifest: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could not find the manifest deploy/service_account.yaml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM after nit
This adds service account support back to the sdk, as well as
updates some documentation and fixes the
dep
warning when creatinga new project