Skip to content

Commit

Permalink
feat: Display argo-server version in argo version and in UI. (argop…
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Apr 22, 2020
1 parent 8de5728 commit d0cc776
Show file tree
Hide file tree
Showing 32 changed files with 1,426 additions and 506 deletions.
45 changes: 45 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,22 @@
}
}
},
"/api/v1/version": {
"get": {
"tags": [
"InfoService"
],
"operationId": "GetVersion",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.Version"
}
}
}
}
},
"/api/v1/workflow-events/{namespace}": {
"get": {
"tags": [
Expand Down Expand Up @@ -3196,6 +3212,35 @@
}
}
},
"io.argoproj.workflow.v1alpha1.Version": {
"type": "object",
"properties": {
"buildDate": {
"type": "string"
},
"compiler": {
"type": "string"
},
"gitCommit": {
"type": "string"
},
"gitTag": {
"type": "string"
},
"gitTreeState": {
"type": "string"
},
"goVersion": {
"type": "string"
},
"platform": {
"type": "string"
},
"version": {
"type": "string"
}
}
},
"io.argoproj.workflow.v1alpha1.Workflow": {
"type": "object",
"title": "Workflow is the definition of a workflow resource\n+genclient\n+genclient:noStatus\n+k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object",
Expand Down
3 changes: 1 addition & 2 deletions cmd/argo/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/argoproj/argo/cmd/argo/commands/archive"
"github.com/argoproj/argo/cmd/argo/commands/client"
"github.com/argoproj/argo/cmd/argo/commands/template"
"github.com/argoproj/argo/util/cmd"
)

