forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
/
classic-client.go
42 lines (34 loc) · 1.3 KB
/
classic-client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package apiclient
import (
"context"
"fmt"
"k8s.io/client-go/tools/clientcmd"
"github.com/argoproj/argo/pkg/apiclient/cronworkflow"
workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow"
workflowarchivepkg "github.com/argoproj/argo/pkg/apiclient/workflowarchive"
"github.com/argoproj/argo/pkg/client/clientset/versioned"
"github.com/argoproj/argo/util/help"
)
type classicClient struct {
versioned.Interface
}
func newClassicClient(clientConfig clientcmd.ClientConfig) (context.Context, Client, error) {
restConfig, err := clientConfig.ClientConfig()
if err != nil {
return nil, nil, err
}
wfClient, err := versioned.NewForConfig(restConfig)
if err != nil {
return nil, nil, err
}
return context.Background(), &classicClient{wfClient}, nil
}
func (a *classicClient) NewWorkflowServiceClient() workflowpkg.WorkflowServiceClient {
return &classicWorkflowServiceClient{a.Interface}
}
func (a *classicClient) NewCronWorkflowServiceClient() cronworkflow.CronWorkflowServiceClient {
return &classicCronWorkflowServiceClient{a.Interface}
}
func (a *classicClient) 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)
}