Skip to content

Commit 616f262

Browse files
authored
Rename restapi to api (#3176)
Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
1 parent 8aa0ec1 commit 616f262

File tree

733 files changed

+396
-372
lines changed

Some content is hidden

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

733 files changed

+396
-372
lines changed

.github/workflows/jobs.yaml

Lines changed: 77 additions & 77 deletions
Large diffs are not rendered by default.

.golangci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ run:
4646
skip-dirs:
4747
- pkg/clientgen
4848
- pkg/apis/networking.gke.io
49-
- restapi/operations
49+
- api/operations

CONTRIBUTING.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,80 @@ This is a REST portal server created using [go-swagger](https://github.com/go-sw
44

55
The API handlers are created using a YAML definition located in `swagger.YAML`.
66

7-
To add new api, the YAML file needs to be updated with all the desired apis using the [Swagger Basic Structure](https://swagger.io/docs/specification/2-0/basic-structure/), this includes paths, parameters, definitions, tags, etc.
7+
To add new api, the YAML file needs to be updated with all the desired apis using
8+
the [Swagger Basic Structure](https://swagger.io/docs/specification/2-0/basic-structure/), this includes paths,
9+
parameters, definitions, tags, etc.
810

911
## Generate server from YAML
12+
1013
Once the YAML file is ready we can autogenerate the code needed for the new api by just running:
1114

1215
Validate it:
16+
1317
```
1418
swagger validate ./swagger.yml
1519
```
20+
1621
Update server code:
22+
1723
```
1824
make swagger-gen
1925
```
2026

2127
This will update all the necessary code.
2228

23-
`./restapi/configure_console.go` is a file that contains the handlers to be used by the application, here is the only place where we need to update our code to support the new apis. This file is not affected when running the swagger generator and it is safe to edit.
29+
`./api/configure_console.go` is a file that contains the handlers to be used by the application, here is the only place
30+
where we need to update our code to support the new apis. This file is not affected when running the swagger generator
31+
and it is safe to edit.
2432

2533
## Unit Tests
26-
`./restapi/handlers_test.go` needs to be updated with the proper tests for the new api.
34+
35+
`./api/handlers_test.go` needs to be updated with the proper tests for the new api.
2736

2837
To run tests:
38+
2939
```
30-
go test ./restapi
40+
go test ./api
3141
```
3242

3343
## Commit changes
34-
After verification, commit your changes. This is a [great post](https://chris.beams.io/posts/git-commit/) on how to write useful commit messages
44+
45+
After verification, commit your changes. This is a [great post](https://chris.beams.io/posts/git-commit/) on how to
46+
write useful commit messages
3547

3648
```
3749
$ git commit -am 'Add some feature'
3850
```
3951

4052
### Push to the branch
53+
4154
Push your locally committed changes to the remote origin (your fork)
55+
4256
```
4357
$ git push origin my-new-feature
4458
```
4559

4660
### Create a Pull Request
47-
Pull requests can be created via GitHub. Refer to [this document](https://help.github.com/articles/creating-a-pull-request/) for detailed steps on how to create a pull request. After a Pull Request gets peer reviewed and approved, it will be merged.
61+
62+
Pull requests can be created via GitHub. Refer
63+
to [this document](https://help.github.com/articles/creating-a-pull-request/) for detailed steps on how to create a pull
64+
request. After a Pull Request gets peer reviewed and approved, it will be merged.
4865

4966
## FAQs
67+
5068
### How does ``console`` manages dependencies?
69+
5170
``MinIO`` uses `go mod` to manage its dependencies.
71+
5272
- Run `go get foo/bar` in the source folder to add the dependency to `go.mod` file.
5373

5474
To remove a dependency
75+
5576
- Edit your code and remove the import reference.
5677
- Run `go mod tidy` in the source folder to remove dependency from `go.mod` file.
5778

5879
### What are the coding guidelines for console?
59-
``console`` is fully conformant with Golang style. Refer: [Effective Go](https://github.com/golang/go/wiki/CodeReviewComments) article from Golang project. If you observe offending code, please feel free to send a pull request or ping us on [Slack](https://slack.min.io).
80+
81+
``console`` is fully conformant with Golang style.
82+
Refer: [Effective Go](https://github.com/golang/go/wiki/CodeReviewComments) article from Golang project. If you observe
83+
offending code, please feel free to send a pull request or ping us on [Slack](https://slack.min.io).

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ apply-gofmt:
4848
clean-swagger:
4949
@echo "cleaning"
5050
@rm -rf models
51-
@rm -rf restapi/operations
51+
@rm -rf api/operations
5252

5353
swagger-console:
5454
@echo "Generating swagger server code from yaml"
55-
@swagger generate server -A console --main-package=management --server-package=restapi --exclude-main -P models.Principal -f ./swagger.yml -r NOTICE
55+
@swagger generate server -A console --main-package=management --server-package=api --exclude-main -P models.Principal -f ./swagger.yml -r NOTICE
5656
@echo "Generating typescript api"
5757
@npx swagger-typescript-api -p ./swagger.yml -o ./portal-ui/src/api -n consoleApi.ts
58-
@git restore restapi/server.go
58+
@git restore api/server.go
5959

6060

6161
assets:
@@ -78,7 +78,7 @@ test-integration:
7878
@echo "Postgres"
7979
@(docker run --net=mynet123 --ip=173.18.0.4 --name pgsqlcontainer --rm -p 5432:5432 -e POSTGRES_PASSWORD=password -d postgres && sleep 5)
8080
@echo "execute test and get coverage for test-integration:"
81-
@(cd integration && go test -coverpkg=../restapi -c -tags testrunmain . && mkdir -p coverage && ./integration.test -test.v -test.run "^Test*" -test.coverprofile=coverage/system.out)
81+
@(cd integration && go test -coverpkg=../api -c -tags testrunmain . && mkdir -p coverage && ./integration.test -test.v -test.run "^Test*" -test.coverprofile=coverage/system.out)
8282
@(docker stop pgsqlcontainer)
8383
@(docker stop minio)
8484
@(docker stop minio2)
@@ -126,7 +126,7 @@ test-replication:
126126
$(MINIO_VERSION) server /data{1...4} \
127127
--address :9002 \
128128
--console-address :6002)
129-
@(cd replication && go test -coverpkg=../restapi -c -tags testrunmain . && mkdir -p coverage && ./replication.test -test.v -test.run "^Test*" -test.coverprofile=coverage/replication.out)
129+
@(cd replication && go test -coverpkg=../api -c -tags testrunmain . && mkdir -p coverage && ./replication.test -test.v -test.run "^Test*" -test.coverprofile=coverage/replication.out)
130130
@(docker stop minio || true)
131131
@(docker stop minio1 || true)
132132
@(docker stop minio2 || true)
@@ -180,7 +180,7 @@ test-sso-integration:
180180
@echo "add python module"
181181
@(pip3 install bs4)
182182
@echo "Executing the test:"
183-
@(cd sso-integration && go test -coverpkg=../restapi -c -tags testrunmain . && mkdir -p coverage && ./sso-integration.test -test.v -test.run "^Test*" -test.coverprofile=coverage/sso-system.out)
183+
@(cd sso-integration && go test -coverpkg=../api -c -tags testrunmain . && mkdir -p coverage && ./sso-integration.test -test.v -test.run "^Test*" -test.coverprofile=coverage/sso-system.out)
184184

185185
test-permissions-1:
186186
@(docker run -v /data1 -v /data2 -v /data3 -v /data4 -d --name minio --rm -p 9000:9000 quay.io/minio/minio:latest server /data{1...4})
@@ -259,7 +259,7 @@ cleanup-minio-nginx:
259259
# This is needed because tests can be in the folder or sub-folder(s), let's include them all please!.
260260
test:
261261
@echo "execute test and get coverage"
262-
@(cd restapi && mkdir -p coverage && GO111MODULE=on go test ./... -test.v -coverprofile=coverage/coverage.out)
262+
@(cd api && mkdir -p coverage && GO111MODULE=on go test ./... -test.v -coverprofile=coverage/coverage.out)
263263

264264

265265
# https://stackoverflow.com/questions/19200235/golang-tests-in-sub-directory
@@ -270,7 +270,7 @@ test-pkg:
270270
@(cd pkg && mkdir -p coverage && GO111MODULE=on go test ./... -test.v -coverprofile=coverage/coverage-pkg.out)
271271

272272
coverage:
273-
@(GO111MODULE=on go test -v -coverprofile=coverage.out github.com/minio/console/restapi/... && go tool cover -html=coverage.out && open coverage.html)
273+
@(GO111MODULE=on go test -v -coverprofile=coverage.out github.com/minio/console/api/... && go tool cover -html=coverage.out && open coverage.html)
274274

275275
clean:
276276
@echo "Cleaning up all the generated files"

restapi/admin_arns.go renamed to api/admin_arns.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
package restapi
17+
package api
1818

1919
import (
2020
"context"
2121

22-
systemApi "github.com/minio/console/restapi/operations/system"
22+
systemApi "github.com/minio/console/api/operations/system"
2323

2424
"github.com/go-openapi/runtime/middleware"
25+
"github.com/minio/console/api/operations"
2526
"github.com/minio/console/models"
26-
"github.com/minio/console/restapi/operations"
2727
)
2828

2929
func registerAdminArnsHandlers(api *operations.ConsoleAPI) {

restapi/admin_arns_test.go renamed to api/admin_arns_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
package restapi
17+
package api
1818

1919
import (
2020
"context"
@@ -25,11 +25,11 @@ import (
2525
"testing"
2626

2727
"github.com/go-openapi/runtime/middleware"
28+
"github.com/minio/console/api/operations/system"
2829
"github.com/minio/console/models"
29-
"github.com/minio/console/restapi/operations/system"
3030

3131
"github.com/go-openapi/loads"
32-
"github.com/minio/console/restapi/operations"
32+
"github.com/minio/console/api/operations"
3333
"github.com/minio/madmin-go/v3"
3434

3535
asrt "github.com/stretchr/testify/assert"

restapi/admin_client_mock.go renamed to api/admin_client_mock.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
package restapi
17+
package api
1818

1919
import (
2020
"context"

restapi/admin_config.go renamed to api/admin_config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
package restapi
17+
package api
1818

1919
import (
2020
"context"
@@ -24,11 +24,11 @@ import (
2424

2525
"github.com/go-openapi/runtime/middleware"
2626
"github.com/go-openapi/swag"
27+
"github.com/minio/console/api/operations"
2728
"github.com/minio/console/models"
28-
"github.com/minio/console/restapi/operations"
2929
madmin "github.com/minio/madmin-go/v3"
3030

31-
cfgApi "github.com/minio/console/restapi/operations/configuration"
31+
cfgApi "github.com/minio/console/api/operations/configuration"
3232
)
3333

3434
func registerConfigHandlers(api *operations.ConsoleAPI) {

restapi/admin_config_test.go renamed to api/admin_config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
package restapi
17+
package api
1818

1919
import (
2020
"context"

restapi/admin_console.go renamed to api/admin_console.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// You should have received a copy of the GNU Affero General Public License
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

17-
package restapi
17+
package api
1818

1919
import (
2020
"context"

0 commit comments

Comments
 (0)