@@ -11,29 +11,33 @@ import (
1111)
1212
1313var (
14- target = flag .String ("target" , "" , "-target staging.mpost-api.guardtek.net:443" )
15- expectedVersion = flag .String ("version" , "" , "Expected version" )
16- method = flag .String ("method" , "/version.Version/GetVersion" , "Version check endpoint path" )
17- clientType = flag .String ("client" , "grpc" , "Version check client type" )
18- checkCount = flag .Int ("count" , 12 , "Check count" )
19- sleepAfterCheck = flag .Int ("sleep" , 5 , "Sleep after check in seconds" )
20- showHelp = flag .Bool ("help" , false , "Show help" )
14+ target = flag .String ("target" , "" , "Version check endpoint target" )
15+ expectedBuildVersion = flag .String ("expect" , "" , "Expected version" )
16+ method = flag .String ("method" , "/version.Version/GetVersion" , "Version check endpoint path" )
17+ clientType = flag .String ("client" , "grpc" , "Version check client type" )
18+ checkCount = flag .Int ("count" , 12 , "Check count" )
19+ sleepAfterCheck = flag .Int ("sleep" , 5 , "Sleep after check in seconds" )
20+ printHelp = flag .Bool ("help" , false , "Print help" )
21+ printVersion = flag .Bool ("version" , false , "Print vcheck version" )
2122)
2223
24+ var Version = "dev"
25+
2326const checkTimeout = 10 * time .Second
2427
2528const usageStr = `
2629Usage: vcheck [options]
2730Options:
2831 --target <target> Target host including port. (e.g --target service.mydomain.com:443)
29- --version <version> Expected version (e.g -v 1.2.3)
32+ --expect <version> Expected version (e.g -v 1.2.3)
3033 --method <method> Version check endpoint (default: /debug.Debug/GetVersion)
3134 --client <client> Client type (grpc, http)
3235 --count <count> Check count (default: 12)
3336 --sleep <sleep> Sleep duration after check in seconds (default: 5)
3437
3538Other options:
36- --help
39+ --help Print help
40+ --version Print vcheck util version
3741`
3842
3943func usage () {
@@ -43,7 +47,13 @@ func usage() {
4347
4448func main () {
4549 flag .Parse ()
46- if * showHelp || * target == "" || * expectedVersion == "" {
50+
51+ if * printVersion {
52+ fmt .Println (Version )
53+ os .Exit (0 )
54+ }
55+
56+ if * printHelp || * target == "" || * expectedBuildVersion == "" {
4757 usage ()
4858 }
4959
@@ -59,16 +69,16 @@ func main() {
5969 continue
6070 }
6171 actualVersion = v .BuildVersion
62- fmt .Printf ("expected version %s, got %s\n " , * expectedVersion , actualVersion )
63- if actualVersion == * expectedVersion {
72+ fmt .Printf ("expected version %s, got %s\n " , * expectedBuildVersion , actualVersion )
73+ if actualVersion == * expectedBuildVersion {
6474 fmt .Println ("deployment successful" )
6575 return
6676 }
6777
6878 time .Sleep (sleep )
6979 }
7080
71- log .Fatalf ("deployment failed: expected version %s, got %s\n " , * expectedVersion , actualVersion )
81+ log .Fatalf ("deployment failed: expected version %s, got %s\n " , * expectedBuildVersion , actualVersion )
7282}
7383
7484func getVersion (c client.Client ) (* client.GetVersionReply , error ) {
0 commit comments