Skip to content

Commit

Permalink
Switch to k8s-codegen generated workflow client and informer
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesuen committed Jan 4, 2018
1 parent 9b08b6e commit a0add24
Show file tree
Hide file tree
Showing 69 changed files with 2,052 additions and 474 deletions.
86 changes: 11 additions & 75 deletions .argo-ci/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,88 +14,25 @@ spec:
templates:
- name: argo-ci
steps:
- - name: controller-image
- - name: ci
template: ci-builder
arguments:
parameters:
- name: revision
value: "{{workflow.parameters.revision}}"
- name: repo
value: "{{workflow.parameters.repo}}"
- name: cmd
value: "make controller-image"

- name: executor-image
template: ci-builder
arguments:
parameters:
- name: revision
value: "{{workflow.parameters.revision}}"
- name: repo
value: "{{workflow.parameters.repo}}"
- name: cmd
value: "make executor-image"

- name: cli-linux
template: ci-builder
arguments:
parameters:
- name: revision
value: "{{workflow.parameters.revision}}"
- name: repo
value: "{{workflow.parameters.repo}}"
- name: cmd
value: "make cli-linux"

- name: cli-darwin
template: ci-builder
arguments:
parameters:
- name: revision
value: "{{workflow.parameters.revision}}"
- name: repo
value: "{{workflow.parameters.repo}}"
- name: cmd
value: "make cli-darwin"

- name: ui-image
template: ci-builder
arguments:
parameters:
- name: revision
value: "{{workflow.parameters.revision}}"
- name: repo
value: "{{workflow.parameters.repo}}"
- name: cmd
value: "make ui-image"

- name: lint
template: ci-builder
arguments:
parameters:
- name: revision
value: "{{workflow.parameters.revision}}"
- name: repo
value: "{{workflow.parameters.repo}}"
- name: cmd
value: "dep ensure && make lint"

- name: test
template: ci-builder
arguments:
parameters:
- name: revision
value: "{{workflow.parameters.revision}}"
- name: repo
value: "{{workflow.parameters.repo}}"
- name: cmd
value: "dep ensure && make test"
value: "{{item}}"
withItems:
- make controller-image
- make executor-image
- make cli-linux
- make cli-darwin
- make ui-image
- dep ensure && make lint
- dep ensure && make test
- dep ensure && ./hack/verify-codegen.sh

- name: ci-builder
inputs:
parameters:
- name: revision
- name: repo
- name: cmd
artifacts:
- name: code
Expand All @@ -110,7 +47,6 @@ spec:
env:
- name: DOCKER_HOST
value: 127.0.0.1

sidecars:
- name: dind
image: docker:17.10-dind
Expand Down
5 changes: 5 additions & 0 deletions .argo/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ steps:
parameters.CMD: dep ensure && make test
parameters.MEM: "1024"
artifacts.CODE: "%%steps.CHECKOUT.outputs.artifacts.CODE%%"
VERIFY-CODEGEN:
template: ci-builder
arguments:
parameters.CMD: dep ensure && ./hack/verify-codegen.sh
artifacts.CODE: "%%steps.CHECKOUT.outputs.artifacts.CODE%%"

---
type: container
Expand Down
108 changes: 57 additions & 51 deletions Gopkg.lock

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions Gopkg.toml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
[[constraint]]
branch = "release-1.8"
name = "k8s.io/api"
branch = "release-1.9"

[[constraint]]
branch = "release-1.8"
name = "k8s.io/apiextensions-apiserver"
branch = "release-1.9"

[[constraint]]
branch = "release-1.8"
name = "k8s.io/apimachinery"
branch = "release-1.9"

[[constraint]]
name = "k8s.io/code-generator"
branch = "release-1.9"

[[constraint]]
name = "k8s.io/client-go"
branch = "release-5.0"
branch = "release-6.0"

[[constraint]]
name = "github.com/stretchr/testify"
Expand All @@ -27,9 +31,13 @@
version = "3.0.2"

[[constraint]]
branch = "master"
name = "github.com/hashicorp/go-version"
branch = "master"

[[constraint]]
branch = "master"
name = "github.com/jpillora/backoff"
branch = "master"

[[constraint]]
name = "github.com/spf13/cobra"
branch = "master"
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ executor-image: executor-linux
@if [ "$(DOCKER_PUSH)" = "true" ] ; then docker push $(IMAGE_PREFIX)argoexec:$(IMAGE_TAG) ; fi

lint:
gometalinter --deadline 2m --config gometalinter.json --vendor ./...
gometalinter --config gometalinter.json ./...

test:
go test ./...
Expand Down
80 changes: 0 additions & 80 deletions api/workflow/v1alpha1/workflow.go

This file was deleted.

