We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see ourdocumentation.
There was an error while loading.Please reload this page.
1 parente4770bb commitc6cee94Copy full SHA for c6cee94
cli/clitest/clitest.go
@@ -23,6 +23,7 @@ import (
23
24
var (
25
// Used to ensure terminal output doesn't have anything crazy!
26
+// See: https://stackoverflow.com/a/29497680
27
stripAnsi=regexp.MustCompile("[\u001B\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))")
28
)
29
cli/projects.go
@@ -17,7 +17,6 @@ func projects() *cobra.Command {
17
cmd:=&cobra.Command{
18
Use:"projects",
19
Aliases: []string{"project"},
20
-Long:"Testing something",
21
Example:`
22
- Create a project for developers to create workspaces
cli/workspacecreate.go
@@ -120,8 +120,9 @@ func workspaceCreate() *cobra.Command {
120
_,_=fmt.Printf("Terraform: %s\n",log.Output)
121
}
122
123
-_,_=fmt.Printf("Created workspace! %s\n",name)
+// This command is WIP, and output will change!
124
125
+_,_=fmt.Printf("Created workspace! %s\n",name)
126
returnnil
127
},
128
coderd/files.go
@@ -40,8 +40,18 @@ func (api *api) postFiles(rw http.ResponseWriter, r *http.Request) {
40
return
41
42
hashBytes:=sha256.Sum256(data)
43
-file,err:=api.Database.InsertFile(r.Context(), database.InsertFileParams{
44
-Hash:hex.EncodeToString(hashBytes[:]),
+hash:=hex.EncodeToString(hashBytes[:])
+file,err:=api.Database.GetFileByHash(r.Context(),hash)
45
+iferr==nil {
46
+// The file already exists!
47
+render.Status(r,http.StatusOK)
48
+render.JSON(rw,r,UploadFileResponse{
49
+Hash:file.Hash,
50
+})
51
+return
52
+}
53
+file,err=api.Database.InsertFile(r.Context(), database.InsertFileParams{
54
+Hash:hash,
55
CreatedBy:apiKey.UserID,
56
CreatedAt:database.Now(),
57
Mimetype:contentType,
coderd/files_test.go
@@ -27,4 +27,15 @@ func TestPostFiles(t *testing.T) {
_,err:=client.UploadFile(context.Background(),codersdk.ContentTypeTar,make([]byte,1024))
require.NoError(t,err)
})
30
+
31
+t.Run("InsertAlreadyExists",func(t*testing.T) {
32
+t.Parallel()
33
+client:=coderdtest.New(t)
34
+_=coderdtest.CreateInitialUser(t,client)
35
+data:=make([]byte,1024)
36
+_,err:=client.UploadFile(context.Background(),codersdk.ContentTypeTar,data)
37
+require.NoError(t,err)
38
+_,err=client.UploadFile(context.Background(),codersdk.ContentTypeTar,data)
39
coderd/parameter/compute.go
@@ -88,7 +88,7 @@ func Compute(ctx context.Context, db database.Store, scope ComputeScope, options
88
continue
89
90
if_,ok:=compute.computedParameterByName[parameterSchema.Name];ok {
91
-// We already have a value! No need to useth default.
+// We already have a value! No need to usethe default.
92
93
94
coderd/provisionerjobs.go
@@ -170,7 +170,6 @@ func (api *api) provisionerJobLogsByID(rw http.ResponseWriter, r *http.Request)
170
171
iferrors.Is(err,sql.ErrNoRows) {
172
err=nil
173
-provisionerJobLogs= []database.ProvisionerJobLog{}
174
175
iferr!=nil {
176
httpapi.Write(rw,http.StatusInternalServerError, httpapi.Response{
codersdk/files.go
@@ -20,7 +20,7 @@ func (c *Client) UploadFile(ctx context.Context, contentType string, content []b
return coderd.UploadFileResponse{},err
deferres.Body.Close()
-ifres.StatusCode!=http.StatusCreated {
+ifres.StatusCode!=http.StatusCreated&&res.StatusCode!=http.StatusOK{
return coderd.UploadFileResponse{},readBodyAsError(res)
varresp coderd.UploadFileResponse