This repository has been archived by the owner on May 31, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
Added version command #41
Merged
Merged
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6983a3f
wip: Added version command
yindia 3bae499
wip: small fix
yindia 33b3109
wip: version api call added
yindia c5cb388
added docs for version
c00b0b6
wip: lint fix
yindia 43f10a7
fix testcase
yindia da4508b
Removed version pkg
yindia e6eacde
added json output in version command
yindia 0559456
unit test added
yindia fee1989
Added brew install in readme
yindia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
This file was deleted.
Oops, something went wrong.
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,58 @@ | ||
package version | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
|
||
adminclient "github.com/flyteorg/flyteidl/clients/go/admin" | ||
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin" | ||
"github.com/flyteorg/flytestdlib/version" | ||
"github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// Long descriptions are whitespace sensitive when generating docs using sphinx. | ||
const ( | ||
versionCmdShort = `Used for fetching flyte version` | ||
versionCmdLong = ` | ||
Example version. | ||
:: | ||
|
||
bin/flytectl version | ||
` | ||
) | ||
|
||
// VersionCommand will return version of flyte | ||
func GetVersionCommand() *cobra.Command { | ||
versionCmd := &cobra.Command{ | ||
Use: "version", | ||
Short: versionCmdShort, | ||
Aliases: []string{"versions"}, | ||
Long: versionCmdLong, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
|
||
ctx := context.Background() | ||
adminClient, err := adminclient.InitializeAdminClientFromConfig(ctx) | ||
if err != nil { | ||
fmt.Printf("err %v:", err) | ||
os.Exit(1) | ||
} | ||
v, err := adminClient.GetVersion(ctx, &admin.GetVersionRequest{}) | ||
if err != nil { | ||
fmt.Printf("err %v:", err) | ||
os.Exit(1) | ||
} | ||
version.LogBuildInformation("flytectl") | ||
PrintVersion("flyteadmin", v) | ||
}, | ||
} | ||
|
||
return versionCmd | ||
} | ||
|
||
func PrintVersion(appName string, res *admin.GetVersionResponse) { | ||
logrus.Info("------------------------------------------------------------------------") | ||
logrus.Infof("App [%s], Version [%s], BuildSHA [%s], BuildTS [%s]", appName, res.ControlPlaneVersion.Version, res.ControlPlaneVersion.Build, res.ControlPlaneVersion.BuildTime) | ||
logrus.Info("------------------------------------------------------------------------") | ||
} |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
plz use
logger
from stdlib...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.
@EngHabu I can make these changes....but it's a command....we can't add its output in the log. I found that flytestdlib version package only prints the version in the log(We need to set the log level to print output). Printing log in JSON formate is not the solution in this case because it's log, not a output of a command