78 lines
2.1 KiB
YAML
78 lines
2.1 KiB
YAML
apiVersion: tekton.dev/v1
|
|
kind: Task
|
|
metadata:
|
|
name: openapi-generate
|
|
spec:
|
|
params:
|
|
- name: context
|
|
type: string
|
|
description: context directory
|
|
default: ""
|
|
|
|
- name: packageNamePrefix
|
|
description: Rust crate name prefix
|
|
type: string
|
|
default: ""
|
|
- name: specDomain
|
|
type: string
|
|
default: ""
|
|
- name: version
|
|
description: Rust crate version
|
|
type: string
|
|
default: "0.0.0"
|
|
- name: generator
|
|
description: specify the generator
|
|
type: string
|
|
default: ""
|
|
|
|
# 배열 타입으로 변경
|
|
- name: generatorOptions
|
|
type: array
|
|
description: |
|
|
openapi-generator-cli options
|
|
ex) ['--additional-properties=key=value', '--enable-post-process-file']
|
|
default: []
|
|
|
|
workspaces:
|
|
- name: base
|
|
description: Git-cloned source code
|
|
|
|
results:
|
|
- name: output
|
|
|
|
steps:
|
|
# split-arguments 단계 제거
|
|
|
|
- name: generate-code
|
|
image: openapitools/openapi-generator-cli:v7.4.0
|
|
workingDir: /workspace/base/$(params.context)/source
|
|
env:
|
|
- name: HOME
|
|
value: /workspace/base/$(params.context)/home
|
|
script: |
|
|
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
OPENAPI_FILE="specs/$(params.specDomain)/openapi.yaml"
|
|
PACKAGE_NAME="$(params.packageNamePrefix)$(params.context)"
|
|
OUTPUT="/workspace/base/$(params.context)/output/${PACKAGE_NAME}-$(date +%s)-$(head /dev/urandom | tr -dc a-z0-9 | head -c 6)"
|
|
|
|
if [ ! -d "$OUTPUT" ]; then
|
|
mkdir -p "$OUTPUT"
|
|
fi
|
|
|
|
# 배열 파라미터 직접 참조
|
|
GENERATOR_OPTIONS=("${params.generatorOptions[@]}")
|
|
|
|
openapi-generator-cli generate \
|
|
-i ${OPENAPI_FILE} \
|
|
-g $(params.generator) \
|
|
-o $OUTPUT \
|
|
--additional-properties=packageName="${PACKAGE_NAME}" \
|
|
--additional-properties=packageVersion=$(params.version) \
|
|
--additional-properties=publish=true \
|
|
--additional-properties=disableValidator=false \
|
|
"${GENERATOR_OPTIONS[@]}" # 배열 확장
|
|
|
|
echo -n "${OUTPUT}" > $(results.output.path)
|