-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add version command and add build information to metrics
Signed-off-by: David Christofas <dchristofas@owncloud.com>
- Loading branch information
David Christofas
committed
Sep 25, 2020
1 parent
ff8fc23
commit 0578092
Showing
13 changed files
with
142 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Enhancement: Add version command | ||
|
||
Added a command to list the currently running services with their respective version. | ||
Also added a metrics entry for build information which includes the service version. | ||
|
||
https://github.com/owncloud/product/issues/226 |
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,45 @@ | ||
package command | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/micro/cli/v2" | ||
"github.com/micro/go-micro/v2/registry/mdns" | ||
tw "github.com/olekukonko/tablewriter" | ||
"github.com/owncloud/ocis/proxy/pkg/config" | ||
"github.com/owncloud/ocis/proxy/pkg/flagset" | ||
) | ||
|
||
// PrintVersion prints the service versions of all running instances. | ||
func PrintVersion(cfg *config.Config) *cli.Command { | ||
return &cli.Command{ | ||
Name: "version", | ||
Usage: "Print the versions of the running instances", | ||
Flags: flagset.ListProxyWithConfig(cfg), | ||
Action: func(c *cli.Context) error { | ||
reg := mdns.NewRegistry() | ||
services, err := reg.GetService(cfg.Service.Namespace + "." + cfg.Service.Name) | ||
if err != nil { | ||
fmt.Println(fmt.Errorf("could not get proxy services from the registry: %v", err)) | ||
return err | ||
} | ||
|
||
if len(services) == 0 { | ||
fmt.Println("No running proxy service found.") | ||
return nil | ||
} | ||
|
||
table := tw.NewWriter(os.Stdout) | ||
table.SetHeader([]string{"Version", "Address", "Id"}) | ||
table.SetAutoFormatHeaders(false) | ||
for _, s := range services { | ||
for _, n := range s.Nodes { | ||
table.Append([]string{s.Version, n.Address, n.Id}) | ||
} | ||
} | ||
table.Render() | ||
return nil | ||
}, | ||
} | ||
} |
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
Oops, something went wrong.