Skip to content

Commit

Permalink
renamed the project to github.com/cyverse-de/qms
Browse files Browse the repository at this point in the history
  • Loading branch information
slr71 committed May 8, 2024
1 parent ea95952 commit a94f8df
Show file tree
Hide file tree
Showing 27 changed files with 81 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*.dll
*.so
*.dylib
QMS
qms

# Test binary, built with `go test -c`
*.test
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ RUN go install github.com/jstemmer/go-junit-report@latest

ENV CGO_ENABLED=0

WORKDIR /go/src/github.com/cyverse-de/QMS
WORKDIR /go/src/github.com/cyverse-de/qms
COPY . .
RUN make

FROM debian:stable-slim

WORKDIR /app

COPY --from=0 /go/src/github.com/cyverse-de/QMS/QMS /bin/QMS
COPY --from=0 /go/src/github.com/cyverse-de/QMS/swagger.json swagger.json
COPY --from=0 /go/src/github.com/cyverse-de/QMS/migrations migrations
COPY --from=0 /go/src/github.com/cyverse-de/qms/qms /bin/qms
COPY --from=0 /go/src/github.com/cyverse-de/qms/swagger.json swagger.json
COPY --from=0 /go/src/github.com/cyverse-de/qms/migrations migrations

ENTRYPOINT ["QMS"]
ENTRYPOINT ["qms"]

EXPOSE 8080
14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
all: QMS
all: qms

install-swagger:
which swagger || go install github.com/go-swagger/go-swagger/cmd/swagger@latest

swagger.json: install-swagger
swagger generate spec -o ./swagger.json --scan-models

QMS: swagger.json
qms: swagger.json
go build --buildvcs=false .

clean:
rm -rf QMS swagger.json
rm -rf qms swagger.json

.PHONY: install-swagger clean all
lint:
golangci-lint run

test:
go test ./...

.PHONY: install-swagger clean all lint test
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# QMS
# qms

QMS is the CyVerse Quota Management System. Its purpose is to keep track of resource usage limits and totals for
qms is the CyVerse Quota Management System. Its purpose is to keep track of resource usage limits and totals for
CyVerse users.

## Concepts
Expand All @@ -20,21 +20,21 @@ user. Quotas can be customized if necessary, but customizing quotas should be a

### Current Usage

The QMS tracks the current resource usage totals for each CyVerse user. These usage totals are calculated by other
CyVerse microservices and reported to the QMS.
The qms tracks the current resource usage totals for each CyVerse user. These usage totals are calculated by other
CyVerse microservices and reported to the qms.

### Updates

Updates to both quotas and resource usage totals are recorded in the QMS database for auditing purposes.
Updates to both quotas and resource usage totals are recorded in the qms database for auditing purposes.

## Configuration Settings

The QMS uses environment variables for its configuration settings. The following configuration settings are supported.
The qms uses environment variables for its configuration settings. The following configuration settings are supported.

### QMS_DATABASE_URI (Required)

This environment variable contains the database connection URI. The QMS uses a PostgreSQL database to keep track of
its data. Any version of PostgreSQL that supports the required extensions should work, but the QMS has been tested
This environment variable contains the database connection URI. The qms uses a PostgreSQL database to keep track of
its data. Any version of PostgreSQL that supports the required extensions should work, but the qms has been tested
against versions 12, 13, and 14. The following extensions are required:

1. uuid-ossp
Expand All @@ -58,20 +58,20 @@ postgresql://[email protected]:5432/dbname?sslmode=disable

### QMS_DATABASE_MIGRATE (Optional, Default: `false`)

If this environment variable is defined and set to `true` then QMS will automatically run database schema migrations
If this environment variable is defined and set to `true` then qms will automatically run database schema migrations
on startup.

### QMS_DATABASE_REINIT (Optional, Default: `false`)

If this environment variable is defined and set to `true` then the QMS will reinitialize the database upon startup.
If this environment variable is defined and set to `true` then the qms will reinitialize the database upon startup.
This feature is intended to be used only during development testing, when the schema migrations are being actively
updated. Note: this parameter is only applicable if `QMS_DATABASE_MIGRATE` is also enabled.

## Database Schema Migraions