16 changes: 7 additions & 9 deletions cmd/argo/commands/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import (
"strconv"
"strings"

wfv1 "github.com/argoproj/argo/api/workflow/v1alpha1"
"github.com/argoproj/argo/errors"
wfclient "github.com/argoproj/argo/workflow/client"
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
wfclientset "github.com/argoproj/argo/pkg/client/clientset/versioned"
"github.com/argoproj/argo/pkg/client/clientset/versioned/typed/workflow/v1alpha1"
"github.com/ghodss/yaml"
"github.com/spf13/cobra"
"k8s.io/client-go/kubernetes"
Expand All @@ -23,7 +24,7 @@ var (
restConfig *rest.Config
clientConfig clientcmd.ClientConfig
clientset *kubernetes.Clientset
wfClient *wfclient.WorkflowClient
wfClient v1alpha1.WorkflowInterface
jobStatusIconMap map[wfv1.NodePhase]string
)

Expand Down Expand Up @@ -77,7 +78,7 @@ func initKubeClient() *kubernetes.Clientset {
}

// InitWorkflowClient creates a new client for the Kubernetes Workflow CRD.
func InitWorkflowClient(ns ...string) *wfclient.WorkflowClient {
func InitWorkflowClient(ns ...string) v1alpha1.WorkflowInterface {
if wfClient != nil {
return wfClient
}
Expand All @@ -92,11 +93,8 @@ func InitWorkflowClient(ns ...string) *wfclient.WorkflowClient {
log.Fatal(err)
}
}
restClient, scheme, err := wfclient.NewRESTClient(restConfig)
if err != nil {
log.Fatal(err)
}
wfClient = wfclient.NewWorkflowClient(restClient, scheme, namespace)
wfcs := wfclientset.NewForConfigOrDie(restConfig)
wfClient = wfcs.ArgoprojV1alpha1().Workflows(namespace)
return wfClient
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/argo/commands/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ func deleteWorkflowCmd(cmd *cobra.Command, args []string) {
}

func deleteWorkflow(wfName string) {
err := wfClient.DeleteWorkflow(wfName, &metav1.DeleteOptions{})
err := wfClient.Delete(wfName, &metav1.DeleteOptions{})
if err != nil {
log.Fatal(err)
}
fmt.Printf("Workflow '%s' deleted\n", wfName)
}

func deleteWorkflows(options metav1.ListOptions) {
wfList, err := wfClient.ListWorkflows(options)
wfList, err := wfClient.List(options)
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/argo/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"text/tabwriter"
"time"

wfv1 "github.com/argoproj/argo/api/workflow/v1alpha1"
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
humanize "github.com/dustin/go-humanize"
"github.com/ghodss/yaml"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -43,7 +43,7 @@ func GetWorkflow(cmd *cobra.Command, args []string) {
}

wfClient := InitWorkflowClient()
wf, err := wfClient.GetWorkflow(args[0])
wf, err := wfClient.Get(args[0], metav1.GetOptions{})
if err != nil {
log.Fatal(err)
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/argo/commands/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import (
"strconv"

"github.com/argoproj/argo"
wfv1 "github.com/argoproj/argo/api/workflow/v1alpha1"
"github.com/argoproj/argo/errors"
workflowclient "github.com/argoproj/argo/workflow/client"
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo/workflow/common"
"github.com/argoproj/argo/workflow/controller"
"github.com/ghodss/yaml"
Expand Down Expand Up @@ -452,7 +451,7 @@ func installCRD(clientset *kubernetes.Clientset) {
}

// initialize custom resource using a CustomResourceDefinition if it does not exist
result, err := workflowclient.CreateCustomResourceDefinition(apiextensionsclientset)
result, err := common.CreateCustomResourceDefinition(apiextensionsclientset)
if err != nil {
if !apierr.IsAlreadyExists(err) {
log.Fatalf("Failed to create CustomResourceDefinition: %v", err)
Expand Down
8 changes: 4 additions & 4 deletions cmd/argo/commands/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"text/tabwriter"
"time"

wfv1 "github.com/argoproj/argo/api/workflow/v1alpha1"
wfclient "github.com/argoproj/argo/workflow/client"
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
"github.com/argoproj/argo/pkg/client/clientset/versioned/typed/workflow/v1alpha1"
humanize "github.com/dustin/go-humanize"
"github.com/spf13/cobra"
apiv1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -44,13 +44,13 @@ var timeMagnitudes = []humanize.RelTimeMagnitude{
}

func listWorkflows(cmd *cobra.Command, args []string) {
var wfClient *wfclient.WorkflowClient
var wfClient v1alpha1.WorkflowInterface
if listArgs.allNamespaces {
wfClient = InitWorkflowClient(apiv1.NamespaceAll)
} else {
wfClient = InitWorkflowClient()
}
wfList, err := wfClient.ListWorkflows(metav1.ListOptions{})
wfList, err := wfClient.List(metav1.ListOptions{})
if err != nil {
log.Fatal(err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/argo/commands/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"os"
"strings"

wfv1 "github.com/argoproj/argo/api/workflow/v1alpha1"
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"
cmdutil "github.com/argoproj/argo/util/cmd"
"github.com/argoproj/argo/workflow/common"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -122,7 +122,7 @@ func submitWorkflow(wf *wfv1.Workflow) (string, error) {
if err != nil {
return "", err
}
created, err := wfClient.CreateWorkflow(wf)
created, err := wfClient.Create(wf)
if err != nil {
return "", err
}
Expand Down
Loading

0 comments on commit a0add24

Please sign in to comment.