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

89 changes: 89 additions & 0 deletions cmd/version/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package version

import (
"context"
"encoding/json"
"fmt"

adminclient "github.com/flyteorg/flyteidl/clients/go/admin"
"github.com/flyteorg/flyteidl/gen/pb-go/flyteidl/admin"
adminversion "github.com/flyteorg/flytestdlib/version"
yindia marked this conversation as resolved.
Show resolved Hide resolved
"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
`
)

type versionOutput struct {
// Specifies the Name of app
App string `json:"App,omitempty"`
// Specifies the GIT sha of the build
Build string `json:"Build,omitempty"`
// Version for the build, should follow a semver
Version string `json:"Version,omitempty"`
// Build timestamp
BuildTime string `json:"BuildTime,omitempty"`
}

// VersionCommand will return version of flyte
func GetVersionCommand() *cobra.Command {
versionCmd := &cobra.Command{
Use: "version",
Short: versionCmdShort,
Aliases: []string{"versions"},
Long: versionCmdLong,
RunE: func(cmd *cobra.Command, args []string) error {

ctx := context.Background()
adminClient, err := adminclient.InitializeAdminClientFromConfig(ctx)
if err != nil {
return fmt.Errorf("err %v: ", err)
}

v, err := adminClient.GetVersion(ctx, &admin.GetVersionRequest{})
if err != nil {
return fmt.Errorf("err %v: ", err)
}

// Print Flytectl
if err := PrintVersion(versionOutput{
Build: adminversion.Build,
BuildTime: adminversion.BuildTime,
Version: adminversion.Version,
App: "flytectl",
}); err != nil {
return err
}

// Print Flyteadmin
if err := PrintVersion(versionOutput{
Build: v.ControlPlaneVersion.Build,
BuildTime: v.ControlPlaneVersion.BuildTime,
Version: v.ControlPlaneVersion.Version,
App: "controlPlane",
}); err != nil {
return err
}
return nil
},
}

return versionCmd
}

func PrintVersion(response versionOutput) error {
b, err := json.MarshalIndent(response, "", " ")
if err != nil {
return fmt.Errorf("err %v:", err)
}
fmt.Print(string(b))
return nil
}
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