Skip to content

Commit

Permalink
build(swagger): Fix Swagger build problems (argoproj#3084)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed May 26, 2020
1 parent e4e0dfb commit 4fd27c3
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 39 deletions.
40 changes: 26 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ CONTROLLER_IMAGE_FILE := dist/controller-image.$(VERSION)
# perform static compilation
STATIC_BUILD ?= true
CI ?= false
DB ?= postgres
DB ?= no-db
ifeq ($(CI),false)
AUTH_MODE := hybrid
else
AUTH_MODE := client
endif
K3D := $(shell if [ "`which kubectl`" != '' ] && [ "`kubectl config current-context`" = "k3s-default" ]; then echo true; else echo false; fi)
LOG_LEVEL := debug

Expand Down Expand Up @@ -357,19 +362,17 @@ stop:
$(GOPATH)/bin/goreman:
go get github.com/mattn/goreman

.PHONY: start-aux
start-aux: $(GOPATH)/bin/goreman
.PHONY: start
start: status stop install controller cli executor-image $(GOPATH)/bin/goreman
kubectl config set-context --current --namespace=argo
kubectl -n argo wait --for=condition=Ready pod --all -l app --timeout 2m
./hack/port-forward.sh
# Check minio, postgres and mysql are in hosts file
grep '127.0.0.1 *minio' /etc/hosts
grep '127.0.0.1 *postgres' /etc/hosts
grep '127.0.0.1 *mysql' /etc/hosts
env ALWAYS_OFFLOAD_NODE_STATUS=$(ALWAYS_OFFLOAD_NODE_STATUS) LOG_LEVEL=$(LOG_LEVEL) VERSION=$(VERSION) goreman -set-ports=false -logtime=false start
env ALWAYS_OFFLOAD_NODE_STATUS=$(ALWAYS_OFFLOAD_NODE_STATUS) LOG_LEVEL=$(LOG_LEVEL) VERSION=$(VERSION) AUTH_MODE=$(AUTH_MODE) goreman -set-ports=false -logtime=false start

.PHONY: start
start: status stop install controller cli executor-image start-aux wait env

.PHONY: wait
wait:
Expand Down Expand Up @@ -451,7 +454,7 @@ $(GOPATH)/bin/swagger:
.PHONY: swagger
swagger: api/openapi-spec/swagger.json

pkg/apis/workflow/v1alpha1/openapi_generated.go:
pkg/apis/workflow/v1alpha1/openapi_generated.go: $(shell find pkg/apis/workflow/v1alpha1 -type f -not -name openapi_generated.go)
$(call backup_go_mod)
go install k8s.io/kube-openapi/cmd/openapi-gen
openapi-gen \
Expand All @@ -461,20 +464,29 @@ pkg/apis/workflow/v1alpha1/openapi_generated.go:
--report-filename pkg/apis/api-rules/violation_exceptions.list
$(call restore_go_mod)

dist/kubernetes.swagger.json:
./hack/recurl.sh dist/kubernetes.swagger.json https://raw.githubusercontent.com/kubernetes/kubernetes/release-1.15/api/openapi-spec/swagger.json

pkg/apiclient/_.secondary.swagger.json: hack/secondaryswaggergen.go pkg/apis/workflow/v1alpha1/openapi_generated.go dist/kubernetes.swagger.json
go run ./hack secondaryswaggergen

dist/swagger.json: $(GOPATH)/bin/swagger $(SWAGGER_FILES) $(MANIFESTS_VERSION_FILE) hack/swaggify.sh
swagger mixin -c 684 $(SWAGGER_FILES) | sed 's/VERSION/$(MANIFESTS_VERSION)/' | ./hack/swaggify.sh > dist/swagger.json
# we always ignore the conflicts, so lets automated figuring out how many there will be and just use that
dist/swagger-conflicts: $(GOPATH)/bin/swagger $(SWAGGER_FILES)
swagger mixin $(SWAGGER_FILES) 2>&1 | grep -c skipping > dist/swagger-conflicts || true

dist/kubernetes.swagger.json:
./hack/recurl.sh dist/kubernetes.swagger.json https://raw.githubusercontent.com/kubernetes/kubernetes/release-1.15/api/openapi-spec/swagger.json
dist/mixed.swagger.json: $(GOPATH)/bin/swagger $(SWAGGER_FILES) dist/swagger-conflicts
swagger mixin -c $(shell cat dist/swagger-conflicts) $(SWAGGER_FILES) > dist/mixed.swagger.json.tmp
mv dist/mixed.swagger.json.tmp dist/mixed.swagger.json

dist/swaggifed.swagger.json: dist/mixed.swagger.json $(MANIFESTS_VERSION_FILE) hack/swaggify.sh
cat dist/mixed.swagger.json | sed 's/VERSION/$(MANIFESTS_VERSION)/' | ./hack/swaggify.sh > dist/swaggifed.swagger.json

dist/kubeified.swagger.json: dist/swagger.json dist/kubernetes.swagger.json hack/kubeifyswagger.go
go run ./hack kubeifyswagger dist/swagger.json dist/kubeified.swagger.json
dist/kubeified.swagger.json: dist/swaggifed.swagger.json dist/kubernetes.swagger.json hack/kubeifyswagger.go
go run ./hack kubeifyswagger dist/swaggifed.swagger.json dist/kubeified.swagger.json

api/openapi-spec/swagger.json: dist/kubeified.swagger.json
swagger flatten --with-flatten minimal --with-flatten remove-unused dist/kubeified.swagger.json > api/openapi-spec/swagger.json
swagger flatten --with-flatten minimal --with-flatten remove-unused dist/kubeified.swagger.json > dist/swagger.json
mv dist/swagger.json api/openapi-spec/swagger.json
swagger validate api/openapi-spec/swagger.json
go test ./api/openapi-spec

Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
controller: ALWAYS_OFFLOAD_NODE_STATUS=${ALWAYS_OFFLOAD_NODE_STATUS} OFFLOAD_NODE_STATUS_TTL=30s WORKFLOW_GC_PERIOD=30s UPPERIO_DB_DEBUG=1 ARCHIVED_WORKFLOW_GC_PERIOD=30s ./dist/workflow-controller --executor-image argoproj/argoexec:${VERSION} --namespaced --loglevel ${LOG_LEVEL}
argo-server: UPPERIO_DB_DEBUG=1 ./dist/argo --loglevel ${LOG_LEVEL} server --namespaced --auth-mode client --secure
argo-server: UPPERIO_DB_DEBUG=1 ./dist/argo --loglevel ${LOG_LEVEL} server --namespaced --auth-mode ${AUTH_MODE} --secure
36 changes: 31 additions & 5 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,10 @@
"type": "string"
}
},
"depends": {
"description": "Depends are name of other targets which this depends on",
"type": "string"
},
"name": {
"description": "Name is the name of the target",
"type": "string"
Expand Down Expand Up @@ -3148,10 +3152,6 @@
"description": "GenerateName overrides metadata.generateName",
"type": "string"
},
"instanceID": {
"description": "InstanceID binds the Resource to the specified instance ID",
"type": "string"
},
"labels": {
"description": "Labels adds to metadata.labels",
"type": "string"
Expand Down Expand Up @@ -3415,7 +3415,7 @@
"type": "object",
"properties": {
"clusterScope": {
"description": "ClusterScope indicates the referred template is cluster scoped (i.e., a ClusterWorkflowTemplate).",
"description": "ClusterScope indicates the referred template is cluster scoped (i.e. a ClusterWorkflowTemplate).",
"type": "boolean"
},
"name": {
Expand Down Expand Up @@ -3977,6 +3977,10 @@
},
"x-kubernetes-patch-merge-key": "name",
"x-kubernetes-patch-strategy": "merge"
},
"workflowTemplateRef": {
"description": "WorkflowTemplateRef holds a reference to a WorkflowTemplate for execution",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.WorkflowTemplateRef"
}
}
},
Expand Down Expand Up @@ -4047,6 +4051,10 @@
"additionalProperties": {
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.Template"
}
},
"storedWorkflowTemplateSpec": {
"description": "StoredWorkflowSpec stores the WorkflowTemplate spec for future execution.",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.WorkflowSpec"
}
}
},
Expand Down Expand Up @@ -4225,6 +4233,20 @@
}
}
},
"io.argoproj.workflow.v1alpha1.WorkflowTemplateRef": {
"description": "WorkflowTemplateRef is a reference to a WorkflowTemplate resource.",
"type": "object",
"properties": {
"clusterScope": {
"description": "ClusterScope indicates the referred template is cluster scoped (i.e. a ClusterWorkflowTemplate).",
"type": "boolean"
},
"name": {
"description": "Name is the resource name of the workflow template.",
"type": "string"
}
}
},
"io.argoproj.workflow.v1alpha1.WorkflowTemplateSpec": {
"description": "WorkflowTemplateSpec is a spec of WorkflowTemplate.",
"type": "object",
Expand Down Expand Up @@ -4400,6 +4422,10 @@
},
"x-kubernetes-patch-merge-key": "name",
"x-kubernetes-patch-strategy": "merge"
},
"workflowTemplateRef": {
"description": "WorkflowTemplateRef holds a reference to a WorkflowTemplate for execution",
"$ref": "#/definitions/io.argoproj.workflow.v1alpha1.WorkflowTemplateRef"
}
}
},
Expand Down
3 changes: 1 addition & 2 deletions cmd/argo/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import (
"k8s.io/apimachinery/pkg/fields"
"sigs.k8s.io/yaml"

"github.com/argoproj/argo/cmd/argo/commands/client"
workflowpkg "github.com/argoproj/argo/pkg/apiclient/workflow"
wfv1 "github.com/argoproj/argo/pkg/apis/workflow/v1alpha1"

"github.com/argoproj/argo/cmd/argo/commands/client"
"github.com/argoproj/argo/util/printer"
"github.com/argoproj/argo/workflow/util"
)
Expand Down
25 changes: 24 additions & 1 deletion docs/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ WorkflowSpec is the specification of a Workflow.
|`ttlStrategy`|[`TTLStrategy`](#ttlstrategy)|TTLStrategy limits the lifetime of a Workflow that has finished execution depending on if it Succeeded or Failed. If this struct is set, once the Workflow finishes, it will be deleted after the time to live expires. If this field is unset, the controller config map will hold the default values.|
|`volumeClaimTemplates`|`Array<`[`PersistentVolumeClaim`](#persistentvolumeclaim)`>`|VolumeClaimTemplates is a list of claims that containers are allowed to reference. The Workflow controller will create the claims at the beginning of the workflow and delete the claims upon completion of the workflow|
|`volumes`|`Array<`[`Volume`](#volume)`>`|Volumes is a list of volumes that can be mounted by containers in a io.argoproj.workflow.v1alpha1.|
|`workflowTemplateRef`|[`WorkflowTemplateRef`](#workflowtemplateref)|WorkflowTemplateRef holds a reference to a WorkflowTemplate for execution|

## WorkflowStatus

Expand All @@ -590,6 +591,7 @@ WorkflowStatus contains overall status information about a workflow
|`resourcesDuration`|`Map< integer , int64 >`|ResourcesDuration is the total for the workflow|
|`startedAt`|[`Time`](#time)|Time at which this workflow started|
|`storedTemplates`|[`Template`](#template)|StoredTemplates is a mapping between a template ref and the node's status.|
|`storedWorkflowTemplateSpec`|[`WorkflowSpec`](#workflowspec)|StoredWorkflowSpec stores the WorkflowTemplate spec for future execution.|

## CronWorkflowSpec

Expand Down Expand Up @@ -1144,6 +1146,7 @@ WorkflowTemplateSpec is a spec of WorkflowTemplate.
|`ttlStrategy`|[`TTLStrategy`](#ttlstrategy)|TTLStrategy limits the lifetime of a Workflow that has finished execution depending on if it Succeeded or Failed. If this struct is set, once the Workflow finishes, it will be deleted after the time to live expires. If this field is unset, the controller config map will hold the default values.|
|`volumeClaimTemplates`|`Array<`[`PersistentVolumeClaim`](#persistentvolumeclaim)`>`|VolumeClaimTemplates is a list of claims that containers are allowed to reference. The Workflow controller will create the claims at the beginning of the workflow and delete the claims upon completion of the workflow|
|`volumes`|`Array<`[`Volume`](#volume)`>`|Volumes is a list of volumes that can be mounted by containers in a io.argoproj.workflow.v1alpha1.|
|`workflowTemplateRef`|[`WorkflowTemplateRef`](#workflowtemplateref)|WorkflowTemplateRef holds a reference to a WorkflowTemplate for execution|

## Arguments

Expand Down Expand Up @@ -1627,6 +1630,25 @@ TTLStrategy is the strategy for the time to live depending on if the workflow su
|`secondsAfterFailure`|`int32`|SecondsAfterFailure is the number of seconds to live after failure|
|`secondsAfterSuccess`|`int32`|SecondsAfterSuccess is the number of seconds to live after success|

## WorkflowTemplateRef

WorkflowTemplateRef is a reference to a WorkflowTemplate resource.

<details>
<summary>Examples with this field (click to open)</summary>
<br>

- [`workflow-template-ref-with-entrypoint-arg-passing.yaml`](../examples/workflow-template/workflow-template-ref-with-entrypoint-arg-passing.yaml)

- [`workflow-template-ref.yaml`](../examples/workflow-template/workflow-template-ref.yaml)
</details>

### Fields
| Field Name | Field Type | Description |
|:----------:|:----------:|---------------|
|`clusterScope`|`boolean`|ClusterScope indicates the referred template is cluster scoped (i.e. a ClusterWorkflowTemplate).|
|`name`|`string`|Name is the resource name of the workflow template.|

## WorkflowCondition

_No description available_
Expand Down Expand Up @@ -2775,7 +2797,7 @@ TemplateRef is a reference of template resource.
### Fields
| Field Name | Field Type | Description |
|:----------:|:----------:|---------------|
|`clusterScope`|`boolean`|ClusterScope indicates the referred template is cluster scoped (i.e., a ClusterWorkflowTemplate).|
|`clusterScope`|`boolean`|ClusterScope indicates the referred template is cluster scoped (i.e. a ClusterWorkflowTemplate).|
|`name`|`string`|Name is the resource name of the template.|
|`runtimeResolution`|`boolean`|RuntimeResolution skips validation at creation time. By enabling this option, you can create the referred workflow template before the actual runtime.|
|`template`|`string`|Template is the name of referred template in the resource.|
Expand Down Expand Up @@ -3150,6 +3172,7 @@ DAGTask represents a node in the graph during DAG execution
|`arguments`|[`Arguments`](#arguments)|Arguments are the parameter and artifact arguments to the template|
|`continueOn`|[`ContinueOn`](#continueon)|ContinueOn makes argo to proceed with the following step even if this step fails. Errors and Failed states can be specified|
|`dependencies`|`Array< string >`|Dependencies are name of other targets which this depends on|
|`depends`|`string`|Depends are name of other targets which this depends on|
|`name`|`string`|Name is the name of the target|
|`onExit`|`string`|OnExit is a template reference which is invoked at the end of the template, irrespective of the success, failure, or error of the primary template.|
|`template`|`string`|Name of template to execute|
Expand Down
36 changes: 31 additions & 5 deletions pkg/apiclient/_.secondary.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,10 @@
"type": "string"
}
},
"depends": {
"description": "Depends are name of other targets which this depends on",
"type": "string"
},
"name": {
"description": "Name is the name of the target",
"type": "string"
Expand Down Expand Up @@ -1561,10 +1565,6 @@
"description": "GenerateName overrides metadata.generateName",
"type": "string"
},
"instanceID": {
"description": "InstanceID binds the Resource to the specified instance ID",
"type": "string"
},
"labels": {
"description": "Labels adds to metadata.labels",
"type": "string"
Expand Down Expand Up @@ -1828,7 +1828,7 @@
"type": "object",
"properties": {
"clusterScope": {
"description": "ClusterScope indicates the referred template is cluster scoped (i.e., a ClusterWorkflowTemplate).",
"description": "ClusterScope indicates the referred template is cluster scoped (i.e. a ClusterWorkflowTemplate).",
"type": "boolean"
},
"name": {
Expand Down Expand Up @@ -2292,6 +2292,10 @@
},
"x-kubernetes-patch-merge-key": "name",
"x-kubernetes-patch-strategy": "merge"
},
"workflowTemplateRef": {
"description": "WorkflowTemplateRef holds a reference to a WorkflowTemplate for execution",
"$ref": "#/definitions/github.com.argoproj.argo.pkg.apis.workflow.v1alpha1.WorkflowTemplateRef"
}
}
},
Expand Down Expand Up @@ -2362,6 +2366,10 @@
"additionalProperties": {
"$ref": "#/definitions/github.com.argoproj.argo.pkg.apis.workflow.v1alpha1.Template"
}
},
"storedWorkflowTemplateSpec": {
"description": "StoredWorkflowSpec stores the WorkflowTemplate spec for future execution.",
"$ref": "#/definitions/github.com.argoproj.argo.pkg.apis.workflow.v1alpha1.WorkflowSpec"
}
}
},
Expand Down Expand Up @@ -2464,6 +2472,20 @@
}
}
},
"github.com.argoproj.argo.pkg.apis.workflow.v1alpha1.WorkflowTemplateRef": {
"description": "WorkflowTemplateRef is a reference to a WorkflowTemplate resource.",
"type": "object",
"properties": {
"clusterScope": {
"description": "ClusterScope indicates the referred template is cluster scoped (i.e. a ClusterWorkflowTemplate).",
"type": "boolean"
},
"name": {
"description": "Name is the resource name of the workflow template.",
"type": "string"
}
}
},
"github.com.argoproj.argo.pkg.apis.workflow.v1alpha1.WorkflowTemplateSpec": {
"description": "WorkflowTemplateSpec is a spec of WorkflowTemplate.",
"type": "object",
Expand Down Expand Up @@ -2639,6 +2661,10 @@
},
"x-kubernetes-patch-merge-key": "name",
"x-kubernetes-patch-strategy": "merge"
},
"workflowTemplateRef": {
"description": "WorkflowTemplateRef holds a reference to a WorkflowTemplate for execution",
"$ref": "#/definitions/github.com.argoproj.argo.pkg.apis.workflow.v1alpha1.WorkflowTemplateRef"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/api-rules/violation_exceptions.list
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@ API rule violation: names_match,github.com/argoproj/argo/pkg/apis/workflow/v1alp
API rule violation: names_match,github.com/argoproj/argo/pkg/apis/workflow/v1alpha1,ItemValue,Type
API rule violation: names_match,github.com/argoproj/argo/pkg/apis/workflow/v1alpha1,ParallelSteps,Steps
API rule violation: names_match,github.com/argoproj/argo/pkg/apis/workflow/v1alpha1,SubmitOpts,Entrypoint
API rule violation: names_match,github.com/argoproj/argo/pkg/apis/workflow/v1alpha1,WorkflowStatus,StoredWorkflowSpec
Loading

0 comments on commit 4fd27c3

Please sign in to comment.