Skip to content

Commit

Permalink
Add new workspace fields
Browse files Browse the repository at this point in the history
  • Loading branch information
mwhooker committed Mar 10, 2021
1 parent 862478c commit 1dd9469
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ type Workspace struct {
TriggerPrefixes []string `jsonapi:"attr,trigger-prefixes"`
VCSRepo *VCSRepo `jsonapi:"attr,vcs-repo"`
WorkingDirectory string `jsonapi:"attr,working-directory"`
UpdatedAt time.Time `jsonapi:"attr,updated-at,iso8601"`
ResourceCount int `jsonapi:"attr,resource-count"`
Readme string `jsonapi:"attr,readme"`
ApplyDurationAverage time.Duration `jsonapi:"attr,apply-duration-average"`
PlanDurationAverage time.Duration `jsonapi:"attr,plan-duration-average"`
PolicyCheckFailures int `jsonapi:"attr,policy-check-failures"`
RunFailures int `jsonapi:"attr,run-failures"`
RunsCount int `jsonapi:"attr,workspace-kpis-runs-count"`

// Relations
AgentPool *AgentPool `jsonapi:"relation,agent-pool"`
Expand Down Expand Up @@ -320,6 +328,10 @@ func (s *workspaces) Read(ctx context.Context, organization, workspace string) (
return nil, err
}

// durations come over in ms
w.ApplyDurationAverage *= (time.Second / time.Millisecond)
w.PlanDurationAverage *= (time.Second / time.Millisecond)

return w, nil
}

Expand All @@ -341,6 +353,10 @@ func (s *workspaces) ReadByID(ctx context.Context, workspaceID string) (*Workspa
return nil, err
}

// durations come over in ms
w.ApplyDurationAverage *= (time.Second / time.Millisecond)
w.PlanDurationAverage *= (time.Second / time.Millisecond)

return w, nil
}

Expand Down

0 comments on commit 1dd9469

Please sign in to comment.