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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ on:

jobs:
call-workflow-passing-data:
uses: cyverse-de/github-workflows/.github/workflows/golangci-lint.yml@v0.2.0
uses: cyverse-de/github-workflows/.github/workflows/golangci-lint.yml@v0.2.1
with:
go-version: 1.24
go-version: 1.25
2 changes: 1 addition & 1 deletion .github/workflows/skaffold-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:

jobs:
call-workflow-passing-data:
uses: cyverse-de/github-workflows/.github/workflows/skaffold-build.yml@v0.2.0
uses: cyverse-de/github-workflows/.github/workflows/skaffold-build.yml@v0.2.1
with:
build-prerelease: ${{ contains(github.ref_name, '-rc') }}
secrets:
Expand Down
24 changes: 21 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
issues:
exclude-files:
- ".../main_docs.go"
version: "2"
linters:
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- '.../main_docs.go'
- third_party$
- builtin$
- examples$
formatters:
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.24
FROM golang:1.25

RUN go install github.com/jstemmer/go-junit-report@latest

Expand All @@ -8,11 +8,10 @@ WORKDIR /go/src/github.com/cyverse-de/requests
COPY . .
RUN make

FROM scratch
FROM gcr.io/distroless/static-debian13

WORKDIR /app

COPY --from=0 /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=0 /go/src/github.com/cyverse-de/requests/requests /bin/requests
COPY --from=0 /go/src/github.com/cyverse-de/requests/swagger.json swagger.json

Expand Down
7 changes: 0 additions & 7 deletions Jenkinsfile

This file was deleted.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
all: requests

install-swagger:
which swagger || go install github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0
which swagger || go install github.com/go-swagger/go-swagger/cmd/swagger@v0.33.1