The QMS runs its schema migrations upon startup. For this to succeed, two prerequisites must be satisfied. The first
The qms runs its schema migrations upon startup. For this to succeed, two prerequisites must be satisfied. The first
requirement is that the database must exist and must have the required extensions listed above installed. Having the
extensions installed in advance allows QMS to use a regular PostgreSQL account instead of requiring an administrative
extensions installed in advance allows qms to use a regular PostgreSQL account instead of requiring an administrative
account.

The second requirement is that the schema migrations must exist in a subdirectory of the current working directory
Expand Down
6 changes: 3 additions & 3 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"github.com/cyverse-de/go-mod/cfg"
)

var ServiceName = "QMS"
var ServiceName = "qms"

// Specification defines the configuration settings for the QMS service.
// Specification defines the configuration settings for the qms service.
type Specification struct {
DatabaseURI string
RunSchemaMigrations bool
Expand All @@ -19,7 +19,7 @@ type Specification struct {
UsernameSuffix string
}

// LoadConfig loads the configuration for the QMS service.
// LoadConfig loads the configuration for the qms service.
func LoadConfig(envPrefix, configPath, dotEnvPath string) (*Specification, error) {
k, err := cfg.Init(&cfg.Settings{
EnvPrefix: envPrefix,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/cyverse/QMS
module github.com/cyverse/qms

go 1.21

Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/admins.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (

"github.com/sirupsen/logrus"

"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/qms/internal/model"
"github.com/labstack/echo/v4"
)

Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"gorm.io/gorm/clause"

"github.com/cyverse-de/echo-middleware/v2/params"
"github.com/cyverse/QMS/internal/db"
"github.com/cyverse/QMS/internal/httpmodel"
"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/qms/internal/db"
"github.com/cyverse/qms/internal/httpmodel"
"github.com/cyverse/qms/internal/model"
"github.com/labstack/echo/v4"
"github.com/sirupsen/logrus"
"gorm.io/gorm"
Expand Down
8 changes: 4 additions & 4 deletions internal/controllers/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"net/http"

"github.com/cyverse-de/echo-middleware/v2/params"
"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/qms/internal/model"
"github.com/labstack/echo/v4"
"github.com/sirupsen/logrus"
"gorm.io/gorm"
Expand All @@ -26,7 +26,7 @@ func extractResourceTypeID(ctx echo.Context) (string, error) {
//
// List Resource Types
//
// Lists all the resource types defined in the QMS database.
// Lists all the resource types defined in the qms database.
//
// responses:
// 200: resourceTypeListing
Expand All @@ -53,7 +53,7 @@ func (s Server) ListResourceTypes(ctx echo.Context) error {
//
// Add Resource Type
//
// Adds a new resource type to the QMS database.
// Adds a new resource type to the qms database.
//
// responses:
// 200: resourceTypeDetails
Expand Down Expand Up @@ -151,7 +151,7 @@ func (s Server) GetResourceTypeDetails(ctx echo.Context) error {
//
// Update Resource Type
//
// Updates an existing resource type in the QMS database.
// Updates an existing resource type in the qms database.
//
// responses:
// 200: resourceTypeDetails
Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import (
"database/sql"
"net/http"

"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/QMS/logging"
"github.com/cyverse/qms/internal/model"
"github.com/cyverse/qms/logging"
"github.com/labstack/echo/v4"
"github.com/sirupsen/logrus"
"gorm.io/gorm"
)

var log = logging.GetLogger().WithFields(logrus.Fields{"package": "controllers"})

// Server defines the REST API of the QMS
// Server defines the REST API of the qms
type Server struct {
Router *echo.Echo
DB *sql.DB
Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"net/http"

"github.com/cyverse/QMS/internal/db"
"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/QMS/internal/query"
"github.com/cyverse/qms/internal/db"
"github.com/cyverse/qms/internal/model"
"github.com/cyverse/qms/internal/query"
"github.com/labstack/echo/v4"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/usages.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"strings"
"time"

"github.com/cyverse/QMS/internal/db"
"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/qms/internal/db"
"github.com/cyverse/qms/internal/model"
"github.com/labstack/echo/v4"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down
16 changes: 8 additions & 8 deletions internal/controllers/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import (

"github.com/cyverse-de/go-mod/pbinit"
"github.com/cyverse-de/p/go/qms"
"github.com/cyverse/QMS/internal/db"
"github.com/cyverse/QMS/internal/httpmodel"
"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/QMS/internal/model/timestamp"
"github.com/cyverse/QMS/internal/query"
"github.com/cyverse/qms/internal/db"
"github.com/cyverse/qms/internal/httpmodel"
"github.com/cyverse/qms/internal/model"
"github.com/cyverse/qms/internal/model/timestamp"
"github.com/cyverse/qms/internal/query"
"github.com/labstack/echo/v4"
"github.com/sirupsen/logrus"
)
Expand All @@ -28,7 +28,7 @@ const (
//
// List Users
//
// Lists the users registered in the QMS database.
// Lists the users registered in the qms database.
//
// responses:
// 200: userListing
Expand Down Expand Up @@ -199,7 +199,7 @@ func (s Server) GetUserOverages(ctx echo.Context) error {

responseList := pbinit.NewOverageList()

// Skip the remaining logic because QMS is configured to not report overages.
// Skip the remaining logic because qms is configured to not report overages.
if !s.ReportOverages {
return model.ProtobufJSON(ctx, responseList, http.StatusOK)
}
Expand Down Expand Up @@ -240,7 +240,7 @@ func (s Server) InOverage(ctx echo.Context) error {

response := pbinit.NewIsOverage()

// Skip the rest of the logic because QMS is configured to not report overages
// Skip the rest of the logic because qms is configured to not report overages
if !s.ReportOverages {
response.IsOverage = false
return model.ProtobufJSON(ctx, response, http.StatusOK)
Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"net/http"

"github.com/cyverse/QMS/internal/db"
"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/qms/internal/db"
"github.com/cyverse/qms/internal/model"
"github.com/labstack/echo/v4"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/db/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/qms/internal/model"
"github.com/pkg/errors"
"gorm.io/gorm"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/db/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"context"
"fmt"

"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/qms/internal/model"
"github.com/pkg/errors"
"gorm.io/gorm"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/db/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"time"

"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/qms/internal/model"
"github.com/pkg/errors"
"gorm.io/gorm"
"gorm.io/gorm/clause"
Expand Down
2 changes: 1 addition & 1 deletion internal/db/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package db
import (
"context"

"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/qms/internal/model"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
Expand Down
2 changes: 1 addition & 1 deletion internal/db/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package db
import (
"context"

"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/qms/internal/model"
"github.com/pkg/errors"
"gorm.io/gorm"
"gorm.io/gorm/clause"
Expand Down
2 changes: 1 addition & 1 deletion internal/httpmodel/new_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package httpmodel
import (
"fmt"

"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/qms/internal/model"
)

// Note: the names in the comments may deviate a bit from the actual structure names in order to avoid producing
Expand Down
2 changes: 1 addition & 1 deletion internal/model/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package model
import (
"time"

"github.com/cyverse/QMS/internal/model/timestamp"
"github.com/cyverse/qms/internal/model/timestamp"
)

// SubscriptionOptions represents options that can be applied to a new subscription.
Expand Down
2 changes: 1 addition & 1 deletion internal/model/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const (
ValueTypeUsages = "usages"
)

// UpdateOperation defines the structure of an available update operation in the QMS database.
// UpdateOperation defines the structure of an available update operation in the qms database.
//
// swagger:model
type UpdateOperation struct {
Expand Down
10 changes: 5 additions & 5 deletions internal/swagger/swagger.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package api QMS
// Package api qms
//
// Documentation of the QMS Api
// Documentation of the qms Api
//
// Schemes: http
// BasePath: /
Expand All @@ -16,9 +16,9 @@
package swagger

import (
"github.com/cyverse/QMS/internal/controllers"
"github.com/cyverse/QMS/internal/httpmodel"
"github.com/cyverse/QMS/internal/model"
"github.com/cyverse/qms/internal/controllers"
"github.com/cyverse/qms/internal/httpmodel"
"github.com/cyverse/qms/internal/model"
)

// Note: the comments in this package don't conform to the convention of including the name of the entity that the
Expand Down
Loading

0 comments on commit a94f8df

Please sign in to comment.