Merge pull request #20316 from hashicorp/vendor-go-tfe-bump
vendor: github.com/hashicorp/go-tfe@v0.3.8
This commit is contained in:
commit
8f3ee1800d
2
go.mod
2
go.mod
|
@ -60,7 +60,7 @@ require (
|
||||||
github.com/hashicorp/go-retryablehttp v0.5.1
|
github.com/hashicorp/go-retryablehttp v0.5.1
|
||||||
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90
|
github.com/hashicorp/go-rootcerts v0.0.0-20160503143440-6bb64b370b90
|
||||||
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86 // indirect
|
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86 // indirect
|
||||||
github.com/hashicorp/go-tfe v0.3.7
|
github.com/hashicorp/go-tfe v0.3.8
|
||||||
github.com/hashicorp/go-uuid v1.0.0
|
github.com/hashicorp/go-uuid v1.0.0
|
||||||
github.com/hashicorp/go-version v1.0.0
|
github.com/hashicorp/go-version v1.0.0
|
||||||
github.com/hashicorp/golang-lru v0.5.0 // indirect
|
github.com/hashicorp/golang-lru v0.5.0 // indirect
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -162,8 +162,8 @@ github.com/hashicorp/go-slug v0.2.0 h1:MVdZAkTmDsUi1AT+3NQDsn8n3ssnVSIHwiM6RcUHv
|
||||||
github.com/hashicorp/go-slug v0.2.0/go.mod h1:+zDycQOzGqOqMW7Kn2fp9vz/NtqpMLQlgb9JUF+0km4=
|
github.com/hashicorp/go-slug v0.2.0/go.mod h1:+zDycQOzGqOqMW7Kn2fp9vz/NtqpMLQlgb9JUF+0km4=
|
||||||
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86 h1:7YOlAIO2YWnJZkQp7B5eFykaIY7C9JndqAFQyVV5BhM=
|
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86 h1:7YOlAIO2YWnJZkQp7B5eFykaIY7C9JndqAFQyVV5BhM=
|
||||||
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU=
|
||||||
github.com/hashicorp/go-tfe v0.3.7 h1:YTL4qVxuQ9mRUnGrxXN3dlil7IugxyDOiOkUQANH6fg=
|
github.com/hashicorp/go-tfe v0.3.8 h1:pUqxmnhZ7Dj3biugEEo2oGZ758zVQy70lx8p7p4JREY=
|
||||||
github.com/hashicorp/go-tfe v0.3.7/go.mod h1:LHLchj07PCYgQqcyE5Sz+g4zrMNW+nALKbiSNTZedEs=
|
github.com/hashicorp/go-tfe v0.3.8/go.mod h1:LHLchj07PCYgQqcyE5Sz+g4zrMNW+nALKbiSNTZedEs=
|
||||||
github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM=
|
github.com/hashicorp/go-uuid v1.0.0 h1:RS8zrF7PhGwyNPOtxSClXXj9HA8feRnJzgnI1RJCSnM=
|
||||||
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||||
github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8=
|
github.com/hashicorp/go-version v1.0.0 h1:21MVWPKDphxa7ineQQTrCU5brh7OuVVAzGOCnnCPtE8=
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
slug "github.com/hashicorp/go-slug"
|
slug "github.com/hashicorp/go-slug"
|
||||||
|
@ -183,9 +184,17 @@ func (s *configurationVersions) Read(ctx context.Context, cvID string) (*Configu
|
||||||
// upload URL from a configuration version and the path to the configuration
|
// upload URL from a configuration version and the path to the configuration
|
||||||
// files on disk.
|
// files on disk.
|
||||||
func (s *configurationVersions) Upload(ctx context.Context, url, path string) error {
|
func (s *configurationVersions) Upload(ctx context.Context, url, path string) error {
|
||||||
|
file, err := os.Stat(path)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if !file.Mode().IsDir() {
|
||||||
|
return errors.New("path needs to be an existing directory")
|
||||||
|
}
|
||||||
|
|
||||||
body := bytes.NewBuffer(nil)
|
body := bytes.NewBuffer(nil)
|
||||||
|
|
||||||
_, err := slug.Pack(path, body, true)
|
_, err = slug.Pack(path, body, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,9 @@ type Teams interface {
|
||||||
// Read a team by its ID.
|
// Read a team by its ID.
|
||||||
Read(ctx context.Context, teamID string) (*Team, error)
|
Read(ctx context.Context, teamID string) (*Team, error)
|
||||||
|
|
||||||
|
// Update a team by its ID.
|
||||||
|
Update(ctx context.Context, teamID string, options TeamUpdateOptions) (*Team, error)
|
||||||
|
|
||||||
// Delete a team by its ID.
|
// Delete a team by its ID.
|
||||||
Delete(ctx context.Context, teamID string) error
|
Delete(ctx context.Context, teamID string) error
|
||||||
}
|
}
|
||||||
|
@ -41,16 +44,24 @@ type TeamList struct {
|
||||||
|
|
||||||
// Team represents a Terraform Enterprise team.
|
// Team represents a Terraform Enterprise team.
|
||||||
type Team struct {
|
type Team struct {
|
||||||
ID string `jsonapi:"primary,teams"`
|
ID string `jsonapi:"primary,teams"`
|
||||||
Name string `jsonapi:"attr,name"`
|
Name string `jsonapi:"attr,name"`
|
||||||
Permissions *TeamPermissions `jsonapi:"attr,permissions"`
|
OrganizationAccess *OrganizationAccess `jsonapi:"attr,organization-access"`
|
||||||
UserCount int `jsonapi:"attr,users-count"`
|
Permissions *TeamPermissions `jsonapi:"attr,permissions"`
|
||||||
|
UserCount int `jsonapi:"attr,users-count"`
|
||||||
|
|
||||||
// Relations
|
// Relations
|
||||||
Users []*User `jsonapi:"relation,users"`
|
Users []*User `jsonapi:"relation,users"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TeamPermissions represents the team permissions.
|
// OrganizationAccess represents the team's permissions on its organization
|
||||||
|
type OrganizationAccess struct {
|
||||||
|
ManagePolicies bool `json:"manage-policies"`
|
||||||
|
ManageWorkspaces bool `json:"manage-workspaces"`
|
||||||
|
ManageVCSSettings bool `json:"manage-vcs-settings"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TeamPermissions represents the current user's permissions on the team.
|
||||||
type TeamPermissions struct {
|
type TeamPermissions struct {
|
||||||
CanDestroy bool `json:"can-destroy"`
|
CanDestroy bool `json:"can-destroy"`
|
||||||
CanUpdateMembership bool `json:"can-update-membership"`
|
CanUpdateMembership bool `json:"can-update-membership"`
|
||||||
|
@ -89,15 +100,22 @@ type TeamCreateOptions struct {
|
||||||
|
|
||||||
// Name of the team.
|
// Name of the team.
|
||||||
Name *string `jsonapi:"attr,name"`
|
Name *string `jsonapi:"attr,name"`
|
||||||
|
|
||||||
|
// The team's organization access
|
||||||
|
OrganizationAccess *OrganizationAccessOptions `jsonapi:"attr,organization-access,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrganizationAccessOptions represents the organization access options of a team.
|
||||||
|
type OrganizationAccessOptions struct {
|
||||||
|
ManagePolicies *bool `json:"manage-policies,omitempty"`
|
||||||
|
ManageWorkspaces *bool `json:"manage-workspaces,omitempty"`
|
||||||
|
ManageVCSSettings *bool `json:"manage-vcs-settings,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o TeamCreateOptions) valid() error {
|
func (o TeamCreateOptions) valid() error {
|
||||||
if !validString(o.Name) {
|
if !validString(o.Name) {
|
||||||
return errors.New("name is required")
|
return errors.New("name is required")
|
||||||
}
|
}
|
||||||
if !validStringID(o.Name) {
|
|
||||||
return errors.New("invalid value for name")
|
|
||||||
}
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,6 +167,42 @@ func (s *teams) Read(ctx context.Context, teamID string) (*Team, error) {
|
||||||
return t, nil
|
return t, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TeamUpdateOptions represents the options for updating a team.
|
||||||
|
type TeamUpdateOptions struct {
|
||||||
|
// For internal use only!
|
||||||
|
ID string `jsonapi:"primary,teams"`
|
||||||
|
|
||||||
|
// New name for the team
|
||||||
|
Name *string `jsonapi:"attr,name,omitempty"`
|
||||||
|
|
||||||
|
// The team's organization access
|
||||||
|
OrganizationAccess *OrganizationAccessOptions `jsonapi:"attr,organization-access,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update a team by its ID.
|
||||||
|
func (s *teams) Update(ctx context.Context, teamID string, options TeamUpdateOptions) (*Team, error) {
|
||||||
|
if !validStringID(&teamID) {
|
||||||
|
return nil, errors.New("invalid value for team ID")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure we don't send a user provided ID.
|
||||||
|
options.ID = ""
|
||||||
|
|
||||||
|
u := fmt.Sprintf("teams/%s", url.QueryEscape(teamID))
|
||||||
|
req, err := s.client.newRequest("PATCH", u, &options)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
t := &Team{}
|
||||||
|
err = s.client.do(ctx, req, t)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return t, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Delete a team by its ID.
|
// Delete a team by its ID.
|
||||||
func (s *teams) Delete(ctx context.Context, teamID string) error {
|
func (s *teams) Delete(ctx context.Context, teamID string) error {
|
||||||
if !validStringID(&teamID) {
|
if !validStringID(&teamID) {
|
||||||
|
|
|
@ -251,13 +251,8 @@ func rateLimitBackoff(min, max time.Duration, attemptNum int, resp *http.Respons
|
||||||
|
|
||||||
// configureLimiter configures the rate limiter.
|
// configureLimiter configures the rate limiter.
|
||||||
func (c *Client) configureLimiter() error {
|
func (c *Client) configureLimiter() error {
|
||||||
u, err := c.baseURL.Parse("/")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new request.
|
// Create a new request.
|
||||||
req, err := http.NewRequest("GET", u.String(), nil)
|
req, err := http.NewRequest("GET", c.baseURL.String(), nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -266,6 +261,7 @@ func (c *Client) configureLimiter() error {
|
||||||
for k, v := range c.headers {
|
for k, v := range c.headers {
|
||||||
req.Header[k] = v
|
req.Header[k] = v
|
||||||
}
|
}
|
||||||
|
req.Header.Set("Accept", "application/vnd.api+json")
|
||||||
|
|
||||||
// Make a single request to retrieve the rate limit headers.
|
// Make a single request to retrieve the rate limit headers.
|
||||||
resp, err := c.http.HTTPClient.Do(req)
|
resp, err := c.http.HTTPClient.Do(req)
|
||||||
|
|
|
@ -400,7 +400,7 @@ github.com/hashicorp/go-rootcerts
|
||||||
github.com/hashicorp/go-safetemp
|
github.com/hashicorp/go-safetemp
|
||||||
# github.com/hashicorp/go-slug v0.2.0
|
# github.com/hashicorp/go-slug v0.2.0
|
||||||
github.com/hashicorp/go-slug
|
github.com/hashicorp/go-slug
|
||||||
# github.com/hashicorp/go-tfe v0.3.7
|
# github.com/hashicorp/go-tfe v0.3.8
|
||||||
github.com/hashicorp/go-tfe
|
github.com/hashicorp/go-tfe
|
||||||
# github.com/hashicorp/go-uuid v1.0.0
|
# github.com/hashicorp/go-uuid v1.0.0
|
||||||
github.com/hashicorp/go-uuid
|
github.com/hashicorp/go-uuid
|
||||||
|
|
Loading…
Reference in New Issue