Skip to content

Commit bb6c555

Browse files
committed
projects support
1 parent 3779993 commit bb6c555

File tree

136 files changed

+3913
-1396
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+3913
-1396
lines changed

args.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
@@ -187,6 +187,19 @@ const (
187187
// ArgOutboundRules is a list of outbound rules for the firewall.
188188
ArgOutboundRules = "outbound-rules"
189189

190+
// ArgProjectName is the name of a project.
191+
ArgProjectName = "name"
192+
// ArgProjectDescription is the description of a project.
193+
ArgProjectDescription = "description"
194+
// ArgProjectPurpose is the purpose of a project.
195+
ArgProjectPurpose = "purpose"
196+
// ArgProjectEnvironment is the environment of a project. Should be one of 'Development', 'Staging', 'Production'.
197+
ArgProjectEnvironment = "environment"
198+
// ArgProjectIsDefault is used to change the default project.
199+
ArgProjectIsDefault = "is_default"
200+
// ArgProjectResource is a flag for your resource URNs
201+
ArgProjectResource = "resource"
202+
190203
// ArgForce forces confirmation on actions
191204
ArgForce = "force"
192205
)

args_short.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

cmd/doctl-gen-doc/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

cmd/doctl/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

cmd/install-doctl/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

cmd/release-doctl/main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

command.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

commands/account.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
@@ -13,7 +13,10 @@ limitations under the License.
1313

1414
package commands
1515

16-
import "github.com/spf13/cobra"
16+
import (
17+
"github.com/digitalocean/doctl/commands/displayers"
18+
"github.com/spf13/cobra"
19+
)
1720

1821
// Account creates the account commands heirarchy.
1922
func Account() *Command {
@@ -28,10 +31,10 @@ func Account() *Command {
2831
}
2932

3033
CmdBuilder(cmd, RunAccountGet, "get", "get account", Writer,
31-
aliasOpt("g"), displayerType(&account{}), docCategories("account"))
34+
aliasOpt("g"), displayerType(&displayers.Account{}), docCategories("account"))
3235

3336
CmdBuilder(cmd, RunAccountRateLimit, "ratelimit", "get API rate limits", Writer,
34-
aliasOpt("rl"), displayerType(&rateLimit{}), docCategories("account"))
37+
aliasOpt("rl"), displayerType(&displayers.RateLimit{}), docCategories("account"))
3538

3639
return cmd
3740
}
@@ -43,7 +46,7 @@ func RunAccountGet(c *CmdConfig) error {
4346
return err
4447
}
4548

46-
return c.Display(&account{Account: a})
49+
return c.Display(&displayers.Account{Account: a})
4750
}
4851

4952
// RunAccountRateLimit retrieves API rate limits for the account.
@@ -53,5 +56,5 @@ func RunAccountRateLimit(c *CmdConfig) error {
5356
return err
5457
}
5558

56-
return c.Display(&rateLimit{RateLimit: rl})
59+
return c.Display(&displayers.RateLimit{RateLimit: rl})
5760
}

commands/account_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

commands/actions.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
@@ -19,6 +19,7 @@ import (
1919
"time"
2020

2121
"github.com/digitalocean/doctl"
22+
"github.com/digitalocean/doctl/commands/displayers"
2223
"github.com/digitalocean/doctl/do"
2324
"github.com/spf13/cobra"
2425
)
@@ -36,10 +37,10 @@ func Actions() *Command {
3637
}
3738

3839
CmdBuilder(cmd, RunCmdActionGet, "get <action-id>", "get action", Writer,
39-
aliasOpt("g"), displayerType(&action{}), docCategories("action"))
40+
aliasOpt("g"), displayerType(&displayers.Action{}), docCategories("action"))
4041

