Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
154 changes: 77 additions & 77 deletions .github/workflows/jobs.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ run:
skip-dirs:
- pkg/clientgen
- pkg/apis/networking.gke.io
- restapi/operations
- api/operations
38 changes: 31 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,80 @@ This is a REST portal server created using [go-swagger](https://github.com/go-sw

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

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.
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.

## Generate server from YAML

Once the YAML file is ready we can autogenerate the code needed for the new api by just running:

Validate it:

```
swagger validate ./swagger.yml
```

Update server code:

```
make swagger-gen
```

This will update all the necessary code.

`./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.
`./api/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.

## Unit Tests
`./restapi/handlers_test.go` needs to be updated with the proper tests for the new api.

`./api/handlers_test.go` needs to be updated with the proper tests for the new api.

To run tests:

```
go test ./restapi
go test ./api
```

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

After verification, commit your changes. This is a [great post](https://chris.beams.io/posts/git-commit/) on how to
write useful commit messages

```
$ git commit -am 'Add some feature'
```

### Push to the branch

Push your locally committed changes to the remote origin (your fork)

```
$ git push origin my-new-feature
```

### Create a Pull Request
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.

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.

## FAQs

### How does ``console`` manages dependencies?

``MinIO`` uses `go mod` to manage its dependencies.

- Run `go get foo/bar` in the source folder to add the dependency to `go.mod` file.

To remove a dependency

- Edit your code and remove the import reference.
- Run `go mod tidy` in the source folder to remove dependency from `go.mod` file.

### What are the coding guidelines for console?
``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).

``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).
16 changes: 8 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ apply-gofmt:
clean-swagger:
@echo "cleaning"
@rm -rf models
@rm -rf restapi/operations
@rm -rf api/operations

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


assets:
Expand All @@ -78,7 +78,7 @@ test-integration:
@echo "Postgres"
@(docker run --net=mynet123 --ip=173.18.0.4 --name pgsqlcontainer --rm -p 5432:5432 -e POSTGRES_PASSWORD=password -d postgres && sleep 5)
@echo "execute test and get coverage for test-integration:"
@(cd integration && go test -coverpkg=../restapi -c -tags testrunmain . && mkdir -p coverage && ./integration.test -test.v -test.run "^Test*" -test.coverprofile=coverage/system.out)
@(cd integration && go test -coverpkg=../api -c -tags testrunmain . && mkdir -p coverage && ./integration.test -test.v -test.run "^Test*" -test.coverprofile=coverage/system.out)
@(docker stop pgsqlcontainer)
@(docker stop minio)
@(docker stop minio2)
Expand Down Expand Up @@ -126,7 +126,7 @@ test-replication:
$(MINIO_VERSION) server /data{1...4} \
--address :9002 \
--console-address :6002)
@(cd replication && go test -coverpkg=../restapi -c -tags testrunmain . && mkdir -p coverage && ./replication.test -test.v -test.run "^Test*" -test.coverprofile=coverage/replication.out)
@(cd replication && go test -coverpkg=../api -c -tags testrunmain . && mkdir -p coverage && ./replication.test -test.v -test.run "^Test*" -test.coverprofile=coverage/replication.out)
@(docker stop minio || true)
@(docker stop minio1 || true)
@(docker stop minio2 || true)
Expand Down Expand Up @@ -180,7 +180,7 @@ test-sso-integration:
@echo "add python module"
@(pip3 install bs4)
@echo "Executing the test:"
@(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)
@(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)

test-permissions-1:
@(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})
Expand Down Expand Up @@ -259,7 +259,7 @@ cleanup-minio-nginx:
# This is needed because tests can be in the folder or sub-folder(s), let's include them all please!.
test:
@echo "execute test and get coverage"
@(cd restapi && mkdir -p coverage && GO111MODULE=on go test ./... -test.v -coverprofile=coverage/coverage.out)
@(cd api && mkdir -p coverage && GO111MODULE=on go test ./... -test.v -coverprofile=coverage/coverage.out)


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

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

clean:
@echo "Cleaning up all the generated files"
Expand Down
6 changes: 3 additions & 3 deletions restapi/admin_arns.go → api/admin_arns.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"

