Skip to content

Commit 9465741

Browse files
committed
usage-api: extract config to api
1 parent 1d8fb82 commit 9465741

File tree

7 files changed

+338
-97
lines changed

7 files changed

+338
-97
lines changed

components/public-api/go/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type Configuration struct {
3131
// Redis configures the connection to Redis
3232
Redis RedisConfiguration `json:"redis"`
3333

34-
// Authentication configuration
34+
// AuthN configuration
3535
Auth AuthConfiguration `json:"auth"`
3636

3737
Server *baseserver.Configuration `json:"server,omitempty"`
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2+
// Licensed under the GNU Affero General Public License (AGPL).
3+
// See License.AGPL.txt in the project root for license information.
4+
5+
package config
6+
7+
import (
8+
db "github.com/gitpod-io/gitpod/components/gitpod-db/go"
9+
)
10+
11+
type Config struct {
12+
// LedgerSchedule determines how frequently to run the Usage/Billing controller.
13+
// When LedgerSchedule is empty, the background controller is disabled.
14+
LedgerSchedule string `json:"controllerSchedule,omitempty"`
15+
16+
// ResetUsageSchedule determines how frequently to run the Usage Reset job.
17+
// When empty, the job is disabled.
18+
ResetUsageSchedule string `json:"resetUsageSchedule,omitempty"`
19+
20+
CreditsPerMinuteByWorkspaceClass map[string]float64 `json:"creditsPerMinuteByWorkspaceClass,omitempty"`
21+
22+
StripeCredentialsFile string `json:"stripeCredentialsFile,omitempty"`
23+
24+
DefaultSpendingLimit db.DefaultSpendingLimit `json:"defaultSpendingLimit"`
25+
26+
// StripePrices configure which Stripe Price IDs should be used
27+
StripePrices StripePrices `json:"stripePrices"`
28+
}
29+
30+
type StripePrices struct {
31+
IndividualUsagePriceIDs PriceConfig `json:"individualUsagePriceIds"`
32+
TeamUsagePriceIDs PriceConfig `json:"teamUsagePriceIds"`
33+
}
34+
35+
type PriceConfig struct {
36+
EUR string `json:"eur"`
37+
USD string `json:"usd"`
38+
}

components/usage-api/go/go.mod

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ go 1.21
44

55
replace github.com/gitpod-io/gitpod/common-go => ../../common-go // leeway
66

7+
replace github.com/gitpod-io/gitpod/components/scrubber => ../../scrubber // leeway
8+
79
replace k8s.io/api => k8s.io/api v0.27.3 // leeway indirect from components/common-go:lib
810

911
replace k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.27.3 // leeway indirect from components/common-go:lib
@@ -55,14 +57,34 @@ replace k8s.io/mount-utils => k8s.io/mount-utils v0.27.3 // leeway indirect from
5557
replace k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.27.3 // leeway indirect from components/common-go:lib
5658

5759
require (
58-
google.golang.org/grpc v1.47.0
59-
google.golang.org/protobuf v1.28.1
60+
github.com/gitpod-io/gitpod/components/gitpod-db/go v0.0.0-20231010172218-3eb86ff8b745
61+
google.golang.org/grpc v1.55.0
62+
google.golang.org/protobuf v1.30.0
6063
)
6164

6265
require (
63-
github.com/golang/protobuf v1.5.2 // indirect
64-
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
65-
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4 // indirect
66-
golang.org/x/text v0.3.3 // indirect
67-
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
66+
github.com/gitpod-io/gitpod/common-go v0.0.0-00010101000000-000000000000 // indirect
67+
github.com/gitpod-io/gitpod/components/scrubber v0.0.0-00010101000000-000000000000 // indirect
68+
github.com/go-logr/logr v1.2.4 // indirect
69+
github.com/go-logr/stdr v1.2.2 // indirect
70+
github.com/go-sql-driver/mysql v1.6.0 // indirect
71+
github.com/golang/protobuf v1.5.3 // indirect
72+
github.com/google/uuid v1.3.0 // indirect
73+
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
74+
github.com/jinzhu/inflection v1.0.0 // indirect
75+
github.com/jinzhu/now v1.1.5 // indirect
76+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
77+
github.com/relvacode/iso8601 v1.1.0 // indirect
78+
github.com/sirupsen/logrus v1.9.3 // indirect
79+
go.opentelemetry.io/otel v1.16.0 // indirect
80+
go.opentelemetry.io/otel/metric v1.16.0 // indirect
81+
go.opentelemetry.io/otel/trace v1.16.0 // indirect
82+
golang.org/x/net v0.10.0 // indirect
83+
golang.org/x/sys v0.11.0 // indirect
84+
golang.org/x/text v0.9.0 // indirect
85+
google.golang.org/genproto/googleapis/rpc v0.0.0-20230526161137-0005af68ea54 // indirect
86+
gorm.io/datatypes v1.0.7 // indirect
87+
gorm.io/driver/mysql v1.4.4 // indirect
88+
gorm.io/gorm v1.25.1 // indirect
89+
gorm.io/plugin/opentelemetry v0.1.3 // indirect
6890
)

0 commit comments

Comments
 (0)