diff --git a/.gitignore b/.gitignore index cb094cd..694388c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ vendor/ version.go version.yml build -/right_pt +/fpt *.coverprofile *.bak *.old diff --git a/cmd/fpt/ChangeLog.md b/cmd/fpt/ChangeLog.md index 7a0b536..c24d897 100644 --- a/cmd/fpt/ChangeLog.md +++ b/cmd/fpt/ChangeLog.md @@ -1,3 +1,8 @@ +v1.0.3 / 2019-03-14 +------------------- +* Fix errors for bad hostname in config. +* Fix bad_request error for template in subdirectories. + v1.0.2 / 2019-02-15 ------------------- * Add way to past list param to script command diff --git a/cmd/fpt/check.go b/cmd/fpt/check.go index 57c1fc7..f0f4403 100644 --- a/cmd/fpt/check.go +++ b/cmd/fpt/check.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "github.com/rightscale/policy_sdk/client/policy" policytemplate "github.com/rightscale/policy_sdk/sdk/policy_template" @@ -35,7 +36,7 @@ func doCheck(ctx context.Context, cli policy.Client, file string) error { return err } - err = cli.CompilePolicyTemplate(ctx, file, string(srcBytes)) + err = cli.CompilePolicyTemplate(ctx, filepath.Base(file), string(srcBytes)) if err != nil { printCompileError(err) diff --git a/cmd/fpt/main.go b/cmd/fpt/main.go index 4195898..1ed047c 100644 --- a/cmd/fpt/main.go +++ b/cmd/fpt/main.go @@ -96,10 +96,15 @@ func main() { err := config.ReadConfig(*configFile, *account) var client policy.Client if !strings.HasPrefix(command, "config") && !strings.HasPrefix(command, "update") { - acct := config.Config.Account // Makes sure the config file structure is valid if err != nil { - fatalError("%s: Error reading config file: %s\n", filepath.Base(os.Args[0]), err.Error()) + fatalError("%s: error reading config file: %s\n", *configFile, err.Error()) + } + + acct := config.Config.Account + err := acct.Validate() + if err != nil { + fatalError("%s: invalid config: %s\n", *configFile, err.Error()) } ts, err := auth.NewOAuthAuthenticator(acct.AuthHost(), acct.RefreshToken) diff --git a/cmd/fpt/upload.go b/cmd/fpt/upload.go index 6984d8a..5f8082f 100644 --- a/cmd/fpt/upload.go +++ b/cmd/fpt/upload.go @@ -5,6 +5,7 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" "strings" "github.com/rightscale/policy_sdk/client/policy" @@ -35,11 +36,11 @@ func doUpload(ctx context.Context, cli policy.Client, file string) (*policytempl return nil, err } - pt, err := cli.UploadPolicyTemplate(ctx, file, string(srcBytes)) + pt, err := cli.UploadPolicyTemplate(ctx, filepath.Base(file), string(srcBytes)) verb := "Created" if err != nil && errorName(err) == "conflict" { errTyped := err.(*policytemplate.ConflictError) - pt, err = cli.UpdatePolicyTemplate(ctx, idFromHref(errTyped.Location), file, string(srcBytes)) + pt, err = cli.UpdatePolicyTemplate(ctx, idFromHref(errTyped.Location), filepath.Base(file), string(srcBytes)) verb = "Updated" } if err != nil {