4142
cmdActionList := CmdBuilder(cmd, RunCmdActionList, "list", "list actions", Writer,
42-
aliasOpt("ls"), displayerType(&action{}), docCategories("action"))
43+
aliasOpt("ls"), displayerType(&displayers.Action{}), docCategories("action"))
4344
AddStringFlag(cmdActionList, doctl.ArgActionResourceType, "", "", "Action resource type")
4445
AddStringFlag(cmdActionList, doctl.ArgActionRegion, "", "", "Action region")
4546
AddStringFlag(cmdActionList, doctl.ArgActionAfter, "", "", "Action completed after in RFC3339 format")
@@ -48,7 +49,7 @@ func Actions() *Command {
4849
AddStringFlag(cmdActionList, doctl.ArgActionType, "", "", "Action type")
4950

5051
cmdActionWait := CmdBuilder(cmd, RunCmdActionWait, "wait <action-id>", "wait for action to complete", Writer,
51-
aliasOpt("w"), displayerType(&action{}), docCategories("action"))
52+
aliasOpt("w"), displayerType(&displayers.Action{}), docCategories("action"))
5253
AddIntFlag(cmdActionWait, doctl.ArgPollTime, "", 5, "Re-poll time in seconds")
5354

5455
return cmd
@@ -68,7 +69,7 @@ func RunCmdActionList(c *CmdConfig) error {
6869

6970
sort.Sort(actionsByCompletedAt(actions))
7071

71-
item := &action{actions: actions}
72+
item := &displayers.Action{Actions: actions}
7273
return c.Display(item)
7374
}
7475

@@ -190,7 +191,7 @@ func RunCmdActionGet(c *CmdConfig) error {
190191
return err
191192
}
192193

193-
return c.Display(&action{actions: do.Actions{*a}})
194+
return c.Display(&displayers.Action{Actions: do.Actions{*a}})
194195
}
195196

196197
// RunCmdActionWait waits for an action to complete or error.
@@ -214,7 +215,7 @@ func RunCmdActionWait(c *CmdConfig) error {
214215
return err
215216
}
216217

217-
return c.Display(&action{actions: do.Actions{*a}})
218+
return c.Display(&displayers.Action{Actions: do.Actions{*a}})
218219
}
219220

220221
func actionWait(c *CmdConfig, actionID, pollTime int) (*do.Action, error) {

commands/actions_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

commands/auth.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

commands/auth_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

commands/cdns.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"fmt"
1919

2020
"github.com/digitalocean/doctl"
21+
"github.com/digitalocean/doctl/commands/displayers"
2122
"github.com/digitalocean/doctl/do"
2223
"github.com/digitalocean/godo"
2324
"github.com/spf13/cobra"
@@ -34,21 +35,21 @@ func CDN() *Command {
3435
}
3536

3637
CmdBuilder(cmd, RunCDNList, "list", "list cdn", Writer,
37-
aliasOpt("ls"), displayerType(&cdn{}))
38+
aliasOpt("ls"), displayerType(&displayers.CDN{}))
3839

3940
cmdCDNCreate := CmdBuilder(cmd, RunCDNCreate, "create <cdn-origin>", "create a cdn", Writer,
40-
aliasOpt("c"), displayerType(&cdn{}))
41+
aliasOpt("c"), displayerType(&displayers.CDN{}))
4142
AddIntFlag(cmdCDNCreate, doctl.ArgCDNTTL, "", 3600, "CDN ttl")
4243

4344
cmdRunCDNDelete := CmdBuilder(cmd, RunCDNDelete, "delete <cdn-id>", "delete a cdn", Writer,
4445
aliasOpt("rm"))
4546
AddBoolFlag(cmdRunCDNDelete, doctl.ArgForce, doctl.ArgShortForce, false, "Force cdn delete")
4647

4748
CmdBuilder(cmd, RunCDNGet, "get <cdn-id>", "get a cdn", Writer, aliasOpt("g"),
48-
displayerType(&cdn{}))
49+
displayerType(&displayers.CDN{}))
4950

5051
cmdCDNUpdate := CmdBuilder(cmd, RunCDNUpdateTTL, "update <cdn-id>", "update a cdn", Writer,
51-
aliasOpt("u"), displayerType(&cdn{}))
52+
aliasOpt("u"), displayerType(&displayers.CDN{}))
5253
AddIntFlag(cmdCDNUpdate, doctl.ArgCDNTTL, "", 3600, "cdn ttl")
5354

