forked from argoproj/argo-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WorkflowTemplate CRD (argoproj#1312)
- Loading branch information
Showing
60 changed files
with
3,196 additions
and
255 deletions.
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 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
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,59 @@ | ||
package template | ||
|
||
import ( | ||
"log" | ||
|
||
versioned "github.com/argoproj/argo/pkg/client/clientset/versioned" | ||
"github.com/argoproj/argo/pkg/client/clientset/versioned/typed/workflow/v1alpha1" | ||
"k8s.io/client-go/kubernetes" | ||
"k8s.io/client-go/rest" | ||
"k8s.io/client-go/tools/clientcmd" | ||
) | ||
|
||
// Global variables | ||
var ( | ||
restConfig *rest.Config | ||
clientConfig clientcmd.ClientConfig | ||
clientset *kubernetes.Clientset | ||
wfClientset *versioned.Clientset | ||
wftmplClient v1alpha1.WorkflowTemplateInterface | ||
namespace string | ||
) | ||
|
||
func initKubeClient() *kubernetes.Clientset { | ||
if clientset != nil { | ||
return clientset | ||
} | ||
var err error | ||
restConfig, err = clientConfig.ClientConfig() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// create the clientset | ||
clientset, err = kubernetes.NewForConfig(restConfig) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
return clientset | ||
} | ||
|
||
// InitWorkflowTemplateClient creates a new client for the Kubernetes WorkflowTemplate CRD. | ||
func InitWorkflowTemplateClient(ns ...string) v1alpha1.WorkflowTemplateInterface { | ||
if wftmplClient != nil { | ||
return wftmplClient | ||
} | ||
initKubeClient() | ||
var err error | ||
if len(ns) > 0 { | ||
namespace = ns[0] | ||
} else { | ||
namespace, _, err = clientConfig.Namespace() | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
} | ||
wfClientset = versioned.NewForConfigOrDie(restConfig) | ||
wftmplClient = wfClientset.ArgoprojV1alpha1().WorkflowTemplates(namespace) | ||
return wftmplClient | ||
} |
Oops, something went wrong.