-
Notifications
You must be signed in to change notification settings - Fork 388
/
billing.go
37 lines (30 loc) · 1.12 KB
/
billing.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package billing
import (
"fmt"
"time"
"github.com/earthly/cloud-api/billing"
"google.golang.org/protobuf/proto"
)
// AddPlanInfo sets the billing plan to make it available to retrieve later with Plan()
func AddPlanInfo(plan *billing.BillingPlan, usedBuildMinutes time.Duration) {
billingTracker.AddPlanInfo(plan, usedBuildMinutes)
}
// Plan returns a copy of the billing plan which should have been set earlier by AddPlanInfo
func Plan() *billing.BillingPlan {
if billingTracker.plan != nil {
return proto.Clone(billingTracker.plan).(*billing.BillingPlan)
}
return nil
}
// UsedBuildTime returns the used build time(duration) of org referenced by the earthly command
func UsedBuildTime() time.Duration {
return billingTracker.usedBuildTime
}
// GetBillingURL returns the billing url based on the given host and org names
func GetBillingURL(hostName, orgName string) string {
return fmt.Sprintf("%s/%s/settings", hostName, orgName)
}
// GetUpgradeURL returns the billing url based on the given host and org names
func GetUpgradeURL(hostName, orgName string) string {
return fmt.Sprintf("%s/%s/upgrade-now", hostName, orgName)
}