refactor: expose generated code and client business logic to share with Kapacitor (#103)

* refactor: take clients out of internal

* refactor: move stdio to pkg

* Move internal/api to api

* refactor: final changes for Kapacitor to access shared functionality

* chore: regenerate mocks

* fix: bad automated refactor

* chore: extra formatting not caught by make fmt
This commit is contained in:
Sam Arnold
2021-05-25 10:05:01 -04:00
committed by GitHub
parent d54aa9ec2d
commit 9747d05ae1
191 changed files with 377 additions and 372 deletions

4
.gitignore vendored
View File

@ -17,5 +17,5 @@ dist/
vendor/ vendor/
# Docs generated from our openapi repo # Docs generated from our openapi repo
internal/api/cli.yml api/cli.yml
internal/api/cli.gen.yml api/cli.gen.yml

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "openapi"] [submodule "openapi"]
path = internal/api/contract/openapi path = api/contract/openapi
url = ../openapi url = ../openapi

View File

@ -9,7 +9,7 @@ import (
"net/http/httptest" "net/http/httptest"
"testing" "testing"
"github.com/influxdata/influx-cli/v2/internal/api" "github.com/influxdata/influx-cli/v2/api"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )

View File

@ -1,6 +1,6 @@
# API Contract # API Contract
This directory contains the source YMLs used to drive code generation of HTTP clients in [`internal/api`](../). This directory contains the source YMLs used to drive code generation of HTTP clients in [`api`](../).
## YML Structure ## YML Structure
@ -25,29 +25,29 @@ git checkout <new-branch-name>
Next, decide if any modifications are needed in the source-of-truth `openapi` repo. If so, create a branch in the Next, decide if any modifications are needed in the source-of-truth `openapi` repo. If so, create a branch in the
submodule to track changes there: submodule to track changes there:
```shell ```shell
cd internal/api/contract/openapi && git checkout -b <new-branch-name> cd api/contract/openapi && git checkout -b <new-branch-name>
``` ```
Edit/add to the files under `api-contract/` to describe the new API contract. Run the following from the project Edit/add to the files under `api-contract/` to describe the new API contract. Run the following from the project
root test your changes and see the outputs in Go code: root test your changes and see the outputs in Go code:
```shell ```shell
make openapi make openapi
# Use `git status` to see new/modified files under `internal/api` # Use `git status` to see new/modified files under `api`
``` ```
Once you're happy with the new API contract, submit your changes for review & merge. Once you're happy with the new API contract, submit your changes for review & merge.
If you added/edited files within `openapi`, you'll first need to: If you added/edited files within `openapi`, you'll first need to:
1. Push your submodule branch to GitHub 1. Push your submodule branch to GitHub
```shell ```shell
cd internal/api/contract/openapi && git push <your-branch-name> cd api/contract/openapi && git push <your-branch-name>
``` ```
2. Create a PR in `openapi`, eventually merge to `master` there 2. Create a PR in `openapi`, eventually merge to `master` there
3. Update your submodule to point at the merge result: 3. Update your submodule to point at the merge result:
```shell ```shell
cd internal/api/contract/openapi && git fetch && git checkout master && git pull origin master cd api/contract/openapi && git fetch && git checkout master && git pull origin master
``` ```
4. Update the submodule reference from the main repo: 4. Update the submodule reference from the main repo:
```shell ```shell
git add internal/api/contract/openapi git add api/contract/openapi
git commit git commit
``` ```

Some files were not shown because too many files have changed in this diff Show More