-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Onboard EIA service to equinix-sdk-go (#53)
* Initial addition of Equinix Internet Access SDK to equinix-sdk-go * EIA v2 is a work in progress but we'll be using it to get started on Terraform Provider resources while they add more methods to their spec
- Loading branch information
Showing
209 changed files
with
36,486 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Sync eiav2 API spec | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
sync: | ||
strategy: | ||
matrix: | ||
go-version: [1.19.x] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Get current date | ||
id: date | ||
run: echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT" | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: GitHub user | ||
run: | | ||
# https://api.github.com/users/github-actions[bot] | ||
git config user.name 'github-actions[bot]' | ||
git config user.email '41898282+github-actions[bot]@users.noreply.github.com' | ||
- name: Fetch latest spec | ||
id: fetch | ||
run: | | ||
make -f Makefile.eiav2 fetch | ||
git add spec/services/eiav2 | ||
echo `git commit -m 'sync: fetch ${{ steps.date.outputs.date }} spec and apply patches'` | ||
- name: Apply spec patches | ||
id: patch | ||
if: ${{ always() && steps.fetch.conclusion == 'success' }} | ||
run: | | ||
make -f Makefile.eiav2 patch | ||
git add spec/services/eiav2 | ||
echo `git commit -m 'sync: patch spec with ${{ steps.date.outputs.date }} spec'` | ||
- name: Generate code | ||
id: generate | ||
if: ${{ always() && steps.patch.conclusion == 'success' }} | ||
run: | | ||
make -f Makefile.eiav2 generate | ||
git add services/eiav2 | ||
echo `git commit -m 'sync: generate client with ${{ steps.date.outputs.date }} spec'` | ||
- name: Create Pull Request | ||
id: cpr | ||
uses: peter-evans/create-pull-request@v6 | ||
if: ${{ always() && steps.fetch.conclusion == 'success' }} | ||
with: | ||
branch: sync/gh | ||
branch-suffix: timestamp | ||
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | ||
commit-message: "sync: uncommitted changes detected when opening PR" | ||
title: "feat: API Sync by GitHub Action for @${{ github.event.sender.login }}" | ||
body: | | ||
This API Sync PR was triggered by @${{ github.event.sender.login }} through [GitHub Actions workflow_displatch](https://github.com/equinix/equinix-sdk-go/actions?query=event%3Aworkflow_dispatch) | ||
on ${{ steps.date.outputs.date }}. | ||
* latest Swagger is fetched | ||
* patches have been applied | ||
* generated client has been updated | ||
delete-branch: true | ||
draft: ${{ steps.patch.conclusion == 'failure' || steps.generate.conclusion == 'failure' }} | ||
- name: Comment for failed patch | ||
uses: mshick/add-pr-comment@v2 | ||
if: ${{ always() && steps.patch.conclusion == 'failure' && steps.cpr.conclusion == 'success' }} | ||
with: | ||
issue: ${{ steps.cpr.outputs.pull-request-number }} | ||
message: Failed to patch latest spec. Someone with write access must fix this PR manually and then convert it from Draft status to Ready for Review. | ||
- name: Comment for failed generate | ||
uses: mshick/add-pr-comment@v2 | ||
if: ${{ always() && steps.generate.conclusion == 'failure' && steps.cpr.conclusion == 'success' }} | ||
with: | ||
issue: ${{ steps.cpr.outputs.pull-request-number }} | ||
message: Failed to generate code from latest patched spec. Someone with write access must fix this PR manually and then convert it from Draft status to Ready for Review. | ||
- name: Check outputs | ||
if: ${{ always() && steps.cpr.conclusion == 'success' }} | ||
run: | | ||
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" | ||
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Test eiav2 codegen | ||
|
||
on: | ||
push: | ||
paths: | ||
- "**/eiav2/**" | ||
pull_request: | ||
paths: | ||
- "**/eiav2/**" | ||
|
||
jobs: | ||
test: | ||
strategy: | ||
matrix: | ||
go-version: [1.19.x] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Verify Patches | ||
run: make -f Makefile.eiav2 patch | ||
- name: Generate | ||
run: | | ||
make -f Makefile.eiav2 generate | ||
# Expect all changes to be accounted for | ||
! git status --porcelain | grep . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.PHONY: all pull fetch patch generate clean codegen mod docs move-other patch-post fmt test stage | ||
|
||
include Makefile | ||
|
||
PACKAGE_NAME=eiav2 | ||
SPEC_BASE_URL:=https://api.swaggerhub.com/apis/equinix-api/Equinix_Internet_Access_API_v2/2.0 | ||
SPEC_ROOT_FILE:=swagger.yaml | ||
|
||
CODE_DIR=${CODE_BASE_DIR}/${PACKAGE_NAME} | ||
TEMPLATE_DIR=${TEMPLATE_BASE_DIR}/${PACKAGE_NAME} | ||
SPEC_FETCHED_DIR=${SPEC_BASE_DIR}/${PACKAGE_NAME}/oas3.fetched | ||
SPEC_PATCH_DIR=${SPEC_BASE_DIR}/${PACKAGE_NAME}/patches | ||
SPEC_PATCHED_DIR=${SPEC_BASE_DIR}/${PACKAGE_NAME}/oas3.patched | ||
SPEC_FETCHER=curl | ||
|
||
all: pull fetch patch generate stage | ||
|
||
generate: clean codegen remove-unused patch-post mod fmt test | ||
|
||
pull: | ||
${CRI} pull ${OPENAPI_IMAGE} | ||
|
||
fetch: | ||
${SPEC_FETCHER} -o ${SPEC_FETCHED_DIR}/${SPEC_ROOT_FILE} ${SPEC_BASE_URL}/${SPEC_ROOT_FILE} | ||
|
||
patch: | ||
rm -rf ${SPEC_PATCHED_DIR} | ||
cp -r ${SPEC_FETCHED_DIR} ${SPEC_PATCHED_DIR} | ||
|
||
for diff in $(shell set -x; find ${SPEC_PATCH_DIR} -name '*.patch' | sort -n); do \ | ||
patch --no-backup-if-mismatch -N -t -p1 -i $$diff; \ | ||
done | ||
|
||
patch-post: | ||
# patch is idempotent, always starting with the generated files | ||
for diff in $(shell find patches/services/${PACKAGE_NAME} -name \*.patch | sort -n); do \ | ||
patch --no-backup-if-mismatch -N -t -p1 -i $$diff; \ | ||
done | ||
|
||
clean: | ||
rm -rf $(CODE_DIR) | ||
|
||
codegen: | ||
${OPENAPI_GENERATOR} generate -g go \ | ||
--package-name ${PACKAGE_NAME} \ | ||
--http-user-agent "${USER_AGENT}" \ | ||
-p packageVersion=${PACKAGE_VERSION} \ | ||
--git-user-id ${GIT_ORG} \ | ||
--git-repo-id ${GIT_REPO}/services \ | ||
-c /local/config/openapi-generator.json \ | ||
-t /local/${TEMPLATE_DIR} \ | ||
-o /local/${CODE_DIR} \ | ||
-i /local/${SPEC_PATCHED_DIR}/${SPEC_ROOT_FILE} | ||
|
||
validate: | ||
${OPENAPI_GENERATOR} validate \ | ||
--recommend \ | ||
-i /local/${SPEC_PATCHED_DIR} | ||
|
||
remove-unused: | ||
rm -rf ${CODE_DIR}/api \ | ||
${CODE_DIR}/.travis.yml \ | ||
${CODE_DIR}/git_push.sh \ | ||
${CODE_DIR}/.openapi-generator |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Compiled Object files, Static and Dynamic libs (Shared Objects) | ||
*.o | ||
*.a | ||
*.so | ||
|
||
# Folders | ||
_obj | ||
_test | ||
|
||
# Architecture specific extensions/prefixes | ||
*.[568vq] | ||
[568vq].out | ||
|
||
*.cgo1.go | ||
*.cgo2.c | ||
_cgo_defun.c | ||
_cgo_gotypes.go | ||
_cgo_export.* | ||
|
||
_testmain.go | ||
|
||
*.exe | ||
*.test | ||
*.prof |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md |
Oops, something went wrong.