Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Added version command #41

Merged
merged 10 commits into from
Apr 2, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
export REPOSITORY=flytectl
include boilerplate/lyft/golang_test_targets/Makefile

GIT_VERSION := $(shell git describe --always --tags)
GIT_HASH := $(shell git rev-parse --short HEAD)
TIMESTAMP := $(shell date '+%Y-%m-%d')
PACKAGE ?=github.com/flyteorg/flytestdlib

LD_FLAGS="-s -w -X $(PACKAGE)/version.Version=$(GIT_VERSION) -X $(PACKAGE)/version.Build=$(GIT_HASH) -X $(PACKAGE)/version.BuildTime=$(TIMESTAMP)"



define PIP_COMPILE
pip-compile $(1) --upgrade --verbose
endef
Expand All @@ -9,7 +18,7 @@ generate:
go test github.com/flyteorg/flytectl/cmd --update

compile:
go build -o bin/flytectl main.go
go build -o bin/flytectl -ldflags=$(LD_FLAGS) main.go

.PHONY: update_boilerplate
update_boilerplate:
Expand Down
3 changes: 2 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/flyteorg/flytectl/cmd/get"
"github.com/flyteorg/flytectl/cmd/register"
"github.com/flyteorg/flytectl/cmd/update"
"github.com/flyteorg/flytectl/cmd/version"
"github.com/flyteorg/flytectl/pkg/printer"
stdConfig "github.com/flyteorg/flytestdlib/config"
"github.com/flyteorg/flytestdlib/config/viper"
Expand Down Expand Up @@ -44,7 +45,7 @@ func newRootCmd() *cobra.Command {
rootCmd.PersistentFlags().StringVarP(&(config.GetConfig().Domain), "domain", "d", "", "Specifies the Flyte project's domain.")
rootCmd.PersistentFlags().StringVarP(&(config.GetConfig().Output), "output", "o", printer.OutputFormatTABLE.String(), fmt.Sprintf("Specifies the output type - supported formats %s", printer.OutputFormats()))
rootCmd.AddCommand(viper.GetConfigCommand())
rootCmd.AddCommand(versionCmd)
rootCmd.AddCommand(version.GetVersionCommand())
rootCmd.AddCommand(get.CreateGetCommand())
rootCmd.AddCommand(create.RemoteCreateCommand())
rootCmd.AddCommand(update.CreateUpdateCommand())
Expand Down
17 changes: 0 additions & 17 deletions cmd/version.go

This file was deleted.

58 changes: 58 additions & 0 deletions cmd/version/version.go
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("------------------------------------------------------------------------")
Copy link
Contributor

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...

Copy link
Contributor Author

@yindia yindia Apr 1, 2021

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

logrus.Infof("App [%s], Version [%s], BuildSHA [%s], BuildTS [%s]", appName, res.ControlPlaneVersion.Version, res.ControlPlaneVersion.Build, res.ControlPlaneVersion.BuildTime)
logrus.Info("------------------------------------------------------------------------")
}
2 changes: 1 addition & 1 deletion docs/source/gen/flytectl.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ SEE ALSO
* :doc:`flytectl_get` - Used for fetching various flyte resources including tasks/workflows/launchplans/executions/project.
* :doc:`flytectl_register` - Registers tasks/workflows/launchplans from list of generated serialized files.
* :doc:`flytectl_update` - Used for updating flyte resources eg: project.
* :doc:`flytectl_version` - Displays version information for the client and server.
* :doc:`flytectl_version` - Used for fetching flyte version

12 changes: 6 additions & 6 deletions docs/source/gen/flytectl_get_launchplan.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ The generated file would look similar to this

iamRoleARN: ""
inputs:
numbers:
- 0
numbers_count: 0
run_local_at_count: 10
numbers:
- 0
numbers_count: 0
run_local_at_count: 10
kubeServiceAcct: ""
targetDomain: ""
targetProject: ""
workflow: core.advanced.run_merge_sort.merge
version: "v3"
version: v3
workflow: core.advanced.run_merge_sort.merge_sort

Check the create execution section on how to launch one using the generated file.

Expand Down
2 changes: 1 addition & 1 deletion docs/source/gen/flytectl_get_task.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ The generated file would look similar to this
targetDomain: ""
targetProject: ""
task: core.advanced.run_merge_sort.merge
version: "v2"
version: v2

Check the create execution section on how to launch one using the generated file.

Expand Down
9 changes: 7 additions & 2 deletions docs/source/gen/flytectl_version.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
flytectl version
----------------

Displays version information for the client and server.
Used for fetching flyte version

Synopsis
~~~~~~~~


Displays version information for the client and server.

Example version.
::

bin/flytectl version


::

Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ go 1.13

require (
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/flyteorg/flyteidl v0.18.15
github.com/flyteorg/flytestdlib v0.3.13
github.com/flyteorg/flyteidl v0.18.25
github.com/flyteorg/flytestdlib v0.3.15
github.com/ghodss/yaml v1.0.0
github.com/golang/protobuf v1.4.3
github.com/google/uuid v1.1.2
github.com/kataras/tablewriter v0.0.0-20180708051242-e063d29b7c23
github.com/kr/text v0.2.0 // indirect
github.com/landoop/tableprinter v0.0.0-20180806200924-8bd8c2576d27
github.com/magiconair/properties v1.8.4
github.com/mattn/go-runewidth v0.0.9 // indirect
github.com/mitchellh/mapstructure v1.4.1
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
Expand All @@ -26,5 +27,3 @@ require (
gopkg.in/yaml.v2 v2.4.0
sigs.k8s.io/yaml v1.2.0
)

replace github.com/flyteorg/flyteidl => github.com/flyteorg/flyteidl v0.18.21-0.20210317055906-f2ce9eb7bd1f
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,11 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
github.com/fatih/color v1.10.0 h1:s36xzo75JdqLaaWoiEHk767eHiwo0598uUxyfiPkDsg=
github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM=
github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94=
github.com/flyteorg/flyteidl v0.18.21-0.20210317055906-f2ce9eb7bd1f h1:7qRMZRPQXUVpebBt92msIzQBRtJ4fraWhd75qA6oqaE=
github.com/flyteorg/flyteidl v0.18.21-0.20210317055906-f2ce9eb7bd1f/go.mod h1:b5Fq4Z8a5b0mF6pEwTd48ufvikUGVkWSjZiMT0ZtqKI=
github.com/flyteorg/flytestdlib v0.3.13 h1:5ioA/q3ixlyqkFh5kDaHgmPyTP/AHtqq1K/TIbVLUzM=
github.com/flyteorg/flyteidl v0.18.25 h1:XbHwM4G1u5nGAcdKod+ENgbL84cHdNzQIWY+NajuHs8=
github.com/flyteorg/flyteidl v0.18.25/go.mod h1:b5Fq4Z8a5b0mF6pEwTd48ufvikUGVkWSjZiMT0ZtqKI=
github.com/flyteorg/flytestdlib v0.3.13/go.mod h1:Tz8JCECAbX6VWGwFT6cmEQ+RJpZ/6L9pswu3fzWs220=
github.com/flyteorg/flytestdlib v0.3.15 h1:vzsfqriENyavv6EBwsIm55di2wC+j0jkmjw30JGHAkM=
github.com/flyteorg/flytestdlib v0.3.15/go.mod h1:Tz8JCECAbX6VWGwFT6cmEQ+RJpZ/6L9pswu3fzWs220=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk=
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4=
Expand Down Expand Up @@ -230,7 +231,6 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down