Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions commands/command_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ type CmdConfig struct {
componentBuilderFactory builder.ComponentBuilderFactory

// services
Keys func() do.KeysService
Sizes func() do.SizesService
Regions func() do.RegionsService
Images func() do.ImagesService
ImageActions func() do.ImageActionsService
LoadBalancers func() do.LoadBalancersService
ReservedIPs func() do.ReservedIPsService
ReservedIPActions func() do.ReservedIPActionsService
ReservedIPv6s func() do.ReservedIPv6sService
BYOIPPrefixes func() do.BYOIPPrefixsService
Keys func() do.KeysService
Sizes func() do.SizesService
Regions func() do.RegionsService
Images func() do.ImagesService
ImageActions func() do.ImageActionsService
LoadBalancers func() do.LoadBalancersService
MicroDroplets func() do.MicroDropletsService
MicroDropletImages func() do.MicroDropletImagesService
ReservedIPs func() do.ReservedIPsService
ReservedIPActions func() do.ReservedIPActionsService
ReservedIPv6s func() do.ReservedIPv6sService
BYOIPPrefixes func() do.BYOIPPrefixsService

Droplets func() do.DropletsService
DropletActions func() do.DropletActionsService
Expand Down Expand Up @@ -164,6 +166,10 @@ func NewCmdConfig(ns string, dc doctl.Config, out io.Writer, args []string, init
}
c.Nfs = func() do.NfsService { return do.NewNfsService(godoClient) }
c.NfsActions = func() do.NfsActionsService { return do.NewNfsActionsService(godoClient) }
c.MicroDroplets = func() do.MicroDropletsService { return do.NewMicroDropletsService(godoClient) }
c.MicroDropletImages = func() do.MicroDropletImagesService {
return do.NewMicroDropletImagesService(godoClient)
}
c.Security = func() do.SecurityService { return do.NewSecurityService(godoClient) }
c.Secrets = func() do.SecretsService { return do.NewSecretsService(godoClient) }
return nil
Expand Down
6 changes: 6 additions & 0 deletions commands/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ type tcMocks struct {
inference *domocks.MockInferenceService
nfs *domocks.MockNfsService
nfsActions *domocks.MockNfsActionsService
microDroplets *domocks.MockMicroDropletsService
microDropletImages *domocks.MockMicroDropletImagesService
security *domocks.MockSecurityService
secrets *domocks.MockSecretsService
vectorDBs *domocks.MockVectorDBsService
Expand Down Expand Up @@ -358,6 +360,8 @@ func withTestClient(t *testing.T, tFn testFn) {
inference: domocks.NewMockInferenceService(ctrl),
nfs: domocks.NewMockNfsService(ctrl),
nfsActions: domocks.NewMockNfsActionsService(ctrl),
microDroplets: domocks.NewMockMicroDropletsService(ctrl),
microDropletImages: domocks.NewMockMicroDropletImagesService(ctrl),
security: domocks.NewMockSecurityService(ctrl),
secrets: domocks.NewMockSecretsService(ctrl),
vectorDBs: domocks.NewMockVectorDBsService(ctrl),
Expand Down Expand Up @@ -428,6 +432,8 @@ func withTestClient(t *testing.T, tFn testFn) {
Inference: func() do.InferenceService { return tm.inference },
Nfs: func() do.NfsService { return tm.nfs },
NfsActions: func() do.NfsActionsService { return tm.nfsActions },
MicroDroplets: func() do.MicroDropletsService { return tm.microDroplets },
MicroDropletImages: func() do.MicroDropletImagesService { return tm.microDropletImages },
Security: func() do.SecurityService { return tm.security },
Secrets: func() do.SecretsService { return tm.secrets },
VectorDBs: func() do.VectorDBsService { return tm.vectorDBs },
Expand Down
112 changes: 112 additions & 0 deletions commands/displayers/micro_droplet.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
Copyright 2025 The Doctl Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package displayers

import (
"io"

"github.com/digitalocean/doctl/do"
)

type MicroDroplet struct {
MicroDroplets do.MicroDroplets
}

var _ Displayable = &MicroDroplet{}

func (m *MicroDroplet) JSON(out io.Writer) error {
return writeJSON(m.MicroDroplets, out)
}

func (m *MicroDroplet) Cols() []string {
return []string{
"ID", "Name", "Region", "State", "Size", "Networking", "Image", "Endpoint", "Created",
}
}

func (m *MicroDroplet) ColMap() map[string]string {
return map[string]string{
"ID": "ID",
"Name": "Name",
"Region": "Region",
"State": "State",
"Size": "Size",
"Networking": "Networking",
"Image": "Image",
"Endpoint": "Endpoint",
"Created": "Created At",
}
}

func (m *MicroDroplet) KV() []map[string]any {
out := make([]map[string]any, 0, len(m.MicroDroplets))
for _, md := range m.MicroDroplets {
out = append(out, map[string]any{
"ID": md.ID,
"Name": md.Name,
"Region": md.Region,
"State": string(md.State),
"Size": md.Size,
"Networking": string(md.Networking),
"Image": md.Image,
"Endpoint": md.Endpoint,
"Created": md.Created,
})
}
return out
}

type MicroDropletSnapshot struct {
Snapshots do.MicroDropletSnapshots
}

var _ Displayable = &MicroDropletSnapshot{}

func (s *MicroDropletSnapshot) JSON(out io.Writer) error {
return writeJSON(s.Snapshots, out)
}

func (s *MicroDropletSnapshot) Cols() []string {
return []string{
"ID", "MicroDropletID", "Name", "Status", "MemoryBytes", "DiskBytes", "Created",
}
}

func (s *MicroDropletSnapshot) ColMap() map[string]string {
return map[string]string{
"ID": "ID",
"MicroDropletID": "MicroDroplet ID",
"Name": "Name",
"Status": "Status",
"MemoryBytes": "Memory Bytes",
"DiskBytes": "Disk Bytes",
"Created": "Created At",
}
}

func (s *MicroDropletSnapshot) KV() []map[string]any {
out := make([]map[string]any, 0, len(s.Snapshots))
for _, snap := range s.Snapshots {
out = append(out, map[string]any{
"ID": snap.ID,
"MicroDropletID": snap.MicroDropletID,
"Name": snap.Name,
"Status": string(snap.Status),
"MemoryBytes": snap.MemoryBytes,
"DiskBytes": snap.DiskBytes,
"Created": snap.Created,
})
}
return out
}
58 changes: 58 additions & 0 deletions commands/displayers/micro_droplet_image.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright 2025 The Doctl Authors All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package displayers

import (
"io"

"github.com/digitalocean/doctl/do"
)

type MicroDropletImage struct {
Images do.MicroDropletImages
}

var _ Displayable = &MicroDropletImage{}

func (i *MicroDropletImage) JSON(out io.Writer) error {
return writeJSON(i.Images, out)
}

func (i *MicroDropletImage) Cols() []string {
return []string{"ID", "Name", "Source", "Status", "Created"}
}

func (i *MicroDropletImage) ColMap() map[string]string {
return map[string]string{
"ID": "ID",
"Name": "Name",
"Source": "Source",
"Status": "Status",
"Created": "Created At",
}
}

func (i *MicroDropletImage) KV() []map[string]any {
out := make([]map[string]any, 0, len(i.Images))
for _, img := range i.Images {
out = append(out, map[string]any{
"ID": img.ID,
"Name": img.Name,
"Source": img.Source,
"Status": string(img.Status),
"Created": img.Created,
})
}
return out
}
1 change: 1 addition & 0 deletions commands/doit.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ func computeCmd() *Command {
cmd.AddCommand(Droplet())
cmd.AddCommand(DropletAutoscale())
cmd.AddCommand(Domain())
cmd.AddCommand(MicroDroplet())
cmd.AddCommand(VPCNATGateway())
cmd.AddCommand(Firewall())
cmd.AddCommand(ReservedIP())
Expand Down
Loading
Loading