Skip to content

Commit

Permalink
Merge branch 'main' into APPS-8731/update-cnb-image
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewsomething authored Jul 22, 2024
2 parents 1e055e0 + d16c594 commit f471a39
Show file tree
Hide file tree
Showing 473 changed files with 15,566 additions and 55,982 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:
go-version: 1.21.x

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/typos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Check spelling

on:
push:
branches: [ main ]
pull_request:
branches:
- main
- feature/**

jobs:
run:
name: Spell Check with Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v4

- name: Check spelling
uses: crate-ci/typos@v1.23.2

4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project_name: doctl

version: 2
builds:
- main: ./cmd/doctl/main.go
env:
Expand Down Expand Up @@ -50,4 +50,4 @@ release:
name: doctl

changelog:
skip: false
disable: false
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ or `make help` for a list of available commands with descriptions.
- Avoid the passive voice ("When a tag is provided, access is granted") and use the active voice ("Entering a tag provides access")
- Be helpful when users have to enter a input that is from a list of possible values. Give examples, list the possible values inline (if the list is relatively short), or point them to a command that can list the possible values for them.

## Spell Check

`doctl` is setup to use the code aware spell checker called [typos](https://github.com/crate-ci/typos) to keep an eye on any spelling mistakes.

To install your own copy,follow the instructions on the [typos readme](https://github.com/crate-ci/typos?tab=readme-ov-file#install), and then run the `typos` binary

### Go environment

Expand Down
16 changes: 16 additions & 0 deletions _typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[files]
extend-exclude = [
"vendor/**",
"go.mod"
]

[default.extend-identifiers]
vas = "vas"
splitted = "splitted"

[default.extend-words]
# Its not perfect at hashes yet
cace = "cace"
Wqs = "Wqs"
# example and exmaple as two domain examples
exmaple = "exmaple"
27 changes: 25 additions & 2 deletions args.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ const (
ArgAutoUpgrade = "auto-upgrade"
// ArgHA is a cluster's highly available control plane argument.
ArgHA = "ha"
// ArgEnableControlPlaneFirewall enable control plane firewall.
ArgEnableControlPlaneFirewall = "enable-control-plane-firewall"
// ArgControlPlaneFirewallAllowedAddresses list of allowed addresses that can access the control plane.
ArgControlPlaneFirewallAllowedAddresses = "control-plane-firewall-allowed-addresses"
// ArgSurgeUpgrade is a cluster's surge-upgrade argument.
ArgSurgeUpgrade = "surge-upgrade"
// ArgCommandUpsert is an upsert for a resource to be created or updated argument.
Expand Down Expand Up @@ -337,6 +341,16 @@ const (
ArgDenyList = "deny-list"
// ArgLoadBalancerType is the type of the load balancer.
ArgLoadBalancerType = "type"
// ArgLoadBalancerDomains is list of domains supported for global load balancer.
ArgLoadBalancerDomains = "domains"
// ArgGlobalLoadBalancerSettings is global load balancer settings.
ArgGlobalLoadBalancerSettings = "glb-settings"
// ArgGlobalLoadBalancerCDNSettings is global load balancer CDN settings.
ArgGlobalLoadBalancerCDNSettings = "glb-cdn-settings"
// ArgTargetLoadBalancerIDs is a list of target load balancer IDs.
ArgTargetLoadBalancerIDs = "target-lb-ids"
// ArgLoadBalancerNetwork is the type of network the load balancer is accessible from.
ArgLoadBalancerNetwork = "network"

// ArgFirewallName is a name of the firewall.
ArgFirewallName = "name"
Expand Down Expand Up @@ -390,6 +404,8 @@ const (
ArgDatabaseUserMySQLAuthPlugin = "mysql-auth-plugin"
// ArgDatabasePrivateConnectionBool determine if the private connection details should be shown
ArgDatabasePrivateConnectionBool = "private"
// ArgDatabaseUserKafkaACLs will specify permissions on topics in kafka clsuter
ArgDatabaseUserKafkaACLs = "acl"

// ArgDatabaseTopicReplicationFactor is the replication factor of a kafka topic
ArgDatabaseTopicReplicationFactor = "replication-factor"
Expand All @@ -413,8 +429,8 @@ const (
ArgDatabaseTopicMaxCompactionLagMS = "max-compaction-lag-ms"
// ArgDatabaseTopicMaxMessageBytes is the maximum size, in bytes, of the largest record batch that can be sent to the server
ArgDatabaseTopicMaxMessageBytes = "max-message-bytes"
// ArgDatabaseTopicMesssageDownConversionEnable determines whether brokers should convert messages for consumers expecting older message formats
ArgDatabaseTopicMesssageDownConversionEnable = "message-down-conversion-enable"
// ArgDatabaseTopicMessageDownConversionEnable determines whether brokers should convert messages for consumers expecting older message formats
ArgDatabaseTopicMessageDownConversionEnable = "message-down-conversion-enable"
// ArgDatabaseTopicMessageFormatVersion is the version used by the broker to append messages to the kafka topic logs
ArgDatabaseTopicMessageFormatVersion = "message-format-version"
// ArgDatabaseTopicMessageTimestampType is the timestamp used for messages
Expand Down Expand Up @@ -458,6 +474,13 @@ const (
// ArgVPCIPRange is a VPC range of IP addresses in CIDR notation.
ArgVPCIPRange = "ip-range"

// ArgVPCPeeringName is a name of the VPC Peering.
ArgVPCPeeringName = "name"
// ArgVPCPeeringVPCIDs is the vpc ids of the peering
ArgVPCPeeringVPCIDs = "vpc-ids"
// ArgVPCPeeringVPCID is id of the VPC.
ArgVPCPeeringVPCID = "vpc-id"

// ArgReadWrite indicates a generated token should be read/write.
ArgReadWrite = "read-write"
// ArgRegistry indicates the name of the registry.
Expand Down
3 changes: 2 additions & 1 deletion commands/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ Only basic information is included with the text output format. For complete app
Three types of logs are supported and can be specified with the --`+doctl.ArgAppLogType+` flag:
- build
- deploy
- run
- run
- run_restarted
For more information about logs, see [How to View Logs](https://www.digitalocean.com/docs/app-platform/how-to/view-logs/).
`,
Expand Down
4 changes: 2 additions & 2 deletions commands/apps_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ func appDevPrepareEnvironment(ctx context.Context, ws *workspace.AppDev, cli bui
}

// TODO: get stack run image from builder image md after we pull it, see below
images = append(images, "digitaloceanapps/apps-run:heroku-18_db5978a")
images = append(images, "digitaloceanapps/apps-run:heroku-22_db5978a")
images = append(images, "digitaloceanapps/apps-run:heroku-18_df7e351")
images = append(images, "digitaloceanapps/apps-run:heroku-22_df7e351")
}

if componentSpec.GetType() == godo.AppComponentTypeStaticSite {
Expand Down
35 changes: 33 additions & 2 deletions commands/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ limitations under the License.
package commands

import (
"encoding/json"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -218,11 +219,16 @@ func RunAuthList(c *CmdConfig) error {
}
contexts := viper.GetStringMap("auth-contexts")

displayAuthContexts(c.Out, context, contexts)
if viper.GetString("output") == "json" {
displayAuthContextsJSON(c.Out, context, contexts)
} else {
displayAuthContexts(c.Out, context, contexts)
}

return nil
}

func displayAuthContexts(out io.Writer, currentContext string, contexts map[string]any) {
func ensureDefaultContextAndKeysOrder(contexts map[string]any) []string {
// Because the default context isn't present on the auth-contexts field,
// we add it manually so that it's always included in the output, and so
// we can check if it's the current context.
Expand All @@ -236,6 +242,31 @@ func displayAuthContexts(out io.Writer, currentContext string, contexts map[stri
}
sort.Strings(keys)

return keys
}

func displayAuthContextsJSON(out io.Writer, currentContext string, contexts map[string]any) {
type contextJSON struct {
Name string `json:"name"`
Current bool `json:"current"`
}

var contextsJSON []contextJSON

keys := ensureDefaultContextAndKeysOrder(contexts)
for _, ctx := range keys {
contextsJSON = append(contextsJSON, contextJSON{
Name: ctx,
Current: ctx == currentContext,
})
}

jsonData, _ := json.MarshalIndent(contextsJSON, "", " ")
fmt.Fprintln(out, string(jsonData))
}

func displayAuthContexts(out io.Writer, currentContext string, contexts map[string]any) {
keys := ensureDefaultContextAndKeysOrder(contexts)
for _, ctx := range keys {
if ctx == currentContext {
fmt.Fprintln(out, ctx, "(current)")
Expand Down
67 changes: 62 additions & 5 deletions commands/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,12 @@ func TestAuthList(t *testing.T) {

func Test_displayAuthContexts(t *testing.T) {
testCases := []struct {
Name string
Out *bytes.Buffer
Context string
Contexts map[string]any
Expected string
Name string
Out *bytes.Buffer
Context string
Contexts map[string]any
Expected string
ExpectedJSON string
}{
{
Name: "default context only",
Expand Down Expand Up @@ -227,6 +228,62 @@ func Test_displayAuthContexts(t *testing.T) {
}
}

func Test_displayAuthContextsJSON(t *testing.T) {
testCases := []struct {
Name string
Out *bytes.Buffer
Context string
Contexts map[string]any
ExpectedJSON string
}{
{
Name: "default context only",
Out: &bytes.Buffer{},
Context: doctl.ArgDefaultContext,
Contexts: map[string]any{
doctl.ArgDefaultContext: true,
},
ExpectedJSON: "[\n {\n \"name\": \"default\",\n \"current\": true\n }\n]\n",
},
{
Name: "default context and additional context",
Out: &bytes.Buffer{},
Context: doctl.ArgDefaultContext,
Contexts: map[string]any{
doctl.ArgDefaultContext: true,
"test": true,
},
ExpectedJSON: "[\n {\n \"name\": \"default\",\n \"current\": true\n },\n {\n \"name\": \"test\",\n \"current\": false\n }\n]\n",
},
{
Name: "default context and additional context set to additional context",
Out: &bytes.Buffer{},
Context: "test",
Contexts: map[string]any{
doctl.ArgDefaultContext: true,
"test": true,
},
ExpectedJSON: "[\n {\n \"name\": \"default\",\n \"current\": false\n },\n {\n \"name\": \"test\",\n \"current\": true\n }\n]\n",
},
{
Name: "unset context",
Out: &bytes.Buffer{},
Context: "missing",
Contexts: map[string]any{
doctl.ArgDefaultContext: true,
"test": true,
},
ExpectedJSON: "[\n {\n \"name\": \"default\",\n \"current\": false\n },\n {\n \"name\": \"test\",\n \"current\": false\n }\n]\n",
},
}

for _, tc := range testCases {
t.Run(tc.Name, func(t *testing.T) {
displayAuthContextsJSON(tc.Out, tc.Context, tc.Contexts)
assert.Equal(t, tc.ExpectedJSON, tc.Out.String())
})
}
}
func TestTokenInputValidator(t *testing.T) {
tests := []struct {
name string
Expand Down
2 changes: 1 addition & 1 deletion commands/cdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The Time To Live (TTL) value is the length of time in seconds that a file is cac
CertIDDesc := "Specify a certificate ID for the custom domain"
cmdCDNList := CmdBuilder(cmd, RunCDNList, "list", "List CDNs that have already been created", `Retrieves a list of your existing Content Delivery Networks (CDNs) and their following details:`+CDNDetails, Writer,
aliasOpt("ls"), displayerType(&displayers.CDN{}))
cmdCDNList.Example = "doctl compute cdn list"
cmdCDNList.Example = `The following example retrieves a list of CDNs for your account. The command uses the ` + "`" + `--format` + "`" + ` flag to only return each CDN` + "`" + `'` + "`" + `s origin endpoint, CDN endpoint, and certificate ID: doctl compute cdn list --format ID,Origin,Endpoint,CertificateID`

cmdCDNCreate := CmdBuilder(cmd, RunCDNCreate, "create <cdn-origin>", "Create a CDN", `Creates a Content Delivery Network (CDN) on the origin server you specify and automatically generates an endpoint. You can also use a custom subdomain you own to create an additional endpoint, which must be secured with SSL.`+CDNnotes, Writer,
aliasOpt("c"), displayerType(&displayers.CDN{}))
Expand Down
16 changes: 15 additions & 1 deletion commands/certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ To upload a custom certificate, you need to provide a certificate name, the path
cmdCertificateList := CmdBuilder(cmd, RunCertificateList, "list", "Retrieve list of the account's stored certificates", `This command retrieves a list of all certificates associated with the account. The following details are shown for each certificate:`+certDetails, Writer,
aliasOpt("ls"), displayerType(&displayers.Certificate{}))
cmdCertificateList.Example = `The following example retrieves a list of all certificates associated with your account and uses the ` + "`" + `--format` + "`" + ` flag return only the IDs, names, and the domains associated with each ticket: doctl compute certificate list --format ID,Name,DNSNames`
AddStringFlag(cmdCertificateList, doctl.ArgCertificateName, "", "",
"Filter certificates by the specified name")

cmdCertificateDelete := CmdBuilder(cmd, RunCertificateDelete, "delete <id>",
"Delete the specified certificate", `Deletes the specified certificate.
Expand Down Expand Up @@ -184,8 +186,20 @@ func RunCertificateCreate(c *CmdConfig) error {

// RunCertificateList lists certificates.
func RunCertificateList(c *CmdConfig) error {

name, err := c.Doit.GetString(c.NS, doctl.ArgCertificateName)
if err != nil {
return err
}

cs := c.Certificates()
list, err := cs.List()
var list do.Certificates

if name == "" {
list, err = cs.List()
} else {
list, err = cs.ListByName(name)
}
if err != nil {
return err
}
Expand Down
11 changes: 11 additions & 0 deletions commands/certificates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,17 @@ func TestCertificateList(t *testing.T) {
})
}

func TestCertificateListByName(t *testing.T) {
withTestClient(t, func(config *CmdConfig, tm *tcMocks) {
name := "web-cert-01"
tm.certificates.EXPECT().ListByName(name).Return(testCertificateList, nil)

config.Doit.Set(config.NS, doctl.ArgCertificateName, name)
err := RunCertificateList(config)
assert.NoError(t, err)
})
}

func TestCertificateDelete(t *testing.T) {
withTestClient(t, func(config *CmdConfig, tm *tcMocks) {
cID := "892071a0-bb95-49bc-8021-3afd67a210bf"
Expand Down
2 changes: 1 addition & 1 deletion commands/command_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func (c *CmdConfig) Display(d displayers.Displayable) error {
return dc.Display()
}

// An urner implements the URN method, wihich returns a valid uniform resource
// An urner implements the URN method, which returns a valid uniform resource
// name.
type urner interface {
URN() string
Expand Down
Loading

0 comments on commit f471a39

Please sign in to comment.