File: main.go

package info (click to toggle)
golang-github-aws-aws-sdk-go 1.1.14%2Bdfsg-2~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 25,052 kB
  • sloc: ruby: 193; makefile: 98
file content (47 lines) | stat: -rw-r--r-- 959 bytes parent folder | download | duplicates (3)
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)
	}
}