Skip to content

Commit b33f6b8

Browse files
committed
feat(domain): add procfile_type
1 parent cdcd7b4 commit b33f6b8

7 files changed

Lines changed: 23 additions & 16 deletions

File tree

cmd/cmd.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type Commander interface {
4646
ConfigPull(string, string, string, bool, bool) error
4747
ConfigPush(string, string, string) error
4848
DomainsList(string, int) error
49-
DomainsAdd(string, string) error
49+
DomainsAdd(string, string, string) error
5050
DomainsRemove(string, string) error
5151
ServicesList(string) error
5252
ServicesAdd(string, string, string, string) error

cmd/domains.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ func (d *DryccCmd) DomainsList(appID string, results int) error {
2323
return err
2424
}
2525
if count > 0 {
26-
table := d.getDefaultFormatTable([]string{"APP", "OWNER", "CREATED", "UPDATED", "DOMAIN"})
26+
table := d.getDefaultFormatTable([]string{"APP", "OWNER", "PTYPE", "CREATED", "UPDATED", "DOMAIN"})
2727
for _, domain := range domains {
2828
table.Append([]string{
2929
domain.App,
3030
domain.Owner,
31+
domain.ProcfileType,
3132
domain.Created,
3233
domain.Updated,
3334
domain.Domain,
@@ -41,7 +42,7 @@ func (d *DryccCmd) DomainsList(appID string, results int) error {
4142
}
4243

4344
// DomainsAdd adds a domain to an app.
44-
func (d *DryccCmd) DomainsAdd(appID, domain string) error {
45+
func (d *DryccCmd) DomainsAdd(appID, domain, procfileType string) error {
4546
s, appID, err := load(d.ConfigFile, appID)
4647

4748
if err != nil {
@@ -51,7 +52,7 @@ func (d *DryccCmd) DomainsAdd(appID, domain string) error {
5152
d.Printf("Adding %s to %s... ", domain, appID)
5253

5354
quit := progress(d.WOut)
54-
_, err = domains.New(s.Client, appID, domain)
55+
_, err = domains.New(s.Client, appID, domain, procfileType)
5556
quit <- true
5657
<-quit
5758
if d.checkAPICompatibility(s.Client, err) != nil {

cmd/domains_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,15 @@ func TestDomainsList(t *testing.T) {
3232
"app": "foo",
3333
"created": "2014-01-01T00:00:00UTC",
3434
"domain": "example.example.com",
35+
"procfile_type": "web",
3536
"owner": "test",
3637
"updated": "2014-01-01T00:00:00UTC"
3738
},
3839
{
3940
"app": "foo",
4041
"created": "2014-01-01T00:00:00UTC",
4142
"domain": "foo",
43+
"procfile_type": "web",
4244
"owner": "test",
4345
"updated": "2014-01-01T00:00:00UTC"
4446
}
@@ -49,9 +51,9 @@ func TestDomainsList(t *testing.T) {
4951
err = cmdr.DomainsList("foo", -1)
5052
assert.NoError(t, err)
5153

52-
assert.Equal(t, b.String(), `APP OWNER CREATED UPDATED DOMAIN
53-
foo test 2014-01-01T00:00:00UTC 2014-01-01T00:00:00UTC example.example.com
54-
foo test 2014-01-01T00:00:00UTC 2014-01-01T00:00:00UTC foo
54+
assert.Equal(t, b.String(), `APP OWNER PTYPE CREATED UPDATED DOMAIN
55+
foo test web 2014-01-01T00:00:00UTC 2014-01-01T00:00:00UTC example.example.com
56+
foo test web 2014-01-01T00:00:00UTC 2014-01-01T00:00:00UTC foo
5557
`, "output")
5658
}
5759

@@ -76,6 +78,7 @@ func TestDomainsListLimit(t *testing.T) {
7678
"app": "foo",
7779
"created": "2014-01-01T00:00:00UTC",
7880
"domain": "example.example.com",
81+
"procfile_type": "web",
7982
"owner": "test",
8083
"updated": "2014-01-01T00:00:00UTC"
8184
}
@@ -86,8 +89,8 @@ func TestDomainsListLimit(t *testing.T) {
8689
err = cmdr.DomainsList("foo", 1)
8790
assert.NoError(t, err)
8891

89-
assert.Equal(t, b.String(), `APP OWNER CREATED UPDATED DOMAIN
90-
foo test 2014-01-01T00:00:00UTC 2014-01-01T00:00:00UTC example.example.com
92+
assert.Equal(t, b.String(), `APP OWNER PTYPE CREATED UPDATED DOMAIN
93+
foo test web 2014-01-01T00:00:00UTC 2014-01-01T00:00:00UTC example.example.com
9194
`, "output")
9295
}
9396

@@ -102,14 +105,14 @@ func TestDomainsAdd(t *testing.T) {
102105
cmdr := DryccCmd{WOut: &b, ConfigFile: cf}
103106

104107
server.Mux.HandleFunc("/v2/apps/foo/domains/", func(w http.ResponseWriter, r *http.Request) {
105-
testutil.AssertBody(t, api.DomainCreateRequest{Domain: "example.example.com"}, r)
108+
testutil.AssertBody(t, api.DomainCreateRequest{Domain: "example.example.com", ProcfileType: "web"}, r)
106109
testutil.SetHeaders(w)
107110
w.WriteHeader(http.StatusCreated)
108111
// Body isn't used by CLI, so it isn't set.
109112
w.Write([]byte("{}"))
110113
})
111114

112-
err = cmdr.DomainsAdd("foo", "example.example.com")
115+
err = cmdr.DomainsAdd("foo", "example.example.com", "web")
113116
assert.NoError(t, err)
114117

115118
assert.Equal(t, testutil.StripProgress(b.String()), "Adding example.example.com to foo... done\n", "output")

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.22
55
require (
66
github.com/containerd/console v1.0.4
77
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815
8-
github.com/drycc/controller-sdk-go v0.0.0-20240430013837-6be5299a98ee
8+
github.com/drycc/controller-sdk-go v0.0.0-20240501162129-fd677ec39e8c
99
github.com/drycc/pkg v0.0.0-20240225112316-78fc9239f51f
1010
github.com/olekukonko/tablewriter v0.0.5
1111
github.com/stretchr/testify v1.9.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
44
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
55
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815 h1:bWDMxwH3px2JBh6AyO7hdCn/PkvCZXii8TGj7sbtEbQ=
66
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
7-
github.com/drycc/controller-sdk-go v0.0.0-20240430013837-6be5299a98ee h1:GU8eDN2GrkhcQa3MnBMTJZmJrhZXPbo/rtAQArrzpeo=
8-
github.com/drycc/controller-sdk-go v0.0.0-20240430013837-6be5299a98ee/go.mod h1:n6eQe1irJqjwLo/7t9+Dhdv6faSESQN+ATnZRBP3/Uc=
7+
github.com/drycc/controller-sdk-go v0.0.0-20240501162129-fd677ec39e8c h1:C581oO1EmNJky8GpAricQftIufdeg2tlWgTvA5xPjJ0=
8+
github.com/drycc/controller-sdk-go v0.0.0-20240501162129-fd677ec39e8c/go.mod h1:n6eQe1irJqjwLo/7t9+Dhdv6faSESQN+ATnZRBP3/Uc=
99
github.com/drycc/pkg v0.0.0-20240225112316-78fc9239f51f h1:kgjvUQJeAszDoU1Vo4vTTE92KI8Av3JPb6Qn890niXg=
1010
github.com/drycc/pkg v0.0.0-20240225112316-78fc9239f51f/go.mod h1:n+QxGif6ha9CEoxVnlipxb9IdmerybcUSzTEDFkvjiA=
1111
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=

parser/domains.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ Arguments:
5050
the domain name to be bound to the application, such as 'domain.dryccapp.com'.
5151
5252
Options:
53+
--type=<type>
54+
the procType type for domain, default[web].
5355
-a --app=<app>
5456
the uniquely identifiable name for the application.
5557
`
@@ -61,9 +63,10 @@ Options:
6163
}
6264

6365
app := safeGetString(args, "--app")
66+
procfileType := safeGetString(args, "--type")
6467
domain := safeGetString(args, "<domain>")
6568

66-
return cmdr.DomainsAdd(app, domain)
69+
return cmdr.DomainsAdd(app, domain, procfileType)
6770
}
6871

6972
func domainsList(argv []string, cmdr cmd.Commander) error {

parser/domains_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func (d FakeDryccCmd) DomainsList(string, int) error {
1616
return errors.New("domains:list")
1717
}
1818

19-
func (d FakeDryccCmd) DomainsAdd(string, string) error {
19+
func (d FakeDryccCmd) DomainsAdd(string, string, string) error {
2020
return errors.New("domains:add")
2121
}
2222

0 commit comments

Comments
 (0)