This repository was archived by the owner on Aug 30, 2024. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork18
Add more coder-sdk operations#169
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
9 changes: 4 additions & 5 deletionscoder-sdk/env.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
9 changes: 6 additions & 3 deletionscoder-sdk/error.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletionscoder-sdk/image.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
59 changes: 48 additions & 11 deletionscoder-sdk/org.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
67 changes: 61 additions & 6 deletionscoder-sdk/users.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletionscoder-sdk/util.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package coder | ||
import ( | ||
"encoding/json" | ||
"strconv" | ||
"time" | ||
) | ||
func String(s string) *string { | ||
return &s | ||
} | ||
// Duration is a time.Duration wrapper that marshals to millisecond precision. | ||
// While it looses precision, most javascript applications expect durations to be in milliseconds. | ||
type Duration time.Duration | ||
// MarshalJSON marshals the duration to millisecond precision. | ||
func (d Duration) MarshalJSON() ([]byte, error) { | ||
du := time.Duration(d) | ||
return json.Marshal(du.Milliseconds()) | ||
} | ||
// UnmarshalJSON unmarshals a millisecond-precision integer to | ||
// a time.Duration. | ||
func (d *Duration) UnmarshalJSON(b []byte) error { | ||
i, err := strconv.ParseInt(string(b), 10, 64) | ||
if err != nil { | ||
return err | ||
} | ||
*d = Duration(time.Duration(i) * time.Millisecond) | ||
return nil | ||
} | ||
func (d Duration) String() string { return time.Duration(d).String() } |
31 changes: 0 additions & 31 deletionsinternal/x/xjson/duration.go
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.