5455
cmdCDNFlushCache := CmdBuilder(cmd, RunCDNFlushCache, "flush <cdn-id>", "flush cdn cache", Writer,
@@ -65,7 +66,7 @@ func RunCDNList(c *CmdConfig) error {
6566
return err
6667
}
6768

68-
return c.Display(&cdn{cdns: cdns})
69+
return c.Display(&displayers.CDN{CDNs: cdns})
6970
}
7071

7172
// RunCDNGet returns an individual CDN.
@@ -80,7 +81,7 @@ func RunCDNGet(c *CmdConfig) error {
8081
return err
8182
}
8283

83-
return c.Display(&cdn{cdns: []do.CDN{*item}})
84+
return c.Display(&displayers.CDN{CDNs: []do.CDN{*item}})
8485
}
8586

8687
// RunCDNCreate creates a cdn.
@@ -109,7 +110,7 @@ func RunCDNCreate(c *CmdConfig) error {
109110
return err
110111
}
111112

112-
return c.Display(&cdn{cdns: []do.CDN{*item}})
113+
return c.Display(&displayers.CDN{CDNs: []do.CDN{*item}})
113114
}
114115

115116
// RunCDNUpdateTTL updates an individual cdn ttl
@@ -137,7 +138,7 @@ func RunCDNUpdateTTL(c *CmdConfig) error {
137138
return err
138139
}
139140

140-
return c.Display(&cdn{cdns: []do.CDN{*item}})
141+
return c.Display(&displayers.CDN{CDNs: []do.CDN{*item}})
141142
}
142143

143144
// RunCDNDelete deletes a cdn.

commands/certificates.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2017 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
@@ -18,6 +18,7 @@ import (
1818
"io/ioutil"
1919

2020
"github.com/digitalocean/doctl"
21+
"github.com/digitalocean/doctl/commands/displayers"
2122
"github.com/digitalocean/doctl/do"
2223
"github.com/digitalocean/godo"
2324

@@ -65,7 +66,7 @@ func RunCertificateGet(c *CmdConfig) error {
6566
return err
6667
}
6768

68-
item := &certificate{certificates: do.Certificates{*cer}}
69+
item := &displayers.Certificate{Certificates: do.Certificates{*cer}}
6970
return c.Display(item)
7071
}
7172

@@ -140,7 +141,7 @@ func RunCertificateCreate(c *CmdConfig) error {
140141
return err
141142
}
142143

143-
item := &certificate{certificates: do.Certificates{*cer}}
144+
item := &displayers.Certificate{Certificates: do.Certificates{*cer}}
144145
return c.Display(item)
145146
}
146147

@@ -152,7 +153,7 @@ func RunCertificateList(c *CmdConfig) error {
152153
return err
153154
}
154155

155-
item := &certificate{certificates: list}
156+
item := &displayers.Certificate{Certificates: list}
156157
return c.Display(item)
157158
}
158159

commands/command.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at

commands/command_config.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright 2016 The Doctl Authors All rights reserved.
2+
Copyright 2018 The Doctl Authors All rights reserved.
33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.
55
You may obtain a copy of the License at
@@ -13,6 +13,8 @@ limitations under the License.
1313

1414
package commands
1515

16+
import "github.com/digitalocean/doctl/commands/displayers"
17+
1618
// cmdOption allow configuration of a command.
1719
type cmdOption func(*Command)
1820

@@ -28,7 +30,7 @@ func aliasOpt(aliases ...string) cmdOption {
2830
}
2931

3032
// displayerType sets the columns for display for a command.
31-
func displayerType(d Displayable) cmdOption {
33+
func displayerType(d displayers.Displayable) cmdOption {
3234
return func(c *Command) {
3335
c.fmtCols = d.Cols()
3436
}

0 commit comments

Comments
 (0)