Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

provider/do: add support for Digital Ocean - #9187

Merged
cihangir merged 2 commits into
masterfrom
provider-do
Oct 3, 2016
Merged

provider/do: add support for Digital Ocean#9187
cihangir merged 2 commits into
masterfrom
provider-do

Conversation

@rjeczalik

Copy link
Copy Markdown
Contributor

No description provided.

@cihangir
cihangir merged commit ce0780c into master Oct 3, 2016
@cihangir
cihangir deleted the provider-do branch October 3, 2016 22:16
@cihangir

cihangir commented Oct 3, 2016

Copy link
Copy Markdown
Contributor

🎉

@ppknap ppknap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly small issues :)

return nil, err
}

if err := waitForAction(ctx, m.client, action); err != nil {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better to use waitstate package to wait for machinestate.Running state? It is used in AWS provider here and seems like it was written exactly for this job. Moreover, I think that it's better to have consistent logic across all providers for starting/stopping machines.

debug := false
if debug {
start := time.Now()
log.Println("waiting for action to finish: ", action.ID)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather we handled all the logging in dependency injected Logger. wdyt?

if action.CompletedAt != nil || action.Status == actionCompleted {
return nil
}
case <-ctx.Done():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question: do we have any context cancellation logic?

@rjeczalik rjeczalik Oct 3, 2016

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No we don't, moreover contexts are used wrongly - for storing global-scoped data. I'm in ongoing effort to have that all fixed.

t.Run(test.name, func(t *testing.T) {
dropletID := 12345
if test.dropletID != 0 {
dropletID = 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't be dropletID = test.dropletID ?

"droplet_id": strconv.Itoa(dropletID),
},
}),
Provider: "do",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do or digitalocean ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i was not sure if this field is used to create terraform template where they use digitalocean as a prefix link.

return errors.New("size cannot be empty")
}

if m.Region == "" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this check be implemented by Region type itself?

// isValid checks whether the given region is valid or not
func (r Region) isValid() bool {
for _, validRegion := range validRegions {
if validRegion == string(r) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a bug but var validRegion = []Region{ /* .... */ } will drop this type casting.

import "testing"

func TestCredential_Valid(t *testing.T) {
cred := &Credential{

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another (small) note: all tests in this file could be merged into one with table style fashion.

droplet["ssh_keys"] = []int{keyID}
} else if keyIds, ok := s.([]int); ok {
keys := []int{keyID}
if len(keyIds) != 0 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

even var keyIds []int = nil can be expanded keyIds... so no need for this check.

labels := []string{dropletName}
if count > 1 {
for i := 0; i < count; i++ {
labels = append(labels, fmt.Sprintf("%s.%d", dropletName, i))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm if count = 2 then we will have labels = []string{"droplet", "droplet.0", "droplet.1"}. Doesn't seem right.

@rjeczalik

rjeczalik commented Oct 4, 2016

Copy link
Copy Markdown
Contributor Author

Mostly small issues

@ppknap All valid, will address them in separate PR after #9182.

This was referenced Nov 21, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants