Skip to content

Commit

Permalink
Add Generated headers to generated code, and consisten formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jasdel committed May 28, 2015
1 parent b33d8c8 commit 8dbe47a
Show file tree
Hide file tree
Showing 130 changed files with 344 additions and 109 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
LINTIGNOREDOT='internal/features.+should not use dot imports'
LINTIGNOREDOC='service/[^/]+/(.*iface/interface|api)\.go:.+(comment on exported|should have comment or be unexported)'
LINTIGNOREDOC='service/[^/]+/(api)\.go:.+(comment on exported|should have comment or be unexported)'

default: generate

Expand Down
2 changes: 1 addition & 1 deletion internal/fixtures/protocol/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func main() {
if err != nil {
panic(err)
}
f.WriteString(out + "\n")
f.WriteString(util.GoFmt(out))
} else {
fmt.Println(out)
}
Expand Down
5 changes: 3 additions & 2 deletions internal/model/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ func (a *API) ExampleGoCode() string {
exs = append(exs, o.Example())
}

code := fmt.Sprintf("import (\n%q\n%q\n%q\n%q\n\n%q\n%q\n%q\n)\n\n"+
code := fmt.Sprintf("import (\n%q\n%q\n%q\n\n%q\n%q\n%q\n%q\n)\n\n"+
"var _ time.Duration\nvar _ bytes.Buffer\n\n%s",
"bytes",
"fmt",
"github.com/awslabs/aws-sdk-go/aws",
"time",
"github.com/awslabs/aws-sdk-go/aws",
"github.com/awslabs/aws-sdk-go/aws/awserr",
"github.com/awslabs/aws-sdk-go/aws/awsutil",
"github.com/awslabs/aws-sdk-go/service/"+a.PackageName(),
Expand All @@ -310,6 +310,7 @@ func (a *API) ExampleGoCode() string {

// A tplInterface defines the template for the service interface type.
var tplInterface = template.Must(template.New("interface").Parse(`
// {{ .StructName }}API is the interface type for {{ .PackageName }}.{{ .StructName }}.
type {{ .StructName }}API interface {
{{ range $_, $o := .OperationList }}
{{ $o.InterfaceSignature }}
Expand Down
66 changes: 45 additions & 21 deletions internal/model/cli/gen-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"sync"

"github.com/awslabs/aws-sdk-go/internal/model/api"
"github.com/awslabs/aws-sdk-go/internal/util"
)

type generateInfo struct {
Expand Down Expand Up @@ -129,39 +130,62 @@ func main() {
w.Wait()
}

const codeLayout = `// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.
%s
package %s
%s
`

func writeGoFile(file string, layout string, args ...interface{}) error {
return ioutil.WriteFile(file, []byte(util.GoFmt(fmt.Sprintf(layout, args...))), 0664)
}

// writeExamplesFile writes out the service example file.
func (g *generateInfo) writeExamplesFile() {
file := filepath.Join(g.PackageDir, "examples_test.go")
ioutil.WriteFile(file, []byte("package "+g.API.PackageName()+"_test\n\n"+g.API.ExampleGoCode()+"\n"), 0664)
writeGoFile(filepath.Join(g.PackageDir, "examples_test.go"),
codeLayout,
"",
g.API.PackageName()+"_test",
g.API.ExampleGoCode(),
)
}

// writeServiceFile writes out the service initialization file.
func (g *generateInfo) writeServiceFile() {
file := filepath.Join(g.PackageDir, "service.go")
ioutil.WriteFile(file, []byte("package "+g.API.PackageName()+"\n\n"+g.API.ServiceGoCode()), 0664)
writeGoFile(filepath.Join(g.PackageDir, "service.go"),
codeLayout,
"",
g.API.PackageName(),
g.API.ServiceGoCode(),
)
}

// writeInterfaceFile writes out the service interface file.
func (g *generateInfo) writeInterfaceFile() {
file := filepath.Join(g.PackageDir, g.API.InterfacePackageName(), "interface.go")
ioutil.WriteFile(file, []byte(note+
"// Package "+g.API.InterfacePackageName()+" provides an interface that satisfies the "+g.API.PackageName()+" service.\n"+
"package "+g.API.InterfacePackageName()+"\n\n"+g.API.InterfaceGoCode()+"\n"), 0664)

// Also write test package
file = filepath.Join(g.PackageDir, g.API.InterfacePackageName(), "interface_test.go")
ioutil.WriteFile(file, []byte(note+
"package "+g.API.InterfacePackageName()+"_test\n\n"+g.API.InterfaceTestGoCode()+"\n"), 0664)
writeGoFile(filepath.Join(g.PackageDir, g.API.InterfacePackageName(), "interface.go"),
codeLayout,
fmt.Sprintf("\n// Package %s provides an interface for the %s.",
g.API.InterfacePackageName(), g.API.Metadata.ServiceFullName),
g.API.InterfacePackageName(),
g.API.InterfaceGoCode(),
)

writeGoFile(filepath.Join(g.PackageDir, g.API.InterfacePackageName(), "interface_test.go"),
codeLayout,
"",
g.API.InterfacePackageName()+"_test",
g.API.InterfaceTestGoCode(),
)
}

const note = "// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.\n\n"

// writeAPIFile writes out the service api file.
func (g *generateInfo) writeAPIFile() {
file := filepath.Join(g.PackageDir, "api.go")
pkg := g.API.PackageName()
code := fmt.Sprintf(note+
"// Package %s provides a client for %s.\n"+
"package %s\n\n%s", pkg, g.API.Metadata.ServiceFullName, pkg, g.API.APIGoCode()+"\n")
ioutil.WriteFile(file, []byte(code), 0664)
writeGoFile(filepath.Join(g.PackageDir, "api.go"),
codeLayout,
fmt.Sprintf("\n// Package %s provides a client for %s.",
g.API.PackageName(), g.API.Metadata.ServiceFullName),
g.API.PackageName(),
g.API.APIGoCode(),
)
}
3 changes: 2 additions & 1 deletion service/autoscaling/autoscalingiface/interface.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

// Package autoscalingiface provides an interface that satisfies the autoscaling service.
// Package autoscalingiface provides an interface for the Auto Scaling.
package autoscalingiface

import (
"github.com/awslabs/aws-sdk-go/service/autoscaling"
)

// AutoScalingAPI is the interface type for autoscaling.AutoScaling.
type AutoScalingAPI interface {
AttachInstances(*autoscaling.AttachInstancesInput) (*autoscaling.AttachInstancesOutput, error)

Expand Down
4 changes: 3 additions & 1 deletion service/autoscaling/examples_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package autoscaling_test

import (
"bytes"
"fmt"
"github.com/awslabs/aws-sdk-go/aws"
"time"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/aws/awserr"
"github.com/awslabs/aws-sdk-go/aws/awsutil"
"github.com/awslabs/aws-sdk-go/service/autoscaling"
Expand Down
2 changes: 2 additions & 0 deletions service/autoscaling/service.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package autoscaling

import (
Expand Down
3 changes: 2 additions & 1 deletion service/cloudformation/cloudformationiface/interface.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

// Package cloudformationiface provides an interface that satisfies the cloudformation service.
// Package cloudformationiface provides an interface for the AWS CloudFormation.
package cloudformationiface

import (
"github.com/awslabs/aws-sdk-go/service/cloudformation"
)

// CloudFormationAPI is the interface type for cloudformation.CloudFormation.
type CloudFormationAPI interface {
CancelUpdateStack(*cloudformation.CancelUpdateStackInput) (*cloudformation.CancelUpdateStackOutput, error)

Expand Down
4 changes: 3 additions & 1 deletion service/cloudformation/examples_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package cloudformation_test

import (
"bytes"
"fmt"
"github.com/awslabs/aws-sdk-go/aws"
"time"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/aws/awserr"
"github.com/awslabs/aws-sdk-go/aws/awsutil"
"github.com/awslabs/aws-sdk-go/service/cloudformation"
Expand Down
2 changes: 2 additions & 0 deletions service/cloudformation/service.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package cloudformation

import (
Expand Down
3 changes: 2 additions & 1 deletion service/cloudfront/cloudfrontiface/interface.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

// Package cloudfrontiface provides an interface that satisfies the cloudfront service.
// Package cloudfrontiface provides an interface for the Amazon CloudFront.
package cloudfrontiface

import (
"github.com/awslabs/aws-sdk-go/service/cloudfront"
)

// CloudFrontAPI is the interface type for cloudfront.CloudFront.
type CloudFrontAPI interface {
CreateCloudFrontOriginAccessIdentity(*cloudfront.CreateCloudFrontOriginAccessIdentityInput) (*cloudfront.CreateCloudFrontOriginAccessIdentityOutput, error)

Expand Down
4 changes: 3 additions & 1 deletion service/cloudfront/examples_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package cloudfront_test

import (
"bytes"
"fmt"
"github.com/awslabs/aws-sdk-go/aws"
"time"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/aws/awserr"
"github.com/awslabs/aws-sdk-go/aws/awsutil"
"github.com/awslabs/aws-sdk-go/service/cloudfront"
Expand Down
2 changes: 2 additions & 0 deletions service/cloudfront/service.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package cloudfront

import (
Expand Down
3 changes: 2 additions & 1 deletion service/cloudhsm/cloudhsmiface/interface.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

// Package cloudhsmiface provides an interface that satisfies the cloudhsm service.
// Package cloudhsmiface provides an interface for the Amazon CloudHSM.
package cloudhsmiface

import (
"github.com/awslabs/aws-sdk-go/service/cloudhsm"
)

// CloudHSMAPI is the interface type for cloudhsm.CloudHSM.
type CloudHSMAPI interface {
CreateHAPG(*cloudhsm.CreateHAPGInput) (*cloudhsm.CreateHAPGOutput, error)

Expand Down
4 changes: 3 additions & 1 deletion service/cloudhsm/examples_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package cloudhsm_test

import (
"bytes"
"fmt"
"github.com/awslabs/aws-sdk-go/aws"
"time"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/aws/awserr"
"github.com/awslabs/aws-sdk-go/aws/awsutil"
"github.com/awslabs/aws-sdk-go/service/cloudhsm"
Expand Down
2 changes: 2 additions & 0 deletions service/cloudhsm/service.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package cloudhsm

import (
Expand Down
3 changes: 2 additions & 1 deletion service/cloudsearch/cloudsearchiface/interface.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

// Package cloudsearchiface provides an interface that satisfies the cloudsearch service.
// Package cloudsearchiface provides an interface for the Amazon CloudSearch.
package cloudsearchiface

import (
"github.com/awslabs/aws-sdk-go/service/cloudsearch"
)

// CloudSearchAPI is the interface type for cloudsearch.CloudSearch.
type CloudSearchAPI interface {
BuildSuggesters(*cloudsearch.BuildSuggestersInput) (*cloudsearch.BuildSuggestersOutput, error)

Expand Down
4 changes: 3 additions & 1 deletion service/cloudsearch/examples_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package cloudsearch_test

import (
"bytes"
"fmt"
"github.com/awslabs/aws-sdk-go/aws"
"time"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/aws/awserr"
"github.com/awslabs/aws-sdk-go/aws/awsutil"
"github.com/awslabs/aws-sdk-go/service/cloudsearch"
Expand Down
2 changes: 2 additions & 0 deletions service/cloudsearch/service.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package cloudsearch

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

// Package cloudsearchdomainiface provides an interface that satisfies the cloudsearchdomain service.
// Package cloudsearchdomainiface provides an interface for the Amazon CloudSearch Domain.
package cloudsearchdomainiface

import (
"github.com/awslabs/aws-sdk-go/service/cloudsearchdomain"
)

// CloudSearchDomainAPI is the interface type for cloudsearchdomain.CloudSearchDomain.
type CloudSearchDomainAPI interface {
Search(*cloudsearchdomain.SearchInput) (*cloudsearchdomain.SearchOutput, error)

Expand Down
4 changes: 3 additions & 1 deletion service/cloudsearchdomain/examples_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package cloudsearchdomain_test

import (
"bytes"
"fmt"
"github.com/awslabs/aws-sdk-go/aws"
"time"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/aws/awserr"
"github.com/awslabs/aws-sdk-go/aws/awsutil"
"github.com/awslabs/aws-sdk-go/service/cloudsearchdomain"
Expand Down
2 changes: 2 additions & 0 deletions service/cloudsearchdomain/service.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package cloudsearchdomain

import (
Expand Down
3 changes: 2 additions & 1 deletion service/cloudtrail/cloudtrailiface/interface.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

// Package cloudtrailiface provides an interface that satisfies the cloudtrail service.
// Package cloudtrailiface provides an interface for the AWS CloudTrail.
package cloudtrailiface

import (
"github.com/awslabs/aws-sdk-go/service/cloudtrail"
)

// CloudTrailAPI is the interface type for cloudtrail.CloudTrail.
type CloudTrailAPI interface {
CreateTrail(*cloudtrail.CreateTrailInput) (*cloudtrail.CreateTrailOutput, error)

Expand Down
4 changes: 3 additions & 1 deletion service/cloudtrail/examples_test.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package cloudtrail_test

import (
"bytes"
"fmt"
"github.com/awslabs/aws-sdk-go/aws"
"time"

"github.com/awslabs/aws-sdk-go/aws"
"github.com/awslabs/aws-sdk-go/aws/awserr"
"github.com/awslabs/aws-sdk-go/aws/awsutil"
"github.com/awslabs/aws-sdk-go/service/cloudtrail"
Expand Down
2 changes: 2 additions & 0 deletions service/cloudtrail/service.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

package cloudtrail

import (
Expand Down
3 changes: 2 additions & 1 deletion service/cloudwatch/cloudwatchiface/interface.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT.

// Package cloudwatchiface provides an interface that satisfies the cloudwatch service.
// Package cloudwatchiface provides an interface for the Amazon CloudWatch.
package cloudwatchiface

import (
"github.com/awslabs/aws-sdk-go/service/cloudwatch"
)

// CloudWatchAPI is the interface type for cloudwatch.CloudWatch.
type CloudWatchAPI interface {
DeleteAlarms(*cloudwatch.DeleteAlarmsInput) (*cloudwatch.DeleteAlarmsOutput, error)

Expand Down
Loading

0 comments on commit 8dbe47a

Please sign in to comment.