systemApi "github.com/minio/console/restapi/operations/system"
systemApi "github.com/minio/console/api/operations/system"

"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
"github.com/minio/console/models"
"github.com/minio/console/restapi/operations"
)

func registerAdminArnsHandlers(api *operations.ConsoleAPI) {
Expand Down
6 changes: 3 additions & 3 deletions restapi/admin_arns_test.go → api/admin_arns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"
Expand All @@ -25,11 +25,11 @@ import (
"testing"

"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations/system"
"github.com/minio/console/models"
"github.com/minio/console/restapi/operations/system"

"github.com/go-openapi/loads"
"github.com/minio/console/restapi/operations"
"github.com/minio/console/api/operations"
"github.com/minio/madmin-go/v3"

asrt "github.com/stretchr/testify/assert"
Expand Down
2 changes: 1 addition & 1 deletion restapi/admin_client_mock.go → api/admin_client_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"
Expand Down
6 changes: 3 additions & 3 deletions restapi/admin_config.go → api/admin_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"
Expand All @@ -24,11 +24,11 @@ import (

"github.com/go-openapi/runtime/middleware"
"github.com/go-openapi/swag"
"github.com/minio/console/api/operations"
"github.com/minio/console/models"
"github.com/minio/console/restapi/operations"
madmin "github.com/minio/madmin-go/v3"

cfgApi "github.com/minio/console/restapi/operations/configuration"
cfgApi "github.com/minio/console/api/operations/configuration"
)

func registerConfigHandlers(api *operations.ConsoleAPI) {
Expand Down
2 changes: 1 addition & 1 deletion restapi/admin_config_test.go → api/admin_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion restapi/admin_console.go → api/admin_console.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"
Expand Down
6 changes: 3 additions & 3 deletions restapi/admin_groups.go → api/admin_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"

"github.com/go-openapi/errors"
"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
"github.com/minio/console/pkg/utils"
"github.com/minio/console/restapi/operations"
"github.com/minio/madmin-go/v3"

groupApi "github.com/minio/console/restapi/operations/group"
groupApi "github.com/minio/console/api/operations/group"

"github.com/minio/console/models"
)
Expand Down
2 changes: 1 addition & 1 deletion restapi/admin_groups_test.go → api/admin_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion restapi/admin_heal.go → api/admin_heal.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion restapi/admin_heal_test.go → api/admin_heal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"
Expand Down
2 changes: 1 addition & 1 deletion restapi/admin_health_info.go → api/admin_health_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"bytes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"
Expand Down
6 changes: 3 additions & 3 deletions restapi/admin_idp.go → api/admin_idp.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

package restapi
package api

import (
"context"
"fmt"
"time"

"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
"github.com/minio/console/api/operations/idp"
"github.com/minio/console/models"
"github.com/minio/console/restapi/operations"
"github.com/minio/console/restapi/operations/idp"
"github.com/minio/madmin-go/v3"
)

Expand Down
6 changes: 3 additions & 3 deletions restapi/admin_idp_test.go → api/admin_idp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"
Expand All @@ -27,9 +27,9 @@ import (

"github.com/minio/madmin-go/v3"

"github.com/minio/console/api/operations"
"github.com/minio/console/api/operations/idp"
"github.com/minio/console/models"
"github.com/minio/console/restapi/operations"
"github.com/minio/console/restapi/operations/idp"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/suite"
)
Expand Down
6 changes: 3 additions & 3 deletions restapi/admin_info.go → api/admin_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

package restapi
package api

import (
"context"
Expand All @@ -31,9 +31,9 @@ import (
"github.com/minio/console/pkg/utils"

"github.com/go-openapi/runtime/middleware"
"github.com/minio/console/api/operations"
systemApi "github.com/minio/console/api/operations/system"
"github.com/minio/console/models"
"github.com/minio/console/restapi/operations"
systemApi "github.com/minio/console/restapi/operations/system"
)

func registerAdminInfoHandlers(api *operations.ConsoleAPI) {
Expand Down
Loading