This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#20 update vendor to support auto ECR login if AWS creds are set
- Loading branch information
Yuriy Bogdanov
committed
Jan 12, 2016
1 parent
aca5dc7
commit c4e9569
Showing
103 changed files
with
11,162 additions
and
4,939 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
116 changes: 116 additions & 0 deletions
116
vendor/src/github.com/aws/aws-sdk-go/awsmigrate/awsmigrate-renamer/rename/rename14.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// +build !go1.5 | ||
|
||
package rename | ||
|
||
import ( | ||
"bytes" | ||
"flag" | ||
"fmt" | ||
"go/format" | ||
"go/parser" | ||
"go/token" | ||
"io/ioutil" | ||
|
||
"golang.org/x/tools/go/loader" | ||
"golang.org/x/tools/go/types" | ||
) | ||
|
||
var dryRun = flag.Bool("dryrun", false, "Dry run") | ||
var verbose = flag.Bool("verbose", false, "Verbose") | ||
|
||
type packageRenames struct { | ||
operations map[string]string | ||
shapes map[string]string | ||
fields map[string]string | ||
} | ||
|
||
type renamer struct { | ||
*loader.Program | ||
files map[*token.File]bool | ||
} | ||
|
||
// ParsePathsFromArgs parses arguments from command line and looks at import | ||
// paths to rename objects. | ||
func ParsePathsFromArgs() { | ||
flag.Parse() | ||
for _, dir := range flag.Args() { | ||
var conf loader.Config | ||
conf.ParserMode = parser.ParseComments | ||
conf.ImportWithTests(dir) | ||
prog, err := conf.Load() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
r := renamer{prog, map[*token.File]bool{}} | ||
r.parse() | ||
if !*dryRun { | ||
r.write() | ||
} | ||
} | ||
} | ||
|
||
func (r *renamer) dryInfo() string { | ||
if *dryRun { | ||
return "[DRY-RUN]" | ||
} | ||
return "[!]" | ||
} | ||
|
||
func (r *renamer) printf(msg string, args ...interface{}) { | ||
if *verbose { | ||
fmt.Printf(msg, args...) | ||
} | ||
} | ||
|
||
func (r *renamer) parse() { | ||
for _, pkg := range r.InitialPackages() { | ||
r.parseUses(pkg) | ||
} | ||
} | ||
|
||
func (r *renamer) write() { | ||
for _, pkg := range r.InitialPackages() { | ||
for _, f := range pkg.Files { | ||
tokenFile := r.Fset.File(f.Pos()) | ||
if r.files[tokenFile] { | ||
var buf bytes.Buffer | ||
format.Node(&buf, r.Fset, f) | ||
if err := ioutil.WriteFile(tokenFile.Name(), buf.Bytes(), 0644); err != nil { | ||
panic(err) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
func (r *renamer) parseUses(pkg *loader.PackageInfo) { | ||
for k, v := range pkg.Uses { | ||
if v.Pkg() != nil { | ||
pkgPath := v.Pkg().Path() | ||
if renames, ok := renamedPackages[pkgPath]; ok { | ||
name := k.Name | ||
switch t := v.(type) { | ||
case *types.Func: | ||
if newName, ok := renames.operations[t.Name()]; ok && newName != name { | ||
r.printf("%s Rename [OPERATION]: %q -> %q\n", r.dryInfo(), name, newName) | ||
r.files[r.Fset.File(k.Pos())] = true | ||
k.Name = newName | ||
} | ||
case *types.TypeName: | ||
if newName, ok := renames.shapes[name]; ok && newName != name { | ||
r.printf("%s Rename [SHAPE]: %q -> %q\n", r.dryInfo(), t.Name(), newName) | ||
r.files[r.Fset.File(k.Pos())] = true | ||
k.Name = newName | ||
} | ||
case *types.Var: | ||
if newName, ok := renames.fields[name]; ok && newName != name { | ||
r.printf("%s Rename [FIELD]: %q -> %q\n", r.dryInfo(), t.Name(), newName) | ||
r.files[r.Fset.File(k.Pos())] = true | ||
k.Name = newName | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.