Skip to content

Commit c4abf24

Browse files
committed
feat(build): change dryccfile to v2
1 parent cbad992 commit c4abf24

4 files changed

Lines changed: 12 additions & 79 deletions

File tree

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ go 1.23
55
require (
66
github.com/aws/aws-sdk-go v1.55.5
77
github.com/distribution/distribution/v3 v3.0.0-beta.1.0.20241022144144-c427f845035d
8-
github.com/drycc/controller-sdk-go v0.0.0-20241210030451-bd35b03af548
8+
github.com/drycc/controller-sdk-go v0.0.0-20250114084605-55b2a28ae6ee
99
github.com/drycc/pkg v0.0.0-20241028091700-8caca001c932
1010
github.com/google/uuid v1.6.0
1111
github.com/kelseyhightower/envconfig v1.4.0
12-
github.com/stretchr/testify v1.9.0
12+
github.com/stretchr/testify v1.10.0
1313
github.com/urfave/cli/v2 v2.27.5
1414
golang.org/x/crypto v0.31.0
1515
gopkg.in/yaml.v3 v3.0.1
@@ -71,7 +71,7 @@ require (
7171
go.opentelemetry.io/otel/sdk/metric v1.21.0 // indirect
7272
go.opentelemetry.io/otel/trace v1.21.0 // indirect
7373
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
74-
golang.org/x/net v0.28.0 // indirect
74+
golang.org/x/net v0.33.0 // indirect
7575
golang.org/x/oauth2 v0.21.0 // indirect
7676
golang.org/x/sys v0.28.0 // indirect
7777
golang.org/x/term v0.27.0 // indirect

go.sum

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ github.com/distribution/distribution/v3 v3.0.0-beta.1.0.20241022144144-c427f8450
2121
github.com/distribution/distribution/v3 v3.0.0-beta.1.0.20241022144144-c427f845035d/go.mod h1:Unn8+BXBntRw4BZHI7UVY9wJ7yGW/xtOspXPxo6hFIs=
2222
github.com/docker/go-metrics v0.0.1 h1:AgB/0SvBxihN0X8OR4SjsblXkbMvalQ8cjmtKQ2rQV8=
2323
github.com/docker/go-metrics v0.0.1/go.mod h1:cG1hvH2utMXtqgqqYE9plW6lDxS3/5ayHzueweSI3Vw=
24-
github.com/drycc/controller-sdk-go v0.0.0-20241210030451-bd35b03af548 h1:eU8e0vViXNIltGCRlIWcNMZ2YCrAkfDtYXaa/wdJI4Q=
25-
github.com/drycc/controller-sdk-go v0.0.0-20241210030451-bd35b03af548/go.mod h1:F9ViuoVcZ/OG1WnfZBYH6j4v6mb5B+RW9FLaCopADoo=
24+
github.com/drycc/controller-sdk-go v0.0.0-20250114084605-55b2a28ae6ee h1:A8uiBnRTW4mY5zKnwku25Rf1YHAAexTAfyMSPiF3uX8=
25+
github.com/drycc/controller-sdk-go v0.0.0-20250114084605-55b2a28ae6ee/go.mod h1:lGJpGtKDE7WUVJhkxOgWQfd4GEulJ/NlcJycVZIzs5g=
2626
github.com/drycc/pkg v0.0.0-20241028091700-8caca001c932 h1:tUfkfjmFmlm9n0dYp1NoHcFK6+APD/wHZ2We6CKXDSI=
2727
github.com/drycc/pkg v0.0.0-20241028091700-8caca001c932/go.mod h1:upGcZF/RCEqidGjSnWHh/txRC1I4GPsRGvF8/+bDfwU=
2828
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
@@ -158,8 +158,8 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
158158
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
159159
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
160160
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
161-
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
162-
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
161+
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
162+
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
163163
github.com/urfave/cli/v2 v2.27.5 h1:WoHEJLdsXr6dDWoJgMq/CboDmyY/8HMMH1fTECbih+w=
164164
github.com/urfave/cli/v2 v2.27.5/go.mod h1:3Sevf16NykTbInEnD0yKkjDAeZDS0A6bzhBH5hrMvTQ=
165165
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
@@ -214,8 +214,8 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL
214214
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
215215
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
216216
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
217-
golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE=
218-
golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg=
217+
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
218+
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
219219
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
220220
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
221221
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

pkg/gitreceive/build.go

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/drycc/builder/pkg/git"
1818
"github.com/drycc/builder/pkg/k8s"
1919
"github.com/drycc/builder/pkg/sys"
20+
drycc "github.com/drycc/controller-sdk-go"
2021
dryccAPI "github.com/drycc/controller-sdk-go/api"
2122
"github.com/drycc/controller-sdk-go/hooks"
2223
"github.com/drycc/pkg/log"
@@ -249,11 +250,11 @@ func build(
249250
if err != nil {
250251
return err
251252
}
252-
dryccfile, err := getDryccfile(tmpDir)
253+
dockerfile, err := getDockerfile(tmpDir, stack)
253254
if err != nil {
254255
return err
255256
}
256-
dockerfile, err := getDockerfile(tmpDir, stack)
257+
dryccfile, err := drycc.ParseDryccfile(filepath.Join(tmpDir, ".drycc"))
257258
if err != nil {
258259
return err
259260
}
@@ -318,21 +319,6 @@ func getProcfile(dirName string) (dryccAPI.ProcessType, error) {
318319
return procfile, nil
319320
}
320321

321-
func getDryccfile(dirName string) (map[string]interface{}, error) {
322-
dryccfile := map[string]interface{}{}
323-
file := fmt.Sprintf("%s/drycc.yaml", dirName)
324-
if _, err := os.Stat(file); err == nil {
325-
rawDryccfile, err := os.ReadFile(file)
326-
if err != nil {
327-
return nil, fmt.Errorf("error in reading %s (%s)", file, err)
328-
}
329-
if err := yaml.Unmarshal(rawDryccfile, &dryccfile); err != nil {
330-
return nil, fmt.Errorf("drycc.yaml %s is malformed (%s)", file, err)
331-
}
332-
}
333-
return dryccfile, nil
334-
}
335-
336322
func getDockerfile(dirName string, stack map[string]string) (string, error) {
337323
if stack["name"] == "container" {
338324
file := fmt.Sprintf("%s/Dockerfile", dirName)

pkg/gitreceive/build_test.go

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -95,59 +95,6 @@ func TestRepoCmd(t *testing.T) {
9595
}
9696
}
9797

98-
func TestGetDryccfileFromRepoSuccess(t *testing.T) {
99-
tmpDir, err := os.MkdirTemp("", "tmpdir")
100-
if err != nil {
101-
t.Fatalf("error creating temp directory (%s)", err)
102-
}
103-
104-
data := `
105-
build:
106-
docker:
107-
web: Dockerfile
108-
worker: worker/Dockerfile
109-
config:
110-
RAILS_ENV: development
111-
FOO: bar
112-
run:
113-
command:
114-
- ./deployment-tasks.sh
115-
image: worker
116-
deploy:
117-
web:
118-
command:
119-
- bash
120-
- -c
121-
args: bundle exec puma -C config/puma.rb
122-
worker:
123-
command:
124-
- bash
125-
- -c
126-
args:
127-
- python myworker.py
128-
asset-syncer:
129-
command:
130-
- bash
131-
- -c
132-
args:
133-
- python asset-syncer.py
134-
image: worker
135-
`
136-
if err := os.WriteFile(tmpDir+"/drycc.yaml", []byte(data), 0644); err != nil {
137-
t.Fatalf("error creating %s/drycc.yaml (%s)", tmpDir, err)
138-
}
139-
defer func() {
140-
if err := os.RemoveAll(tmpDir); err != nil {
141-
t.Fatalf("failed to remove drycc.yaml from %s (%s)", tmpDir, err)
142-
}
143-
}()
144-
dryccfile, err := getDryccfile(tmpDir)
145-
actualData := map[string]interface{}{}
146-
yaml.Unmarshal([]byte(data), &actualData)
147-
assert.Equal(t, err, nil)
148-
assert.Equal(t, dryccfile, actualData, "data")
149-
}
150-
15198
func TestGetProcfileFromRepoSuccess(t *testing.T) {
15299
tmpDir, err := os.MkdirTemp("", "tmpdir")
153100
if err != nil {

0 commit comments

Comments
 (0)