From d5c6ebff3dd106f5598062c01452b63076ddde2d Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Mon, 25 Feb 2019 14:32:55 +0100 Subject: [PATCH] gomod: update go-tfe --- go.mod | 2 +- go.sum | 4 +- .../hashicorp/go-tfe/organization.go | 17 +++++++- vendor/github.com/hashicorp/go-tfe/run.go | 14 +++++-- vendor/github.com/hashicorp/go-tfe/tfe.go | 8 ++-- .../github.com/hashicorp/go-tfe/workspace.go | 41 +++++++++++++++++++ vendor/modules.txt | 2 +- 7 files changed, 75 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index fc684b93c..7a81f0266 100644 --- a/go.mod +++ b/go.mod @@ -59,7 +59,7 @@ require ( github.com/hashicorp/go-retryablehttp v0.5.1 github.com/hashicorp/go-rootcerts v1.0.0 github.com/hashicorp/go-sockaddr v0.0.0-20180320115054-6d291a969b86 // indirect - github.com/hashicorp/go-tfe v0.3.8 + github.com/hashicorp/go-tfe v0.3.10 github.com/hashicorp/go-uuid v1.0.0 github.com/hashicorp/go-version v1.1.0 github.com/hashicorp/golang-lru v0.5.0 // indirect diff --git a/go.sum b/go.sum index 0c1f6c333..54a4cbc4d 100644 --- a/go.sum +++ b/go.sum @@ -187,8 +187,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-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-tfe v0.3.8 h1:pUqxmnhZ7Dj3biugEEo2oGZ758zVQy70lx8p7p4JREY= -github.com/hashicorp/go-tfe v0.3.8/go.mod h1:LHLchj07PCYgQqcyE5Sz+g4zrMNW+nALKbiSNTZedEs= +github.com/hashicorp/go-tfe v0.3.10 h1:6uPnPHNPxXDe3k/Vt6fovygYTaWJ8f/7zdHc++f7NJU= +github.com/hashicorp/go-tfe v0.3.10/go.mod h1:LHLchj07PCYgQqcyE5Sz+g4zrMNW+nALKbiSNTZedEs= 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-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0= diff --git a/vendor/github.com/hashicorp/go-tfe/organization.go b/vendor/github.com/hashicorp/go-tfe/organization.go index 2925b52c6..e3a14f697 100644 --- a/vendor/github.com/hashicorp/go-tfe/organization.go +++ b/vendor/github.com/hashicorp/go-tfe/organization.go @@ -80,7 +80,7 @@ type Organization struct { CreatedAt time.Time `jsonapi:"attr,created-at,iso8601"` Email string `jsonapi:"attr,email"` EnterprisePlan EnterprisePlanType `jsonapi:"attr,enterprise-plan"` - OwnersTeamSamlRoleID string `jsonapi:"attr,owners-team-saml-role-id"` + OwnersTeamSAMLRoleID string `jsonapi:"attr,owners-team-saml-role-id"` Permissions *OrganizationPermissions `jsonapi:"attr,permissions"` SAMLEnabled bool `jsonapi:"attr,saml-enabled"` SessionRemember int `jsonapi:"attr,session-remember"` @@ -157,6 +157,18 @@ type OrganizationCreateOptions struct { // Admin email address. Email *string `jsonapi:"attr,email"` + + // Session expiration (minutes). + SessionRemember *int `jsonapi:"attr,session-remember,omitempty"` + + // Session timeout after inactivity (minutes). + SessionTimeout *int `jsonapi:"attr,session-timeout,omitempty"` + + // Authentication policy. + CollaboratorAuthPolicy *AuthPolicyType `jsonapi:"attr,collaborator-auth-policy,omitempty"` + + // The name of the "owners" team + OwnersTeamSAMLRoleID *string `jsonapi:"attr,owners-team-saml-role-id,omitempty"` } func (o OrganizationCreateOptions) valid() error { @@ -235,6 +247,9 @@ type OrganizationUpdateOptions struct { // Authentication policy. CollaboratorAuthPolicy *AuthPolicyType `jsonapi:"attr,collaborator-auth-policy,omitempty"` + + // The name of the "owners" team + OwnersTeamSAMLRoleID *string `jsonapi:"attr,owners-team-saml-role-id,omitempty"` } // Update attributes of an existing organization. diff --git a/vendor/github.com/hashicorp/go-tfe/run.go b/vendor/github.com/hashicorp/go-tfe/run.go index b310bf600..58528739b 100644 --- a/vendor/github.com/hashicorp/go-tfe/run.go +++ b/vendor/github.com/hashicorp/go-tfe/run.go @@ -122,10 +122,16 @@ type RunPermissions struct { // RunStatusTimestamps holds the timestamps for individual run statuses. type RunStatusTimestamps struct { - ErroredAt time.Time `json:"errored-at"` - FinishedAt time.Time `json:"finished-at"` - QueuedAt time.Time `json:"queued-at"` - StartedAt time.Time `json:"started-at"` + ErroredAt time.Time `json:"errored-at"` + FinishedAt time.Time `json:"finished-at"` + QueuedAt time.Time `json:"queued-at"` + StartedAt time.Time `json:"started-at"` + ApplyingAt time.Time `json:"applying-at"` + AppliedAt time.Time `json:"applied-at"` + PlanningAt time.Time `json:"planning-at"` + PlannedAt time.Time `json:"planned-at"` + PlannedAndFinishedAt time.Time `json:"planned-and-finished-at"` + PlanQueuabledAt time.Time `json:"plan-queueable-at"` } // RunListOptions represents the options for listing runs. diff --git a/vendor/github.com/hashicorp/go-tfe/tfe.go b/vendor/github.com/hashicorp/go-tfe/tfe.go index b06c1ea0a..a1adf510f 100644 --- a/vendor/github.com/hashicorp/go-tfe/tfe.go +++ b/vendor/github.com/hashicorp/go-tfe/tfe.go @@ -35,9 +35,6 @@ const ( ) var ( - // random is used to generate pseudo-random numbers. - random = rand.New(rand.NewSource(time.Now().UnixNano())) - // ErrWorkspaceLocked is returned when trying to lock a // locked workspace. ErrWorkspaceLocked = errors.New("workspace already locked") @@ -232,8 +229,11 @@ func rateLimitRetry(ctx context.Context, resp *http.Response, err error) (bool, // the reset time retrieved from the headers. But if the final wait time is // less then min, min will be used instead. func rateLimitBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration { + // rnd is used to generate pseudo-random numbers. + rnd := rand.New(rand.NewSource(time.Now().UnixNano())) + // First create some jitter bounded by the min and max durations. - jitter := time.Duration(rand.Float64() * float64(max-min)) + jitter := time.Duration(rnd.Float64() * float64(max-min)) if resp != nil { if v := resp.Header.Get(headerRateReset); v != "" { diff --git a/vendor/github.com/hashicorp/go-tfe/workspace.go b/vendor/github.com/hashicorp/go-tfe/workspace.go index 2385a9460..7b95ac132 100644 --- a/vendor/github.com/hashicorp/go-tfe/workspace.go +++ b/vendor/github.com/hashicorp/go-tfe/workspace.go @@ -31,6 +31,9 @@ type Workspaces interface { // Delete a workspace by its name. Delete(ctx context.Context, organization string, workspace string) error + // RemoveVCSConnection from a workspace. + RemoveVCSConnection(ctx context.Context, organization, workspace string) (*Workspace, error) + // Lock a workspace by its ID. Lock(ctx context.Context, workspaceID string, options WorkspaceLockOptions) (*Workspace, error) @@ -98,10 +101,13 @@ type WorkspaceActions struct { // WorkspacePermissions represents the workspace permissions. type WorkspacePermissions struct { CanDestroy bool `json:"can-destroy"` + CanForceUnlock bool `json:"can-force-unlock"` CanLock bool `json:"can-lock"` + CanQueueApply bool `json:"can-queue-apply"` CanQueueDestroy bool `json:"can-queue-destroy"` CanQueueRun bool `json:"can-queue-run"` CanReadSettings bool `json:"can-read-settings"` + CanUnlock bool `json:"can-unlock"` CanUpdate bool `json:"can-update"` CanUpdateVariable bool `json:"can-update-variable"` } @@ -333,6 +339,41 @@ func (s *workspaces) Delete(ctx context.Context, organization, workspace string) return s.client.do(ctx, req, nil) } +// workspaceRemoveVCSConnectionOptions +type workspaceRemoveVCSConnectionOptions struct { + ID string `jsonapi:"primary,workspaces"` + VCSRepo *VCSRepoOptions `jsonapi:"attr,vcs-repo"` +} + +// RemoveVCSConnection from a workspace. +func (s *workspaces) RemoveVCSConnection(ctx context.Context, organization, workspace string) (*Workspace, error) { + if !validStringID(&organization) { + return nil, errors.New("invalid value for organization") + } + if !validStringID(&workspace) { + return nil, errors.New("invalid value for workspace") + } + + u := fmt.Sprintf( + "organizations/%s/workspaces/%s", + url.QueryEscape(organization), + url.QueryEscape(workspace), + ) + + req, err := s.client.newRequest("PATCH", u, &workspaceRemoveVCSConnectionOptions{}) + if err != nil { + return nil, err + } + + w := &Workspace{} + err = s.client.do(ctx, req, w) + if err != nil { + return nil, err + } + + return w, nil +} + // WorkspaceLockOptions represents the options for locking a workspace. type WorkspaceLockOptions struct { // Specifies the reason for locking the workspace. diff --git a/vendor/modules.txt b/vendor/modules.txt index 3808504cc..abc252f8d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -290,7 +290,7 @@ github.com/hashicorp/go-rootcerts github.com/hashicorp/go-safetemp # github.com/hashicorp/go-slug v0.2.0 github.com/hashicorp/go-slug -# github.com/hashicorp/go-tfe v0.3.8 +# github.com/hashicorp/go-tfe v0.3.10 github.com/hashicorp/go-tfe # github.com/hashicorp/go-uuid v1.0.0 github.com/hashicorp/go-uuid