Skip to content

Commit 3f14c68

Browse files
alexecsarabala1979
authored andcommitted
feat: Bring Java client into core. (argoproj#7026)
Signed-off-by: Alex Collins <[email protected]>
1 parent 48e1aa9 commit 3f14c68

File tree

409 files changed

+12115
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

409 files changed

+12115
-2
lines changed

.github/workflows/changelog.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ jobs:
2323
with:
2424
title: 'docs: updated CHANGELOG.md'
2525
commit-message: 'docs: updated CHANGELOG.md'
26+
branch: create-pull-request/changelog
2627
signoff: true

.github/workflows/sdks.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: SDKs
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
- 'v3.2.*'
7+
- 'v3.1.*'
8+
branches:
9+
- dev-*
10+
jobs:
11+
sdk:
12+
if: github.repository == 'argoproj/argo-workflows'
13+
runs-on: ubuntu-latest
14+
name: Publish SDK
15+
strategy:
16+
matrix:
17+
name:
18+
- java
19+
steps:
20+
- uses: actions/checkout@v2
21+
- run: make --directory sdks/${{matrix.name}} publish -B
22+
env:
23+
JAVA_SDK_MAVEN_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
24+
- uses: peter-evans/create-pull-request@v3
25+
with:
26+
title: 'chore: updated ${{matrix.name}} SDK'
27+
commit-message: 'chore: updated ${{matrix.name}} SDK'
28+
branch: create-pull-request/sdk/${{matrix.name}}
29+
signoff: true

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ scan-%:
234234

235235
.PHONY: codegen
236236
codegen: types swagger docs manifests
237+
make --directory sdks/java generate
237238

238239
.PHONY: types
239240
types: pkg/apis/workflow/v1alpha1/generated.proto pkg/apis/workflow/v1alpha1/openapi_generated.go pkg/apis/workflow/v1alpha1/zz_generated.deepcopy.go

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ Argo is a [Cloud Native Computing Foundation (CNCF)](https://cncf.io/) hosted pr
6161
|
6262
[Kubeflow Pipelines](https://github.com/kubeflow/pipelines)
6363

64-
## SDKs
64+
## Client Libraries
6565

66-
Check out our [Java, Golang and Python SDKs](https://github.com/argoproj-labs/argo-client-gen).
66+
Check out our [Java, Golang and Python clients](docs/client-libraries.md).
6767

6868
## Quickstart
6969

docs/client-libraries.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Client Libraries
2+
3+
This page contains an overview of the client libraries for using the Argo API from various programming languages.
4+
5+
To write applications using the REST API, you do not need to implement the API calls and request/response types
6+
yourself. You can use a client library for the programming language you are using.
7+
8+
Client libraries often handle common tasks such as authentication for you.
9+
10+
## Officially-supported client libraries
11+
12+
The following client libraries are officially maintained by the Argo team.
13+
14+
| Language | Client Library | Examples/Docs |
15+
|----------|----------------|---------------|
16+
| Golang | [apiclient.go](https://github.com/argoproj/argo-workflows/blob/master/pkg/apiclient/apiclient.go) | [Example](https://github.com/argoproj/argo-workflows/blob/master/cmd/argo/commands/submit.go)
17+
| Java | [java](https://github.com/argoproj/argo-workflows/blob/master/sdks/java) | |
18+
| Python | [python](python) | TBC |
19+
20+
## Community-maintained client libraries
21+
22+
The following client libraries are provided and maintained by their authors, not the Argo team.
23+
24+
| Language | Client Library | Info |
25+
|----------|----------------|---------------|
26+
| Python | [Couler](https://github.com/couler-proj/couler) | Multi-workflow engine support Python SDK |
27+
| Python | Hera | TBC |

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ nav:
7070
- swagger.md
7171
- rest-api.md
7272
- rest-examples.md
73+
- client-libraries.md
7374
- events.md
7475
- webhooks.md
7576
- submit-workflow-via-automation.md

sdks/CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Contributing an SDK
2+
3+
Make it contributor friendly:
4+
5+
* Make it fast, because engineers will have to generate SDKs for every PR.
6+
* Make it dependency free, engineers will not be a be able to install anything. You can use Docker.
7+
* Generate the minimal amount of code possible, so other engineers don't have to commit lots of files too.
8+
* Provide a [`Makefile`](java/Makefile) with the following:
9+
* A `generate` target to generate the code using `openapi-generator` into `client` directory.
10+
* A `publish` target to publish the generated code for use.
11+
* Committed code must be stable, it must not change based on Git tags.
12+
13+
Make it user friendly:
14+
15+
* Commit enough for users to learn how to use it. Use `.gitignore` to exclude files.
16+
* Add a [README.md](java/README.md) to help users get started.

sdks/java/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/client/.openapi-generator/
2+
/client/api/
3+
/client/src/
4+
/client/gradle/
5+
/client/.gitignore
6+
/client/.openapi-generator-ignore
7+
/client/gradlew
8+
/client/*.*

sdks/java/Makefile

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
GIT_TAG := $(shell git describe --exact-match --tags --abbrev=0 2> /dev/null || echo untagged)
2+
ifeq ($(GIT_TAG),untagged)
3+
# "SNAPSHOT" is "latest" for Java
4+
VERSION := 0.0.0-SNAPSHOT
5+
else
6+
# remove the "v" prefix, not allowed
7+
VERSION := $(GIT_TAG:v=)
8+
endif
9+
10+
# work dir
11+
WD := $(shell echo "`pwd`/client")
12+
13+
DOCKER = docker run --rm -v $(WD):/wd --workdir /wd
14+
MVN = $(DOCKER) -v $(HOME)/.m2:/root/.m2 -e JAVA_SDK_MAVEN_PASSWORD=${JAVA_SDK_MAVEN_PASSWORD} maven:3-openjdk-8 mvn -s settings.xml
15+
CHOWN = chown -R $(shell id -u):$(shell id -g)
16+
17+
publish: generate
18+
# https://help.github.com/en/packages/using-github-packages-with-your-projects-ecosystem/configuring-apache-maven-for-use-with-github-packages
19+
$(MVN) deploy -DskipTests -DaltDeploymentRepository=github::default::https://maven.pkg.github.com/argoproj/argo-workflows
20+
21+
generate:
22+
rm -Rf $(WD)
23+
mkdir -p $(WD)
24+
cp settings.xml $(WD)/settings.xml
25+
cat ../../api/openapi-spec/swagger.json | \
26+
sed 's/io.k8s.api.core.v1.//' | \
27+
sed 's/io.k8s.apimachinery.pkg.apis.meta.v1.//' \
28+
> $(WD)/swagger.json
29+
$(DOCKER) openapitools/openapi-generator-cli:v5.2.1 \
30+
generate \
31+
-i /wd/swagger.json \
32+
-g java \
33+
-o /wd \
34+
-p hideGenerationTimestamp=true \
35+
-p dateLibrary=java8 \
36+
--api-package io.argoproj.workflow.apis \
37+
--invoker-package io.argoproj.workflow \
38+
--model-package io.argoproj.workflow.models \
39+
--skip-validate-spec \
40+
--group-id io.argoproj.workflow \
41+
--artifact-id argo-client-java \
42+
--import-mappings Time=java.time.Instant \
43+
--import-mappings Affinity=io.kubernetes.client.openapi.models.V1Affinity \
44+
--import-mappings ConfigMapKeySelector=io.kubernetes.client.openapi.models.V1ConfigMapKeySelector \
45+
--import-mappings Container=io.kubernetes.client.openapi.models.V1Container \
46+
--import-mappings ContainerPort=io.kubernetes.client.openapi.models.V1ContainerPort \
47+
--import-mappings EnvFromSource=io.kubernetes.client.openapi.models.V1EnvFromSource \
48+
--import-mappings EnvVar=io.kubernetes.client.openapi.models.V1EnvVar \
49+
--import-mappings HostAlias=io.kubernetes.client.openapi.models.V1HostAlias \
50+
--import-mappings Lifecycle=io.kubernetes.client.openapi.models.V1Lifecycle \
51+
--import-mappings ListMeta=io.kubernetes.client.openapi.models.V1ListMeta \
52+
--import-mappings LocalObjectReference=io.kubernetes.client.openapi.models.V1LocalObjectReference \
53+
--import-mappings ObjectMeta=io.kubernetes.client.openapi.models.V1ObjectMeta \
54+
--import-mappings ObjectReference=io.kubernetes.client.openapi.models.V1ObjectReference \
55+
--import-mappings PersistentVolumeClaim=io.kubernetes.client.openapi.models.V1PersistentVolumeClaim \
56+
--import-mappings PodDisruptionBudgetSpec=io.kubernetes.client.openapi.models.V1beta1PodDisruptionBudgetSpec \
57+
--import-mappings PodDNSConfig=io.kubernetes.client.openapi.models.V1PodDNSConfig \
58+
--import-mappings PodSecurityContext=io.kubernetes.client.openapi.models.V1PodSecurityContext \
59+
--import-mappings Probe=io.kubernetes.client.openapi.models.V1Probe \
60+
--import-mappings ResourceRequirements=io.kubernetes.client.openapi.models.V1ResourceRequirements \
61+
--import-mappings SecretKeySelector=io.kubernetes.client.openapi.models.V1SecretKeySelector \
62+
--import-mappings SecurityContext=io.kubernetes.client.openapi.models.V1SecurityContext \
63+
--import-mappings Toleration=io.kubernetes.client.openapi.models.V1Toleration \
64+
--import-mappings Volume=io.kubernetes.client.openapi.models.V1Volume \
65+
--import-mappings VolumeDevice=io.kubernetes.client.openapi.models.V1VolumeDevice \
66+
--import-mappings VolumeMount=io.kubernetes.client.openapi.models.V1VolumeMount \
67+
--generate-alias-as-model
68+
# https://vsupalov.com/docker-shared-permissions/#set-the-docker-user-when-running-your-container
69+
$(CHOWN) $(WD) || sudo $(CHOWN) $(WD)
70+
# replace the generated pom.xml, because that has too many dependencies
71+
sed 's/0.0.0-VERSION/$(VERSION)/' pom.xml > $(WD)/pom.xml
72+

sdks/java/README.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Java SDK
2+
3+
## Download
4+
5+
## Client Library
6+
7+
This provides model and APIs for accessing the Argo Server API rather.
8+
9+
If you wish to access the Kubernetes APIs, you can use the models to do this. You'll need to write your own code to speak to the API.
10+
11+
⚠️ The Java SDK is published to Github packages, not Maven Central. You must update your Maven settings.xml
12+
file: [how to do that](https://github.com/argoproj/argo-workflows/packages).
13+
14+
Recommended:
15+
16+
```xml
17+
<dependency>
18+
<groupId>io.argoproj.workflow</groupId>
19+
<artifactId>argo-client-java</artifactId>
20+
<version>3.3.0</version>
21+
</dependency>
22+
```
23+
24+
The very latest version:
25+
26+
```xml
27+
<dependency>
28+
<groupId>io.argoproj.workflow</groupId>
29+
<artifactId>argo-client-java</artifactId>
30+
<version>0.0.0-SNAPSHOT</version>
31+
</dependency>
32+
```
33+
34+
## Examples
35+
36+
* [Example.java](examples/client)
37+
38+
## Docs
39+
40+
* [Event service](client/docs/EventServiceApi.md)
41+
* [Sensor service](client/docs/SensorServiceApi.md)
42+
* [Event source service](client/docs/EventSourceServiceApi.md)
43+
* [Info service](client/docs/InfoServiceApi.md )
44+
* [Pipeline service](client/docs/PipelineServiceApi.md)
45+
* [Workflow service](client/docs/WorkflowServiceApi.md)

0 commit comments

Comments
 (0)