forked from aws/aws-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (41 loc) · 959 Bytes
/
main.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
38
39
40
41
42
43
44
45
46
47
// Command aws-gen-goendpoints parses a JSON description of the AWS endpoint
// discovery logic and generates a Go file which returns an endpoint.
//
// aws-gen-goendpoints apis/_endpoints.json aws/endpoints_map.go
package main
import (
"encoding/json"
"os"
"github.com/aws/aws-sdk-go/private/model"
)
// Generates the endpoints from json description
//
// CLI Args:
// [0] This file's execution path
// [1] The definition file to use
// [2] The output file to generate
func main() {
in, err := os.Open(os.Args[1])
if err != nil {
panic(err)
}
defer in.Close()
var endpoints struct {
Version int
Endpoints map[string]struct {
Endpoint string
SigningRegion string
}
}
if err = json.NewDecoder(in).Decode(&endpoints); err != nil {
panic(err)
}
out, err := os.Create(os.Args[2])
if err != nil {
panic(err)
}
defer out.Close()
if err := model.GenerateEndpoints(endpoints, out); err != nil {
panic(err)
}
}