Skip to content

Commit ec2b3fc

Browse files
authored
Update for Fir (#63)
* Switch to latest Schematic * Update schema from Platform API * Manually correct schema * Generated updated client * Really generate updated client * Fix incorrect Formation update DynoSize ID requirement * Move the update to new major version v6 module. Revert v5 module to original contents of main. Update make generate to set package name correctly. * Correct Go version format * Update CI Go version * Fix old v5 Go code format
1 parent 4c27ea6 commit ec2b3fc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+27447
-18
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
runs-on: ubuntu-latest
66
strategy:
77
matrix:
8-
go: [ '1.16', '1.17' ]
8+
go: [ '1.24' ]
99
steps:
1010
- uses: actions/checkout@v2
1111
- uses: actions/setup-go@v2

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ SRC = $(shell find . -type f -name '*.go' -not -path "*vendor/*")
33
default: build
44

55
build: checks
6-
cd v5 && go install .
6+
cd v6 && go install .
77

88
generate:
9-
cd v5 && ../script/generate
9+
cd v6 && ../script/generate
1010

1111
checks: fmt-check
1212

README.md

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44

55
An API client interface for Heroku Platform API for the Go (golang) programming language.
66

7+
Please note: [major version changes](#major-version-changes).
8+
79
## Usage
810

911
$ go mod init myproj
12+
$ go mod get -u github.com/heroku/heroku-go/v6
1013
$ cd myproj
1114

1215
## Example
@@ -20,20 +23,18 @@ import (
2023
"fmt"
2124
"log"
2225

23-
heroku "github.com/heroku/heroku-go/v5"
26+
heroku "github.com/heroku/heroku-go/v6"
2427
)
2528

2629
var (
27-
username = flag.String("username", "", "api username")
28-
password = flag.String("password", "", "api password")
30+
apiKey = flag.String("api-key", "", "Heroku API key")
2931
)
3032

3133
func main() {
3234
log.SetFlags(0)
3335
flag.Parse()
3436

35-
heroku.DefaultTransport.Username = *username
36-
heroku.DefaultTransport.Password = *password
37+
heroku.DefaultTransport.BearerToken = *apiKey
3738

3839
h := heroku.NewService(heroku.DefaultClient)
3940
addons, err := h.AddOnList(context.TODO(), &heroku.ListRange{Field: "name"})
@@ -46,4 +47,55 @@ func main() {
4647
}
4748
```
4849

49-
$ go build
50+
## Major Version Changes
51+
52+
### `v5``v6`
53+
54+
The Formation type's `Size` string property moved to `DynoSize` struct property, which can identify a dyno size by ID or Name.
55+
56+
In `v5`:
57+
58+
```go
59+
import (
60+
heroku "github.com/heroku/heroku-go/v5"
61+
)
62+
63+
opts := heroku.FormationUpdateOpts{}
64+
newSize := "standard-1x"
65+
opts.Size = &newSize
66+
```
67+
68+
…becomes in `v6`
69+
70+
```go
71+
import (
72+
heroku "github.com/heroku/heroku-go/v6"
73+
)
74+
75+
opts := heroku.FormationUpdateOpts{}
76+
newSize := "standard-1x"
77+
opts.DynoSize = &struct {
78+
ID *string `json:"id,omitempty" url:"id,omitempty,key"` // unique identifier of the dyno size
79+
Name *string `json:"name,omitempty" url:"name,omitempty,key"` // name of the dyno size
80+
}{
81+
Name: &newSize,
82+
}
83+
```
84+
85+
## Development
86+
87+
### Update Client for Schema
88+
89+
This client is auto-generated from the JSON Schema published by the Heroku Platform API.
90+
91+
To fetch the current `schema.json` and generate an updated client:
92+
```console
93+
make generate
94+
```
95+
96+
To use the existing `schema.json` to generate an updated client:
97+
```console
98+
UPDATE_SCHEMA=0 make generate
99+
```
100+
101+
See [`script/generate`](script/generate) for more details.

script/generate

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ while getopts "hnv:" opt; do
2727
done
2828

2929
API_VERSION="3"
30-
CLIENT_VERSION="v5"
30+
CLIENT_VERSION="v6"
3131
SCHEMA_FILE="$CLIENT_VERSION/schema.json"
3232
GENERATED_FILE="$CLIENT_VERSION/heroku.go"
3333

@@ -39,12 +39,15 @@ if [ $UPDATE_SCHEMA -eq 1 ]; then
3939
-H "Accept: application/vnd.heroku+json; version=$API_VERSION"
4040
fi
4141

42-
go install github.com/interagent/schematic/cmd/schematic@7f954c20daa584c8b9a5c13bce4973dbd2539482
42+
go install github.com/interagent/schematic/cmd/schematic@latest
4343

4444
schematic "$SCHEMA_FILE" > "$GENERATED_FILE"
4545

4646
sed -E -i '' \
4747
"s/^([[:space:]]*Version[[:space:]]*=[[:space:]]*)\"\"\$/\1\"${CLIENT_VERSION}\"/" \
4848
"$GENERATED_FILE"
49+
sed -E -i '' \
50+
"s/^package heroku/package ${CLIENT_VERSION}/g" \
51+
"$GENERATED_FILE"
4952

5053
gofmt -w "$GENERATED_FILE"

v5/heroku.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
// To be able to interact with this API, you have to
44
// create a new service:
55
//
6-
// s := heroku.NewService(nil)
6+
// s := heroku.NewService(nil)
77
//
88
// The Service struct has all the methods you need
99
// to interact with heroku API.
10-
//
1110
package v5
1211

1312
import (
@@ -2142,7 +2141,6 @@ type EnterpriseAccountDailyUsageInfoResult []EnterpriseAccountDailyUsage
21422141
// from the [enterprise account
21432142
// list](https://devcenter.heroku.com/articles/platform-api-reference#ent
21442143
// erprise-account-list).
2145-
//
21462144
func (s *Service) EnterpriseAccountDailyUsageInfo(ctx context.Context, enterpriseAccountID string, o EnterpriseAccountDailyUsageInfoOpts, lr *ListRange) (EnterpriseAccountDailyUsageInfoResult, error) {
21472145
var enterpriseAccountDailyUsage EnterpriseAccountDailyUsageInfoResult
21482146
return enterpriseAccountDailyUsage, s.Get(ctx, &enterpriseAccountDailyUsage, fmt.Sprintf("/enterprise-accounts/%v/usage/daily", enterpriseAccountID), o, lr)
@@ -2255,7 +2253,6 @@ type EnterpriseAccountMonthlyUsageInfoResult []EnterpriseAccountMonthlyUsage
22552253
// [enterprise account
22562254
// list](https://devcenter.heroku.com/articles/platform-api-reference#ent
22572255
// erprise-account-list).
2258-
//
22592256
func (s *Service) EnterpriseAccountMonthlyUsageInfo(ctx context.Context, enterpriseAccountID string, o EnterpriseAccountMonthlyUsageInfoOpts, lr *ListRange) (EnterpriseAccountMonthlyUsageInfoResult, error) {
22602257
var enterpriseAccountMonthlyUsage EnterpriseAccountMonthlyUsageInfoResult
22612258
return enterpriseAccountMonthlyUsage, s.Get(ctx, &enterpriseAccountMonthlyUsage, fmt.Sprintf("/enterprise-accounts/%v/usage/monthly", enterpriseAccountID), o, lr)
@@ -2965,7 +2962,8 @@ func (s *Service) PasswordResetCompleteResetPassword(ctx context.Context, passwo
29652962
}
29662963

29672964
// [Peering](https://devcenter.heroku.com/articles/private-space-peering)
2968-
// provides a way to peer your Private Space VPC to another AWS VPC.
2965+
//
2966+
// provides a way to peer your Private Space VPC to another AWS VPC.
29692967
type Peering struct {
29702968
AwsAccountID string `json:"aws_account_id" url:"aws_account_id,key"` // The AWS account ID of your Private Space.
29712969
AwsRegion string `json:"aws_region" url:"aws_region,key"` // The AWS region of the peer connection.
@@ -4481,7 +4479,6 @@ type TeamDailyUsageInfoResult []TeamDailyUsage
44814479
// YYYY-MM-DD. The team identifier can be found from the [team list
44824480
// endpoint](https://devcenter.heroku.com/articles/platform-api-reference
44834481
// #team-list).
4484-
//
44854482
func (s *Service) TeamDailyUsageInfo(ctx context.Context, teamID string, o TeamDailyUsageInfoOpts, lr *ListRange) (TeamDailyUsageInfoResult, error) {
44864483
var teamDailyUsage TeamDailyUsageInfoResult
44874484
return teamDailyUsage, s.Get(ctx, &teamDailyUsage, fmt.Sprintf("/teams/%v/usage/daily", teamID), o, lr)
@@ -4788,7 +4785,6 @@ type TeamMonthlyUsageInfoResult []TeamMonthlyUsage
47884785
// The team identifier can be found from the [team list
47894786
// endpoint](https://devcenter.heroku.com/articles/platform-api-reference
47904787
// #team-list).
4791-
//
47924788
func (s *Service) TeamMonthlyUsageInfo(ctx context.Context, teamID string, o TeamMonthlyUsageInfoOpts, lr *ListRange) (TeamMonthlyUsageInfoResult, error) {
47934789
var teamMonthlyUsage TeamMonthlyUsageInfoResult
47944790
return teamMonthlyUsage, s.Get(ctx, &teamMonthlyUsage, fmt.Sprintf("/teams/%v/usage/monthly", teamID), o, lr)

v6/go.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module github.com/heroku/heroku-go/v6
2+
3+
go 1.24
4+
5+
require (
6+
github.com/cenkalti/backoff v2.1.1+incompatible
7+
github.com/google/go-querystring v1.0.0
8+
github.com/pborman/uuid v1.2.0
9+
)
10+
11+
require github.com/google/uuid v1.0.0 // indirect

v6/go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
github.com/cenkalti/backoff v2.1.1+incompatible h1:tKJnvO2kl0zmb/jA5UKAt4VoEVw1qxKWjE/Bpp46npY=
2+
github.com/cenkalti/backoff v2.1.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
3+
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
4+
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
5+
github.com/google/uuid v1.0.0 h1:b4Gk+7WdP/d3HZH8EJsZpvV7EtDOgaZLtnaNGIu1adA=
6+
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
7+
github.com/pborman/uuid v1.2.0 h1:J7Q5mO4ysT1dv8hyrUGHb9+ooztCXu1D8MY8DZYsu3g=
8+
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=

0 commit comments

Comments
 (0)