Skip to content

Commit

Permalink
Merge pull request #8 from rightscale/PHX-1514_wrong_hostname_message
Browse files Browse the repository at this point in the history
PHX-1514 Correct hostname error message
  • Loading branch information
psschroeter authored Mar 13, 2019
2 parents e6b71d7 + 3c92f21 commit f3993ac
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ vendor/
version.go
version.yml
build
/right_pt
/fpt
*.coverprofile
*.bak
*.old
Expand Down
5 changes: 5 additions & 0 deletions cmd/fpt/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion cmd/fpt/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions cmd/fpt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions cmd/fpt/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"strings"

"github.com/rightscale/policy_sdk/client/policy"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f3993ac

Please sign in to comment.