diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index cd0978e..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,61 +0,0 @@ -# Reference from: -# https://goreleaser.com/ci/actions/ -name: Release -on: - push: - tags: - - "v*" -permissions: - contents: write -jobs: - Test: - name: Unit tests with coverage - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: 'go.mod' - - run: go version - - run: go env - - run: go test ./... - - run: go build - - name: Running go tests with coverage - env: - GO111MODULE: on - run: make cover - - name: Send coverage - uses: shogo82148/actions-goveralls@v1 - with: - path-to-profile: coverage.out - Publish: # Pack and publish image to Docker Hub and Github Release - runs-on: ubuntu-latest - needs: [Test] - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: 1.18 - # <--- Login, build and push image to Docker Hub ---> - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - # <--- End ---> - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v6 - with: - distribution: goreleaser - version: latest - args: release --clean - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index dc3b5a0..0000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,77 +0,0 @@ -# This is an example .goreleaser.yml file with some sane defaults. -# Make sure to check the documentation at http://goreleaser.com -before: - hooks: - # You may remove this if you don't use go modules. - - go mod tidy -builds: - - id: default - env: - - CGO_ENABLED=0 - goos: - - linux - - windows - - darwin - goarch: - - amd64 - - arm64 - # 使用 ldflags="-s -w" 去掉符号表和调试信息,以减少发布包的大小 - ldflags: - - -s - - -w - ignore: - - goos: linux - goarch: arm64 - - goos: windows - goarch: arm64 - main: . -archives: - - id: default - builds: - - default - name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}" - format_overrides: - - goos: windows - format: zip -checksum: - name_template: 'checksums.txt' -changelog: - use: github - sort: asc - filters: - exclude: - - '^docs:' - - '^test:' -release: - github: - owner: kcl-lang - name: kcl-openapi - draft: false - footer: | - ## Docker Images - * `kcllang/kcl-openapi:{{ .Tag }}` -dockers: - - use: buildx - goos: linux - goarch: amd64 - dockerfile: Dockerfile - image_templates: - - kcllang/{{ .ProjectName }}:{{ .Tag }}-amd64 - build_flag_templates: - - "--target=goreleaser" - - "--pull" - - "--label=org.opencontainers.image.created={{.Date}}" - - "--label=org.opencontainers.image.name={{.ProjectName}}" - - "--label=org.opencontainers.image.revision={{.FullCommit}}" - - "--label=org.opencontainers.image.version={{.Version}}" - - "--label=org.opencontainers.image.source={{.GitURL}}" - - "--platform=linux/amd64" -docker_manifests: - - use: docker - name_template: kcllang/{{ .ProjectName }}:{{ .Tag }} - image_templates: - - kcllang/{{ .ProjectName }}:{{ .Tag }}-amd64 - - use: docker - name_template: kcllang/{{ .ProjectName }}:latest - image_templates: - - kcllang/{{ .ProjectName }}:{{ .Tag }}-amd64 diff --git a/README.md b/README.md index 7a6039e..78655ed 100644 --- a/README.md +++ b/README.md @@ -17,79 +17,28 @@ Main use cases: + Kubernetes CRD + Translate Kubernetes CRD to KCL code -## Quick Start - -### Install - -The kcl-openapi tool can be installed in both ways: - -- [go install](#1-go-install) -- [curl|sh install (MacOS & Linux)](#2-curlsh-install-macos--linux) -- [download from release](#3-download-from-release) - -## 1 go install - - ```shell - go install kcl-lang.io/kcl-openapi@latest - ``` - -## 2 Curl|sh install (MacOS & Linux) - -If you don't have to go, you can install the CLI with this one-liner: - - ```shell - curl -fsSL https://kcl-lang.io/script/install-kcl-openapi.sh | /bin/bash - ``` - -## 3 Download from release - - ```shell - # 1. download the released binary from: - # https://github.com/kcl-lang/kcl-openapi/releases - - # 2. Unzip the package and add the binary location to PATH - export PATH=":$PATH" - ``` - ## Features -The tool translates Swagger OpenAPI spec and Kubernetes CRD to KCL models. +The package translates Swagger OpenAPI spec and Kubernetes CRD to KCL models. ### Translate Swagger OpenAPI Spec to KCL -The tool now supports [OpenAPI 2.0](https://swagger.io/specification/v2/). By parsing the "Definitions" section of the spec, the KCL OpenAPI -tool will extract the defined models from it and generate the corresponding KCL representation. - -The command is as follows: - - ```shell - kcl-openapi generate model -f ${your_open_api_spec} -t ${the_kcl_files_output_dir} - ``` +The package now supports [OpenAPI 2.0](https://swagger.io/specification/v2/). By parsing the "Definitions" section of the spec, the KCL OpenAPI +package will extract the defined models from it and generate the corresponding KCL representation. -> **Note**: The [Kubernetes KCL models](https://github.com/orgs/KusionStack/packages/container/package/k8s) among all versions are pre-generated, you get it by executing `kpm add k8s:` under your project. For detailed information about kpm usage, please refer to [kpm quick start guide](https://github.com/kcl-lang/kpm#quick-start). -Alternatively, if you may want to generate them yourself, please refer [Generate KCL Packages from Kubernetes OpenAPI Specs](./docs/generate_from_k8s_spec.md). +> **Note**: The [Kubernetes KCL models](https://github.com/orgs/KusionStack/packages/container/package/k8s) among all versions are pre-generated, you get it by executing `kcl mod add k8s:` under your project. Alternatively, if you may want to generate them yourself, please refer [Generate KCL Packages from Kubernetes OpenAPI Specs](./docs/generate_from_k8s_spec.md). ### Translate Kubernetes CRD to KCL -The tool can also translate +The package can also translate the [Kubernetes CRD](https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/) to KCL models. By parsing the `spec.versions[n].schema.openAPIV3Schema` (n means the latest version of the spec will be used) section of the CRD, the KCL -OpenAPI tool will extract the structural schema and generate the corresponding KCL representation. - -The command is as follows: - - ```shell - kcl-openapi generate model --crd -f ${your_CRD.yaml} -t ${the_kcl_files_output_dir} --skip-validation - ``` +OpenAPI package will extract the structural schema and generate the corresponding KCL representation. ## KCL OpenAPI Spec The [KCL OpenAPI Spec](https://www.kcl-lang.io/docs/tools/cli/openapi/openapi-to-kcl) defines a complete specification of how OpenAPI objects are mapped to KCL language elements. -## Ask for help - -If the tool isn't working as you expect, please reach out to us by filing an [issue](https://github.com/kcl-lang/kcl-openapi/issues). - ## License Apache License Version 2.0