diff --git a/cmd/workspace_show/main.go b/cmd/workspace_show/main.go new file mode 100644 index 000000000..26a7036f2 --- /dev/null +++ b/cmd/workspace_show/main.go @@ -0,0 +1,44 @@ +package main + +import ( + "context" + "flag" + "fmt" + "os" + + "github.com/davecgh/go-spew/spew" + "github.com/hashicorp/go-tfe" +) + +var ( + token, + baseAddress string +) + +func init() { + const defaultAddress = "https://staging-app.terraform.io" + flag.StringVar(&baseAddress, "base_address", defaultAddress, "tf env base address.") + flag.StringVar(&token, "token", "", "tf token.") +} + +func main() { + flag.Parse() + if len(flag.Args()) != 2 { + fmt.Fprint(os.Stderr, + "usage: workspace_show \nflags:\n", + ) + flag.PrintDefaults() + os.Exit(1) + } + + cfg := &tfe.Config{ + Address: baseAddress, + Token: token, + } + client, err := tfe.NewClient(cfg) + if err != nil { + panic(err) + } + + spew.Dump(client.Workspaces.Read(context.Background(), flag.Arg(0), flag.Arg(1))) +} diff --git a/workspace.go b/workspace.go index 7f133728b..8623f88a4 100644 --- a/workspace.go +++ b/workspace.go @@ -363,8 +363,8 @@ func (s *workspaces) Read(ctx context.Context, organization, workspace string) ( } // durations come over in ms - w.ApplyDurationAverage *= (time.Second / time.Millisecond) - w.PlanDurationAverage *= (time.Second / time.Millisecond) + w.ApplyDurationAverage *= time.Millisecond + w.PlanDurationAverage *= time.Millisecond return w, nil } @@ -402,8 +402,8 @@ func (s *workspaces) ReadByID(ctx context.Context, workspaceID string) (*Workspa } // durations come over in ms - w.ApplyDurationAverage *= (time.Second / time.Millisecond) - w.PlanDurationAverage *= (time.Second / time.Millisecond) + w.ApplyDurationAverage *= time.Millisecond + w.PlanDurationAverage *= time.Millisecond return w, nil } @@ -412,7 +412,7 @@ func (s *workspaces) ReadByID(ctx context.Context, workspaceID string) (*Workspa type WorkspaceUpdateOptions struct { // Type is a public field utilized by JSON:API to // set the resource type via the field tag. - // It is not a user-defined value and does not need to be set. + // It is not a user-defined value and / time.Nanosecond)not need to be set. // https://jsonapi.org/format/#crud-creating Type string `jsonapi:"primary,workspaces"`