parent
1c2dfda279
commit
8de0a3092e
3
Makefile
3
Makefile
|
@ -5,6 +5,9 @@ all:
|
|||
@echo a work in progress digital ocean control panel
|
||||
@echo
|
||||
|
||||
goimports:
|
||||
goimports -w *.go
|
||||
|
||||
redomod:
|
||||
rm -f go.*
|
||||
GO111MODULE= go mod init
|
||||
|
|
2
api.go
2
api.go
|
@ -3,8 +3,8 @@ package digitalocean
|
|||
import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/oauth2"
|
||||
"github.com/digitalocean/godo"
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
|
6
args.go
6
args.go
|
@ -3,7 +3,7 @@ package digitalocean
|
|||
// initializes logging and command line options
|
||||
|
||||
import (
|
||||
"go.wit.com/arg"
|
||||
"go.wit.com/dev/alexflint/arg"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
@ -19,10 +19,10 @@ type ArgsDo struct {
|
|||
|
||||
func init() {
|
||||
arg.Register(&argDo)
|
||||
full := "go.wit.com/gui/digitalocean"
|
||||
full := "go.wit.com/lib/gui/digitalocean"
|
||||
short := "DOgui"
|
||||
|
||||
NOW = log.NewFlag( "NOW", true, full, short, "temp debugging stuff")
|
||||
NOW = log.NewFlag("NOW", true, full, short, "temp debugging stuff")
|
||||
INFO = log.NewFlag("INFO", false, full, short, "normal debugging stuff")
|
||||
INFO = log.NewFlag("POLL", false, full, short, "show droplet status polling")
|
||||
}
|
||||
|
|
37
create.go
37
create.go
|
@ -3,11 +3,12 @@ package digitalocean
|
|||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"golang.org/x/oauth2"
|
||||
"github.com/digitalocean/godo"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gadgets"
|
||||
// "go.wit.com/gui"
|
||||
)
|
||||
|
||||
|
@ -114,7 +115,9 @@ var myCreate *windowCreate
|
|||
// This is initializes the main DO object
|
||||
// You can only have one of these
|
||||
func InitCreateWindow() *windowCreate {
|
||||
if ! myDo.Ready() {return nil}
|
||||
if !myDo.Ready() {
|
||||
return nil
|
||||
}
|
||||
if myCreate != nil {
|
||||
myCreate.Show()
|
||||
return myCreate
|
||||
|
@ -143,7 +146,7 @@ func InitCreateWindow() *windowCreate {
|
|||
log.Info("Skipping region. No available sizes region =", region.Name)
|
||||
} else {
|
||||
s := region.Name + " (" + region.Slug + ")"
|
||||
if (myCreate.regionSlug == "") {
|
||||
if myCreate.regionSlug == "" {
|
||||
myCreate.regionSlug = region.Slug
|
||||
}
|
||||
myCreate.region.Add(s)
|
||||
|
@ -205,15 +208,15 @@ func InitCreateWindow() *windowCreate {
|
|||
|
||||
// box := myCreate.group.NewBox("vBox", false).Pad()
|
||||
box := myCreate.group.NewBox("hBox", true).Pad()
|
||||
box.NewButton("Cancel", func () {
|
||||
box.NewButton("Cancel", func() {
|
||||
myCreate.Hide()
|
||||
})
|
||||
box.NewButton("Create", func () {
|
||||
box.NewButton("Create", func() {
|
||||
name := myCreate.name.Get()
|
||||
size := myCreate.size.Get()
|
||||
region := myCreate.regionSlug
|
||||
image := myCreate.image.Get()
|
||||
if (region == "") {
|
||||
if region == "" {
|
||||
log.Info("Create() droplet name =", name, "region =", region, "size =", size, "image", image)
|
||||
log.Info("Create() region lookup failed")
|
||||
return
|
||||
|
@ -230,7 +233,9 @@ func InitCreateWindow() *windowCreate {
|
|||
|
||||
// Find the size
|
||||
func (d *windowCreate) UpdateSize() {
|
||||
if ! d.Ready() {return}
|
||||
if !d.Ready() {
|
||||
return
|
||||
}
|
||||
log.Info("Now find the size. sizes count =", len(myCreate.regionSelected.Sizes))
|
||||
var s string
|
||||
m := myCreate.memory.Get()
|
||||
|
@ -270,12 +275,16 @@ func (d *windowCreate) UpdateSize() {
|
|||
|
||||
// Returns true if the status is valid
|
||||
func (d *windowCreate) Ready() bool {
|
||||
if d == nil {return false}
|
||||
if d == nil {
|
||||
return false
|
||||
}
|
||||
return d.ready
|
||||
}
|
||||
|
||||
func (d *windowCreate) Show() {
|
||||
if ! d.Ready() {return}
|
||||
if !d.Ready() {
|
||||
return
|
||||
}
|
||||
log.Info("digitalocean.Show() window")
|
||||
if d.hidden {
|
||||
d.window.Show()
|
||||
|
@ -284,9 +293,11 @@ func (d *windowCreate) Show() {
|
|||
}
|
||||
|
||||
func (d *windowCreate) Hide() {
|
||||
if ! d.Ready() {return}
|
||||
if !d.Ready() {
|
||||
return
|
||||
}
|
||||
log.Info("digitalocean.Hide() window")
|
||||
if ! d.hidden {
|
||||
if !d.hidden {
|
||||
d.window.Hide()
|
||||
}
|
||||
d.hidden = true
|
||||
|
|
121
droplet.go
121
droplet.go
|
@ -3,8 +3,9 @@ package digitalocean
|
|||
import (
|
||||
"errors"
|
||||
"sort"
|
||||
"strings"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
|
||||
"go.wit.com/log"
|
||||
|
@ -12,10 +13,12 @@ import (
|
|||
)
|
||||
|
||||
func (d *DigitalOcean) NewDroplet(dd *godo.Droplet) *Droplet {
|
||||
if ! myDo.Ready() {return nil}
|
||||
if !myDo.Ready() {
|
||||
return nil
|
||||
}
|
||||
|
||||
// check if the droplet ID already exists
|
||||
if (d.dropMap[dd.ID] != nil) {
|
||||
if d.dropMap[dd.ID] != nil {
|
||||
log.Error(errors.New("droplet.NewDroplet() already exists"))
|
||||
return d.dropMap[dd.ID]
|
||||
}
|
||||
|
@ -26,7 +29,7 @@ func (d *DigitalOcean) NewDroplet(dd *godo.Droplet) *Droplet {
|
|||
droplet.ID = dd.ID
|
||||
droplet.image = dd.Image.Name + " (" + dd.Image.Slug + ")"
|
||||
|
||||
if (d.dGrid == nil) {
|
||||
if d.dGrid == nil {
|
||||
d.dGrid = d.group.NewGrid("grid", 12, 1).Pad()
|
||||
}
|
||||
|
||||
|
@ -56,23 +59,23 @@ func (d *DigitalOcean) NewDroplet(dd *godo.Droplet) *Droplet {
|
|||
droplet.imageN = d.dGrid.NewLabel(dd.Image.Slug)
|
||||
droplet.statusN = d.dGrid.NewLabel(dd.Status)
|
||||
|
||||
droplet.connect = d.dGrid.NewButton("Connect", func () {
|
||||
droplet.connect = d.dGrid.NewButton("Connect", func() {
|
||||
droplet.Connect()
|
||||
})
|
||||
|
||||
droplet.edit = d.dGrid.NewButton("Edit", func () {
|
||||
droplet.edit = d.dGrid.NewButton("Edit", func() {
|
||||
droplet.Show()
|
||||
})
|
||||
|
||||
droplet.poweroff = d.dGrid.NewButton("Power Off", func () {
|
||||
droplet.poweroff = d.dGrid.NewButton("Power Off", func() {
|
||||
droplet.PowerOff()
|
||||
})
|
||||
|
||||
droplet.poweron = d.dGrid.NewButton("Power On", func () {
|
||||
droplet.poweron = d.dGrid.NewButton("Power On", func() {
|
||||
droplet.PowerOn()
|
||||
})
|
||||
|
||||
droplet.destroy = d.dGrid.NewButton("Destroy", func () {
|
||||
droplet.destroy = d.dGrid.NewButton("Destroy", func() {
|
||||
droplet.Destroy()
|
||||
})
|
||||
|
||||
|
@ -81,9 +84,11 @@ func (d *DigitalOcean) NewDroplet(dd *godo.Droplet) *Droplet {
|
|||
}
|
||||
|
||||
func (d *Droplet) Active() bool {
|
||||
if ! d.Ready() {return false}
|
||||
if !d.Ready() {
|
||||
return false
|
||||
}
|
||||
log.Log(POLL, "droplet.Active() status: ", d.poll.Status, "d.statusN.GetText() =", d.statusN.GetText())
|
||||
if (d.statusN.GetText() == "active") {
|
||||
if d.statusN.GetText() == "active" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
@ -91,25 +96,33 @@ func (d *Droplet) Active() bool {
|
|||
|
||||
// Returns true if the droplet is finished installing
|
||||
func (d *Droplet) Ready() bool {
|
||||
if d == nil {return false}
|
||||
if d == nil {
|
||||
return false
|
||||
}
|
||||
return d.ready
|
||||
}
|
||||
|
||||
// Returns true if the droplet is running
|
||||
func (d *Droplet) On() bool {
|
||||
if ! d.Ready() {return false}
|
||||
if !d.Ready() {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (d *Droplet) HasIPv4() bool {
|
||||
if ! d.Ready() {return false}
|
||||
if !d.Ready() {
|
||||
return false
|
||||
}
|
||||
if d.ipv4.GetText() == "" {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
func (d *Droplet) HasIPv6() bool {
|
||||
if ! d.Ready() {return false}
|
||||
if !d.Ready() {
|
||||
return false
|
||||
}
|
||||
if d.ipv6.GetText() == "" {
|
||||
return false
|
||||
}
|
||||
|
@ -117,18 +130,24 @@ func (d *Droplet) HasIPv6() bool {
|
|||
}
|
||||
|
||||
func (d *Droplet) GetIPv4() string {
|
||||
if ! d.Ready() {return ""}
|
||||
if !d.Ready() {
|
||||
return ""
|
||||
}
|
||||
return d.ipv4.GetText()
|
||||
}
|
||||
|
||||
func (d *Droplet) GetIPv6() string {
|
||||
if ! d.Ready() {return ""}
|
||||
if !d.Ready() {
|
||||
return ""
|
||||
}
|
||||
log.Info("droplet GetIPv6 has: n.GetText()", d.ipv6.GetText())
|
||||
return d.ipv6.GetText()
|
||||
}
|
||||
|
||||
func (d *Droplet) Connect() {
|
||||
if ! d.Ready() {return}
|
||||
if !d.Ready() {
|
||||
return
|
||||
}
|
||||
if d.HasIPv4() {
|
||||
ipv4 := d.GetIPv4()
|
||||
log.Info("droplet has IPv4 =", ipv4)
|
||||
|
@ -145,7 +164,9 @@ func (d *Droplet) Connect() {
|
|||
}
|
||||
|
||||
func (d *Droplet) Update(dpoll *godo.Droplet) {
|
||||
if ! d.Exists() {return}
|
||||
if !d.Exists() {
|
||||
return
|
||||
}
|
||||
d.poll = dpoll
|
||||
log.Log(POLL, "droplet", dpoll.Name, "dpoll.Status =", dpoll.Status)
|
||||
log.Spew(dpoll)
|
||||
|
@ -164,25 +185,31 @@ func (d *Droplet) Update(dpoll *godo.Droplet) {
|
|||
}
|
||||
|
||||
func (d *Droplet) PowerOn() {
|
||||
if ! d.Exists() {return}
|
||||
if !d.Exists() {
|
||||
return
|
||||
}
|
||||
log.Info("droplet.PowerOn() should do it here")
|
||||
myDo.PowerOn(d.ID)
|
||||
}
|
||||
|
||||
func (d *Droplet) PowerOff() {
|
||||
if ! d.Exists() {return}
|
||||
if !d.Exists() {
|
||||
return
|
||||
}
|
||||
log.Info("droplet.PowerOff() here")
|
||||
myDo.PowerOff(d.ID)
|
||||
}
|
||||
|
||||
func (d *Droplet) Destroy() {
|
||||
if ! d.Exists() {return}
|
||||
if !d.Exists() {
|
||||
return
|
||||
}
|
||||
log.Info("droplet.Destroy() ID =", d.ID, "Name =", d.nameN.GetText())
|
||||
myDo.deleteDroplet(d)
|
||||
}
|
||||
|
||||
/*
|
||||
type Droplet struct {
|
||||
type Droplet struct {
|
||||
ID int `json:"id,float64,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Memory int `json:"memory,omitempty"`
|
||||
|
@ -204,10 +231,12 @@ type Droplet struct {
|
|||
Tags []string `json:"tags,omitempty"`
|
||||
VolumeIDs []string `json:"volume_ids"`
|
||||
VPCUUID string `json:"vpc_uuid,omitempty"`
|
||||
}
|
||||
}
|
||||
*/
|
||||
func (d *Droplet) Show() {
|
||||
if ! d.Exists() {return}
|
||||
if !d.Exists() {
|
||||
return
|
||||
}
|
||||
log.Info("droplet: ID =", d.ID)
|
||||
log.Info("droplet: Name =", d.GetName())
|
||||
log.Info("droplet: Size =", d.GetSize())
|
||||
|
@ -220,47 +249,67 @@ func (d *Droplet) Show() {
|
|||
}
|
||||
|
||||
func (d *Droplet) Hide() {
|
||||
if ! d.Exists() {return}
|
||||
if !d.Exists() {
|
||||
return
|
||||
}
|
||||
log.Info("droplet.Hide() window")
|
||||
if ! d.hidden {
|
||||
if !d.hidden {
|
||||
// d.window.Hide()
|
||||
}
|
||||
d.hidden = true
|
||||
}
|
||||
|
||||
func (d *Droplet) Exists() bool {
|
||||
if ! myDo.Ready() {return false}
|
||||
if d == nil {return false}
|
||||
if d.poll == nil {return false}
|
||||
if !myDo.Ready() {
|
||||
return false
|
||||
}
|
||||
if d == nil {
|
||||
return false
|
||||
}
|
||||
if d.poll == nil {
|
||||
return false
|
||||
}
|
||||
return d.ready
|
||||
}
|
||||
|
||||
func (d *Droplet) GetName() string {
|
||||
if ! d.Ready() {return ""}
|
||||
if !d.Ready() {
|
||||
return ""
|
||||
}
|
||||
return d.nameN.GetText()
|
||||
}
|
||||
|
||||
func (d *Droplet) GetSize() string {
|
||||
if ! d.Ready() {return ""}
|
||||
if !d.Ready() {
|
||||
return ""
|
||||
}
|
||||
return d.sizeSlugN.GetText()
|
||||
}
|
||||
|
||||
func (d *Droplet) GetMemory() string {
|
||||
if ! d.Ready() {return ""}
|
||||
if !d.Ready() {
|
||||
return ""
|
||||
}
|
||||
return strconv.Itoa(d.memory)
|
||||
}
|
||||
|
||||
func (d *Droplet) GetDisk() string {
|
||||
if ! d.Ready() {return ""}
|
||||
if !d.Ready() {
|
||||
return ""
|
||||
}
|
||||
return strconv.Itoa(d.disk)
|
||||
}
|
||||
|
||||
func (d *Droplet) GetImage() string {
|
||||
if ! d.Ready() {return ""}
|
||||
if !d.Ready() {
|
||||
return ""
|
||||
}
|
||||
return d.imageN.GetText()
|
||||
}
|
||||
|
||||
func (d *Droplet) GetStatus() string {
|
||||
if ! d.Ready() {return ""}
|
||||
if !d.Ready() {
|
||||
return ""
|
||||
}
|
||||
return d.statusN.GetText()
|
||||
}
|
||||
|
|
14
go.mod
14
go.mod
|
@ -1,26 +1,24 @@
|
|||
module go.wit.com/gui/lib/digitalocean
|
||||
module go.wit.com/lib/gui/digitalocean
|
||||
|
||||
go 1.21.4
|
||||
|
||||
require (
|
||||
github.com/digitalocean/godo v1.108.0
|
||||
go.wit.com/arg v1.4.4
|
||||
go.wit.com/gui/gadgets v0.12.5
|
||||
go.wit.com/gui/gui v0.12.10
|
||||
go.wit.com/log v0.5.5
|
||||
go.wit.com/dev/alexflint/arg v1.4.5
|
||||
go.wit.com/gui v0.13.11
|
||||
go.wit.com/lib/gadgets v0.13.0
|
||||
go.wit.com/log v0.5.6
|
||||
golang.org/x/oauth2 v0.16.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/alexflint/go-scalar v1.2.0 // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-retryablehttp v0.7.4 // indirect
|
||||
go.wit.com/dev/alexflint/arg v1.4.5 // indirect
|
||||
go.wit.com/dev/alexflint/scalar v1.2.1 // indirect
|
||||
go.wit.com/dev/davecgh/spew v1.1.4 // indirect
|
||||
go.wit.com/gui/widget v1.1.3 // indirect
|
||||
go.wit.com/widget v1.1.6 // indirect
|
||||
golang.org/x/net v0.20.0 // indirect
|
||||
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
|
||||
google.golang.org/appengine v1.6.7 // indirect
|
||||
|
|
20
go.sum
20
go.sum
|
@ -1,5 +1,3 @@
|
|||
github.com/alexflint/go-scalar v1.2.0 h1:WR7JPKkeNpnYIOfHRa7ivM21aWAdHD0gEWHCx+WQBRw=
|
||||
github.com/alexflint/go-scalar v1.2.0/go.mod h1:LoFvNMqS1CPrMVltza4LvnGKhaSpc3oyLEBUZVhhS2o=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/digitalocean/godo v1.108.0 h1:fWyMENvtxpCpva1UbKzOFnyAS04N1FNuBWWfPeTGquQ=
|
||||
|
@ -25,22 +23,20 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
go.wit.com/arg v1.4.4 h1:nfW8JUsVfyXi5l3BlTq5GGhesLlnyh3ICIm8cpM2U8w=
|
||||
go.wit.com/arg v1.4.4/go.mod h1:P2JoYIsJ9SSvp45qSnYibQEQPNTuTB8dTkyT9y1btsI=
|
||||
go.wit.com/dev/alexflint/arg v1.4.5 h1:asDx5f9IlfpknKjPBqqb2qndE91Pbo7ZDkWUgddfMhY=
|
||||
go.wit.com/dev/alexflint/arg v1.4.5/go.mod h1:wnWc+c6z8kSdDKYriMf6RpM+FiXmo5RYp/t4FNi0MU0=
|
||||
go.wit.com/dev/alexflint/scalar v1.2.1 h1:loXOcbVnd+8YeJRLey+XXidecBiedMDO00zQ26TvKNs=
|
||||
go.wit.com/dev/alexflint/scalar v1.2.1/go.mod h1:+rYsfxqdI2cwA8kJ7GCMwWbNJvfvWUurOCXLiwdTtSs=
|
||||
go.wit.com/dev/davecgh/spew v1.1.4 h1:C9hj/rjlUpdK+E6aroyLjCbS5MFcyNUOuP1ICLWdNek=
|
||||
go.wit.com/dev/davecgh/spew v1.1.4/go.mod h1:sihvWmnQ/09FWplnEmozt90CCVqBtGuPXM811tgfhFA=
|
||||
go.wit.com/gui/gadgets v0.12.5 h1:Eg7UbwnvwGgYlNX+sgKQNVcbRMZyYL4ChDmS2p/DHtM=
|
||||
go.wit.com/gui/gadgets v0.12.5/go.mod h1:OB7MtEZy/VK2HrU3yiEuzY9n4LjZwO0L06NYUAFybJs=
|
||||
go.wit.com/gui/gui v0.12.10 h1:52wFdTqB/GpsFKYFTUvSbHQWNEXz114lhvTfMVrXpYM=
|
||||
go.wit.com/gui/gui v0.12.10/go.mod h1:YgbFWxsGqZb45oLGaHim2GukPzPgMLQcVRRI0QkrGS8=
|
||||
go.wit.com/gui/widget v1.1.3 h1:GvLzGSOF9tfmoh6HNbFdN+NSlBo2qeS/Ba2TnQQ1A1U=
|
||||
go.wit.com/gui/widget v1.1.3/go.mod h1:A6/FaiFQtAHTjgo7c4FrokXe6bXX1Cowo35b2Lgi31E=
|
||||
go.wit.com/log v0.5.5 h1:bK3b94uVKgev4jB5wg06FnvCFBEapQICTSH2YW+CWr4=
|
||||
go.wit.com/log v0.5.5/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
|
||||
go.wit.com/gui v0.13.11 h1:d74Ko/XFZYR25P/AZfCQaVO2CuGh1BSjdUp1wjktdDg=
|
||||
go.wit.com/gui v0.13.11/go.mod h1:v2VgnOL3dlZ13KclYeedZ1cd20nQdvwjyJTNKvFX3DA=
|
||||
go.wit.com/lib/gadgets v0.13.0 h1:jtsEnf4DHqAxBxuYsaDlHti73rgaxYf/ffAXNB1PJAk=
|
||||
go.wit.com/lib/gadgets v0.13.0/go.mod h1:xidaHAL6Nk9+M9FkySVU1AG5i39v7T3PuFphUos6LxE=
|
||||
go.wit.com/log v0.5.6 h1:rDC3ju95zfEads4f1Zm+QMkqjZ39CsYAT/UmQQs7VP4=
|
||||
go.wit.com/log v0.5.6/go.mod h1:BaJBfHFqcJSJLXGQ9RHi3XVhPgsStxSMZRlaRxW4kAo=
|
||||
go.wit.com/widget v1.1.6 h1:av2miF5vlohMfARA/QGPTPfgW/ADup1c+oeAOKgroPY=
|
||||
go.wit.com/widget v1.1.6/go.mod h1:I8tnD3x3ECbB/CRNnLCdC+uoyk7rK0AEkzK1bQYSqoQ=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||
|
|
|
@ -2,8 +2,9 @@ package digitalocean
|
|||
|
||||
import (
|
||||
"context"
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
"github.com/digitalocean/godo"
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
|
27
new.go
27
new.go
|
@ -2,8 +2,9 @@ package digitalocean
|
|||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/log"
|
||||
"go.wit.com/gui/gui"
|
||||
)
|
||||
|
||||
var myDo *DigitalOcean
|
||||
|
@ -11,7 +12,9 @@ var myDo *DigitalOcean
|
|||
// This is initializes the main DO object
|
||||
// You can only have one of these
|
||||
func New(p *gui.Node) *DigitalOcean {
|
||||
if myDo != nil {return myDo}
|
||||
if myDo != nil {
|
||||
return myDo
|
||||
}
|
||||
myDo = new(DigitalOcean)
|
||||
myDo.ready = false
|
||||
myDo.parent = p
|
||||
|
@ -34,12 +37,16 @@ func New(p *gui.Node) *DigitalOcean {
|
|||
|
||||
// Returns true if the status is valid
|
||||
func (d *DigitalOcean) Ready() bool {
|
||||
if d == nil {return false}
|
||||
if d == nil {
|
||||
return false
|
||||
}
|
||||
return d.ready
|
||||
}
|
||||
|
||||
func (d *DigitalOcean) Show() {
|
||||
if ! d.Ready() {return}
|
||||
if !d.Ready() {
|
||||
return
|
||||
}
|
||||
log.Info("digitalocean.Show() window")
|
||||
if d.hidden {
|
||||
d.window.Show()
|
||||
|
@ -48,21 +55,25 @@ func (d *DigitalOcean) Show() {
|
|||
}
|
||||
|
||||
func (d *DigitalOcean) Hide() {
|
||||
if ! d.Ready() {return}
|
||||
if !d.Ready() {
|
||||
return
|
||||
}
|
||||
log.Info("digitalocean.Hide() window")
|
||||
if ! d.hidden {
|
||||
if !d.hidden {
|
||||
d.window.Hide()
|
||||
}
|
||||
d.hidden = true
|
||||
}
|
||||
|
||||
func (d *DigitalOcean) Update() bool {
|
||||
if ! d.Ready() {return false}
|
||||
if !d.Ready() {
|
||||
return false
|
||||
}
|
||||
d.ListSSHKeyID()
|
||||
if d.ListDroplets() {
|
||||
for _, droplet := range d.dpolled {
|
||||
// check if the droplet ID already exists
|
||||
if (d.dropMap[droplet.ID] == nil) {
|
||||
if d.dropMap[droplet.ID] == nil {
|
||||
d.dropMap[droplet.ID] = d.NewDroplet(&droplet)
|
||||
} else {
|
||||
log.Log(POLL, "droplet.Update()", droplet.ID, droplet.Name, "already exists")
|
||||
|
|
|
@ -7,8 +7,8 @@ package digitalocean
|
|||
import (
|
||||
"github.com/digitalocean/godo"
|
||||
|
||||
"go.wit.com/gui/gui"
|
||||
"go.wit.com/gui/gadgets"
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
)
|
||||
|
||||
type DigitalOcean struct {
|
||||
|
|
Loading…
Reference in New Issue