-
Notifications
You must be signed in to change notification settings - Fork 20
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
Glome server example #57
base: master
Are you sure you want to change the base?
Conversation
0be30f2
to
34c63e5
Compare
f24bccd
to
72755be
Compare
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.
Please remove compiled files from the change.
fmt.Println(`Please, provide key file, authorization script and address. | ||
For more information read --help option.`) | ||
os.Exit(0) | ||
} |
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.
There's a mechanism for enforcing flag presence, https://github.com/spf13/cobra#required-flags. If you still need to do more complicated sanity checks (cross-deps between flags, for example), you can do that check in a PreRunE
: https://github.com/spf13/cobra#prerun-and-postrun-hooks.
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.
SGTM
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'd use a PreRunE
that returns an error
with that message. That would automatically terminate the process with a non-zero exit code.
cc1205b
to
a084525
Compare
70af180
to
8abcfd0
Compare
Implements an example of use of glome server framework. This example of use is a binary with cobra interface and support different configurations Signed-off-by: pedrobn <pedrobn@google.com>
8abcfd0
to
8b27bc5
Compare
fmt.Println(`Please, provide key file, authorization script and address. | ||
For more information read --help option.`) | ||
os.Exit(0) | ||
} |
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'd use a PreRunE
that returns an error
with that message. That would automatically terminate the process with a non-zero exit code.
cmd := exec.Command(p) | ||
cmd.Stdin = nil | ||
cmd.Env = []string{ | ||
fmt.Sprintf("USER=%s", user), |
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.
The env vars used for configuration should avoid conflicts, a list of names that already have meaning can be found here: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html. IT might be a good idea to use a GLOME_AUTHZ_
prefix or similar.
if err == nil { | ||
return true, nil | ||
} else { | ||
return false, nil |
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.
Should return the error message (authz binary stderr).
} else { | ||
os.Exit(1) | ||
} | ||
} |
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.
Leftover, is superseded by authorization.sh
.
TOKEN=`curl -s 127.0.0.1:8000/v1/UYcvQ1u4uJ0OOtYqouURB07hleHDnvaogAFBi-ZW48N2/serial-number:1234567890=ABCDFGH%2F%23%3F/reboot/` | ||
if [[ "$TOKEN" != "p8M_BUKj7zXBVM2JlQhNYFxs4J-DzxRAps83ZaNDquY=" ]] | ||
then | ||
kill $ID |
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 test should report the HTTP code and the return body in case != 200. In the 200 case, it should output the returned token if it does not match.
Example implementation of glome server