-
Notifications
You must be signed in to change notification settings - Fork 40
Conversation
Please write integration / unit tests 👍 |
pkg/cmd/util.go
Outdated
if err != nil { | ||
return nil, errors.Wrapf(err, "can't list *.yml files in %s", path) | ||
return nil, errors.Wrapf(err, "can't get file info about %s", path) |
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.
can't retrieve file information about
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.
github is messed up here, I didn't change anything
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.
I know, but the correct grammar is can't retrieve file information about %s
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.
When working with single file it works fine. Like this one works pretty well:
$ cat db.yaml | kedge generate -f - | grep -B 3 "kind"
---
apiVersion: v1
kind: PersistentVolumeClaim
--
status: {}
---
apiVersion: v1
kind: Service
--
loadBalancer: {}
---
apiVersion: extensions/v1beta1
kind: Deployment
But when I give multiple files, it does not work
$ cat *.yaml | kedge generate -f - | grep -B 3 "kind"
---
apiVersion: v1
kind: PersistentVolumeClaim
--
status: {}
---
apiVersion: v1
kind: Service
--
loadBalancer: {}
---
apiVersion: extensions/v1beta1
kind: Deployment
It is still reading only one file.
The right output for $ cat *.yaml | kedge generate -f - | grep -B 3 "kind"
should match following.
$ kedge generate -f . | grep -B 3 "kind"
---
apiVersion: v1
kind: PersistentVolumeClaim
--
status: {}
---
apiVersion: v1
kind: Service
--
loadBalancer: {}
---
apiVersion: extensions/v1beta1
kind: Deployment
--
status: {}
---
apiVersion: v1
kind: Service
--
loadBalancer: {}
---
apiVersion: extensions/v1beta1
kind: Deployment
@surajssd , if you put |
@surajnarwade Yes, but that's not what's intended nor originally used... You will have to update your function in order to facilitate having multiple files. |
that is not user friendly, we need another solution |
@kadel how it will distinguish between two files since it's stdin ? |
pkg/cmd/util.go
Outdated
scanner := bufio.NewScanner(os.Stdin) | ||
for scanner.Scan() { | ||
|
||
if strings.Contains(scanner.Text(), "name") && !strings.Contains(scanner.Text(), "-") && !strings.HasPrefix(scanner.Text(), " ") { |
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.
hmm, Interesting solution.
Maybe this could be a little bit more elegant if you use regexp instead of 3 tests with string ;-)
We should make sure that there are no unintentional consequences when we are using name
for detecting that new file begun. Like for example what happens if name
is at the end of the file? That is perfectly valid.
I think we have been over this discussion before of "how to make sure the given kedge format is valid one?". I think what @surajnarwade is saying is correct there is no way to find out the separation of various kedge files, unless user is writing the yaml files in valid way. So accoding to yaml specification:
source: http://www.yaml.org/spec/1.2/spec.html#id2760395 So it is user's responsibility to delimit multiple files being streamed in via STDIN |
@cdrage , I tried that solution but didn't work for me :(
I am bit confused over it. |
@surajnarwade it's not a direct solution, but rather a way to investigate on how to implement it. You would use: Some pseudocode: kedgeFile := `
name: httpd
containers:
- image: centos/httpd
services:
- name: httpd
type: LoadBalancer
portMappings:
- 8080:80
`
subproc := exec.Command("cat kedge.yml | ./kedge generate -f -")
output, _ := subproc.Output()
if output != kedgeFile {
return nil
} and compare the output(s). What errors are you getting too? It'll take some trial-and-error, but I believe it's do-able, let me know if you need any help 👍 |
fd481a9
to
f665e79
Compare
New tests LGTM 👍 Code LGTM 👍 |
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.
code lgtm other than small nitpicks
.travis.yml
Outdated
@@ -25,6 +25,7 @@ install: | |||
- true | |||
|
|||
script: | |||
- make bin |
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.
why are we adding this? kedge is getting installed anyways within travis 👎
pkg/cmd/util.go
Outdated
if err != nil { | ||
return nil, errors.Wrapf(err, "can't list *.yml files in %s", path) | ||
return nil, errors.Wrapf(err, "can't get file info about %s", path) |
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.
I know, but the correct grammar is can't retrieve file information about %s
8003138
to
57d4b5f
Compare
@cdrage all done |
return nil, errors.Wrapf(err, "cannot determine the absolute file path of %q", file) | ||
|
||
if file == "-" { | ||
data, err = ioutil.ReadAll(os.Stdin) |
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.
err
is not handled here
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.
added error handling :)
looks good, but needs rebase |
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, but this definitely needs second review
@cdrage , review needed :) |
@surajnarwade code LGTM. one last rebase and let's merge |
Resolves kedgeproject#183 For example, ``` $ cat mariadb.yaml | kedge generate -f - --- apiVersion: v1 kind: PersistentVolumeClaim metadata: creationTimestamp: null labels: app: database name: database ... ... ```
@containscafeine final review please and then it's ready to merge |
Resolves #183
For example,