const (
Expand Down Expand Up @@ -53,7 +52,7 @@ If you're using the Argo Server (e.g. because you need large workflow support or
command.AddCommand(NewStopCommand())
command.AddCommand(NewTerminateCommand())
command.AddCommand(archive.NewArchiveCommand())
command.AddCommand(cmd.NewVersionCmd(CLIName))
command.AddCommand(NewVersionCommand())
command.AddCommand(template.NewTemplateCommand())
command.AddCommand(cron.NewCronWorkflowCommand())
command.AddCommand(clustertemplate.NewClusterTemplateCommand())
Expand Down
35 changes: 35 additions & 0 deletions cmd/argo/commands/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package commands

import (
"github.com/argoproj/pkg/errors"
"github.com/spf13/cobra"

"github.com/argoproj/argo"
"github.com/argoproj/argo/cmd/argo/commands/client"
"github.com/argoproj/argo/pkg/apiclient"
infopkg "github.com/argoproj/argo/pkg/apiclient/info"
cmdutil "github.com/argoproj/argo/util/cmd"
)

// NewVersionCmd returns a new `version` command to be used as a sub-command to root
func NewVersionCommand() *cobra.Command {
var short bool
cmd := cobra.Command{
Use: "version",
Short: "Print version information",
Run: func(cmd *cobra.Command, args []string) {
cmdutil.PrintVersion(CLIName, argo.GetVersion(), short)
ctx, apiClient := client.NewAPIClient()
serviceClient, err := apiClient.NewInfoServiceClient()
if err == apiclient.NoArgoServerErr {
return
}
errors.CheckError(err)
serverVersion, err := serviceClient.GetVersion(ctx, &infopkg.GetVersionRequest{})
errors.CheckError(err)
cmdutil.PrintVersion("argo-server", *serverVersion, short)
},
}
cmd.Flags().BoolVar(&short, "short", false, "print just the version number")
return &cmd
}
2 changes: 2 additions & 0 deletions pkg/apiclient/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

clusterworkflowtmplpkg "github.com/argoproj/argo/pkg/apiclient/clusterworkflowtemplate"
cronworkflowpkg "github.com/argoproj/argo/pkg/apiclient/cronworkflow"
infopkg "github.com/argoproj/argo/pkg/apiclient/info"
workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow"
workflowarchivepkg "github.com/argoproj/argo/pkg/apiclient/workflowarchive"
workflowtemplatepkg "github.com/argoproj/argo/pkg/apiclient/workflowtemplate"
Expand All @@ -18,6 +19,7 @@ type Client interface {
NewCronWorkflowServiceClient() cronworkflowpkg.CronWorkflowServiceClient
NewWorkflowTemplateServiceClient() workflowtemplatepkg.WorkflowTemplateServiceClient
NewClusterWorkflowTemplateServiceClient() clusterworkflowtmplpkg.ClusterWorkflowTemplateServiceClient
NewInfoServiceClient() (infopkg.InfoServiceClient, error)
}

func NewClient(argoServer string, authSupplier func() string, clientConfig clientcmd.ClientConfig) (context.Context, Client, error) {
Expand Down
8 changes: 7 additions & 1 deletion pkg/apiclient/argo-kube-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/argoproj/argo/persist/sqldb"
"github.com/argoproj/argo/pkg/apiclient/clusterworkflowtemplate"
"github.com/argoproj/argo/pkg/apiclient/cronworkflow"
infopkg "github.com/argoproj/argo/pkg/apiclient/info"
workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow"
workflowarchivepkg "github.com/argoproj/argo/pkg/apiclient/workflowarchive"
"github.com/argoproj/argo/pkg/apiclient/workflowtemplate"
Expand All @@ -23,6 +24,7 @@ import (
)

var argoKubeOffloadNodeStatusRepo = sqldb.ExplosiveOffloadNodeStatusRepo
var NoArgoServerErr = fmt.Errorf("this is impossible if you are not using the Argo Server, see " + help.CLI)

type argoKubeClient struct {
}
Expand Down Expand Up @@ -60,7 +62,11 @@ func (a *argoKubeClient) NewWorkflowTemplateServiceClient() workflowtemplate.Wor
}

func (a *argoKubeClient) NewArchivedWorkflowServiceClient() (workflowarchivepkg.ArchivedWorkflowServiceClient, error) {
return nil, fmt.Errorf("it is impossible to interact with the workflow archive if you are not using the Argo Server, see " + help.CLI)
return nil, NoArgoServerErr
}

func (a *argoKubeClient) NewInfoServiceClient() (infopkg.InfoServiceClient, error) {
return nil, NoArgoServerErr
}

func (a *argoKubeClient) NewClusterWorkflowTemplateServiceClient() clusterworkflowtemplate.ClusterWorkflowTemplateServiceClient {
Expand Down
5 changes: 5 additions & 0 deletions pkg/apiclient/argo-server-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

clusterworkflowtmplpkg "github.com/argoproj/argo/pkg/apiclient/clusterworkflowtemplate"
cronworkflowpkg "github.com/argoproj/argo/pkg/apiclient/cronworkflow"
infopkg "github.com/argoproj/argo/pkg/apiclient/info"
workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow"
workflowarchivepkg "github.com/argoproj/argo/pkg/apiclient/workflowarchive"
workflowtemplatepkg "github.com/argoproj/argo/pkg/apiclient/workflowtemplate"
Expand Down Expand Up @@ -50,6 +51,10 @@ func (a *argoServerClient) NewClusterWorkflowTemplateServiceClient() clusterwork
return clusterworkflowtmplpkg.NewClusterWorkflowTemplateServiceClient(a.ClientConn)
}

func (a *argoServerClient) NewInfoServiceClient() (infopkg.InfoServiceClient, error) {
return infopkg.NewInfoServiceClient(a.ClientConn), nil
}

func NewClientConn(argoServer string) (*grpc.ClientConn, error) {
conn, err := grpc.Dial(argoServer, grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(MaxClientGRPCMessageSize)), grpc.WithInsecure())
if err != nil {
Expand Down
Loading

0 comments on commit d0cc776

Please sign in to comment.