swagger.json: install-swagger
go mod vendor && swagger generate spec -o ./swagger.json --scan-models
Expand Down
6 changes: 3 additions & 3 deletions api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ type RootResponse struct {
// ErrorResponse describes an error response for any endpoint. This type implements the error interface so that it can
// be returned as an error from existing functions.
type ErrorResponse struct {
Message string `json:"message"`
ErrorCode string `json:"error_code,omitempty"`
Details *map[string]interface{} `json:"details,omitempty"`
Message string `json:"message"`
ErrorCode string `json:"error_code,omitempty"`
Details *map[string]any `json:"details,omitempty"`
}

// ErrorBytes returns a byte-array representation of an ErrorResponse.
Expand Down
16 changes: 8 additions & 8 deletions api/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (

// copyRequestDetails makes a one-level-deep copy of a map. For copying request details, we only need to go one level
// deep because this service doesn't need to modify anything below the top level of the map.
func copyRequestDetails(requestDetails map[string]interface{}) map[string]interface{} {
copy := make(map[string]interface{})
func copyRequestDetails(requestDetails map[string]any) map[string]any {
copy := make(map[string]any)
for k, v := range requestDetails {
copy[k] = v
}
Expand Down Expand Up @@ -92,7 +92,7 @@ func (a *API) AddRequestHandler(c echo.Context) error {
return c.JSON(http.StatusBadRequest, ErrorResponse{
Message: fmt.Sprintf("no more requests of type '%s' may be submitted", requestType.Name),
ErrorCode: "ERR_LIMIT_REACHED",
Details: &map[string]interface{}{
Details: &map[string]any{
"requestType": requestType.Name,
"maximumRequests": *requestType.MaximumRequestsPerUser,
"submittedRequests": count,
Expand All @@ -111,7 +111,7 @@ func (a *API) AddRequestHandler(c echo.Context) error {
return c.JSON(http.StatusBadRequest, ErrorResponse{
Message: fmt.Sprintf("no more active requests of type '%s' may be submitted", requestType.Name),
ErrorCode: "ERR_LIMIT_REACHED",
Details: &map[string]interface{}{
Details: &map[string]any{
"requestType": requestType.Name,
"maximumActiveRequests": *requestType.MaximumConcurrentRequestsPerUser,
"activeSubmittedRequests": count,
Expand Down Expand Up @@ -142,11 +142,11 @@ func (a *API) AddRequestHandler(c echo.Context) error {
}

// Add required information to a copy of the request details.
requestDetails := copyRequestDetails(requestSubmission.Details.(map[string]interface{}))
requestDetails := copyRequestDetails(requestSubmission.Details.(map[string]any))
requestDetails["username"] = user
requestDetails["request_id"] = requestID
requestDetails["request_type"] = requestType.Name
requestDetails["request_details"] = requestSubmission.Details.(map[string]interface{})
requestDetails["request_details"] = requestSubmission.Details.(map[string]any)

// Send the email.
err = a.IPlantEmailClient.SendRequestSubmittedEmail(ctx, a.AdminEmail, requestStatusCode.EmailTemplate, requestDetails)
Expand Down Expand Up @@ -344,11 +344,11 @@ func (a *API) UpdateRequestHandler(c echo.Context) error {
}

// Add required information to a copy of the request details.
requestDetails := copyRequestDetails(request.Details.(map[string]interface{}))
requestDetails := copyRequestDetails(request.Details.(map[string]any))
requestDetails["username"] = request.RequestingUser
requestDetails["request_id"] = request.ID
requestDetails["request_type"] = request.RequestType
requestDetails["request_details"] = request.Details.(map[string]interface{})
requestDetails["request_details"] = request.Details.(map[string]any)
requestDetails["update_message"] = update.Message
requestDetails["email_address"] = requestingUserInfo.Email
requestDetails["action"] = "request_status_change"
Expand Down
12 changes: 6 additions & 6 deletions clients/iplantemail/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ var httpClient = http.Client{Transport: otelhttp.NewTransport(http.DefaultTransp

// EmailRequestBody represents a request body sent to iplant-email.
type EmailRequestBody struct {
To string `json:"to"`
Template string `json:"template"`
Subject string `json:"subject"`
Values interface{} `json:"values"`
To string `json:"to"`
Template string `json:"template"`
Subject string `json:"subject"`
Values any `json:"values"`
}

// Client describes a single instance of this client library.
Expand Down Expand Up @@ -71,7 +71,7 @@ func (c *Client) sendEmail(ctx context.Context, requestBody *EmailRequestBody) e
}

// SendRequestSubmittedEmail sends an email corresponding to a request.
func (c *Client) SendRequestSubmittedEmail(ctx context.Context, emailAddress, templateName string, requestDetails interface{}) error {
func (c *Client) SendRequestSubmittedEmail(ctx context.Context, emailAddress, templateName string, requestDetails any) error {
return c.sendEmail(ctx, &EmailRequestBody{
To: emailAddress,
Template: templateName,
Expand All @@ -81,7 +81,7 @@ func (c *Client) SendRequestSubmittedEmail(ctx context.Context, emailAddress, te
}

// SendRequestUpdatedEmail sends an email corresponding to a request status update.
func (c *Client) SendRequestUpdatedEmail(ctx context.Context, emailAddress, templateName string, requestDetails interface{}) error {
func (c *Client) SendRequestUpdatedEmail(ctx context.Context, emailAddress, templateName string, requestDetails any) error {
return c.sendEmail(ctx, &EmailRequestBody{
To: emailAddress,
Template: templateName,
Expand Down
14 changes: 7 additions & 7 deletions clients/notificationagent/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ func NewClient(baseURL string) *Client {

// NotificationRequest represents a request for a notification.
type NotificationRequest struct {
Type string `json:"type"`
User string `json:"user"`
Subject string `json:"subject"`
Message string `json:"message"`
Email bool `json:"email"`
EmailTemplate string `json:"email_template"`
Payload interface{} `json:"payload"`
Type string `json:"type"`
User string `json:"user"`
Subject string `json:"subject"`
Message string `json:"message"`
Email bool `json:"email"`
EmailTemplate string `json:"email_template"`
Payload any `json:"payload"`
}

// buildURL builds the URL to use for the given path components.
Expand Down
2 changes: 1 addition & 1 deletion db/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func CountActiveRequestsOfType(ctx context.Context, tx *sql.Tx, userID, requestT
}

// AddRequest adds a new request to the database.
func AddRequest(ctx context.Context, tx *sql.Tx, userID, requestTypeID string, details interface{}) (string, error) {
func AddRequest(ctx context.Context, tx *sql.Tx, userID, requestTypeID string, details any) (string, error) {
query := `INSERT INTO requests (request_type_id, requesting_user_id, details)
VALUES ($1, $2, CAST($3 AS json))
RETURNING id`
Expand Down
69 changes: 34 additions & 35 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,68 +1,67 @@
module github.com/cyverse-de/requests

go 1.24.0
go 1.25

require (
github.com/Masterminds/squirrel v1.5.4
github.com/cyverse-de/configurate v0.0.0-20220113221928-13d34aae3f0f
github.com/cyverse-de/dbutil v1.0.1
github.com/cyverse-de/echo-middleware/v2 v2.0.3
github.com/cyverse-de/echo-middleware/v3 v3.0.1
github.com/cyverse-de/go-mod/otelutils v0.0.5
github.com/go-playground/validator/v10 v10.26.0
github.com/labstack/echo/v4 v4.13.4
github.com/go-playground/validator/v10 v10.30.1
github.com/labstack/echo/v4 v4.15.0
github.com/labstack/gommon v0.4.2
github.com/lib/pq v1.10.9
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.61.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0
go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho v0.64.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.64.0
)

require (
github.com/cenkalti/backoff/v5 v5.0.2 // indirect
github.com/cenkalti/backoff/v5 v5.0.3 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
github.com/go-viper/mapstructure/v2 v2.5.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.4 // indirect
github.com/lann/builder v0.0.0-20180802200727-47ae307949d0 // indirect
github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
github.com/sagikazarmark/locafero v0.9.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.14.0 // indirect
github.com/spf13/cast v1.8.0 // indirect
github.com/spf13/pflag v1.0.6 // indirect
github.com/spf13/viper v1.20.1 // indirect
github.com/sagikazarmark/locafero v0.12.0 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/spf13/cast v1.10.0 // indirect
github.com/spf13/pflag v1.0.10 // indirect
github.com/spf13/viper v1.21.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/uptrace/opentelemetry-go-extra/otelsql v0.3.2 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/otel v1.36.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.36.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.36.0 // indirect
go.opentelemetry.io/otel/metric v1.36.0 // indirect
go.opentelemetry.io/otel/sdk v1.36.0 // indirect
go.opentelemetry.io/otel/trace v1.36.0 // indirect
go.opentelemetry.io/proto/otlp v1.7.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.45.0 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/text v0.31.0 // indirect
golang.org/x/time v0.11.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250528174236-200df99c418a // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250528174236-200df99c418a // indirect
google.golang.org/grpc v1.72.2 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/otel v1.39.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.39.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.39.0 // indirect
go.opentelemetry.io/otel/metric v1.39.0 // indirect
go.opentelemetry.io/otel/sdk v1.39.0 // indirect
go.opentelemetry.io/otel/trace v1.39.0 // indirect
go.opentelemetry.io/proto/otlp v1.9.0 // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/crypto v0.47.0 // indirect
golang.org/x/net v0.49.0 // indirect
golang.org/x/sys v0.40.0 // indirect
golang.org/x/text v0.33.0 // indirect
golang.org/x/time v0.14.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20260114163908-3f89685c29c3 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20260114163908-3f89685c29c3 // indirect
google.golang.org/grpc v1.78.0 // indirect
google.golang.org/protobuf v1.36.11 // indirect
)
Loading