Skip to content

Compute v2: Clean up availabilityzones - #466

Merged
jrperritt merged 1 commit into
gophercloud:masterfrom
jtopjian:computev2-az-cleanup
Aug 23, 2017
Merged

jrperritt merged 1 commit into
gophercloud:masterfrom
jtopjian:computev2-az-cleanup

Conversation

@jtopjian

Copy link
Copy Markdown
Contributor

For #465
For #446

@jtopjian
jtopjian requested a review from jrperritt August 13, 2017 21:09
@jtopjian
jtopjian force-pushed the computev2-az-cleanup branch from 80ae9e1 to c3c5d6e Compare August 13, 2017 21:43
@coveralls

coveralls commented Aug 13, 2017 •

Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 71.492% when pulling c3c5d6e on jtopjian:computev2-az-cleanup into 8a1afad on gophercloud:master.

type ServerExt struct {
// ServerAvailabilityZoneExt is an extension to the base Server result which
// includes the Availability Zone information.
type ServerAvailabilityZoneExt struct {

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'm OK with renaming these, but this is a mouthful, especially when it's used in user code. Here, it seems (to me) like availabilityzone.Ext is clear. I'd like to hear suggestions, with an eye toward keeping it succinct yet clear when used in user code.

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.

I agree that this one is a mouthful. Maybe ServerAZExt?

The naming pattern that I have in mind for these extensions is ParentType-Extension-Ext. The reason for this is to make sure the extension is easily recognizable with its parent type, since both will be under separate packages.

If this was named just AvailabilityZoneExt (or even AvailabilityZone), it wouldn't be immediately recognizable that it is intended to extend the Server result.

I suppose it's possible that an extension could be applied to more than one parent. I don't know if it's a good idea to enable/allow, that, though. That kind of flexibility might create confusion and odd ways of applying extensions (I don't have a specific extension in mind that is reusable, just thinking of a possible case).

With regard to availabilityzone.Ext, IIRC, there is an issue when embedded/anonymous structs have the same name. So something like this wouldn't work:

var foo struct {
  servers.Server
  availabilityzone.Ext
  tenantid.Ext
}

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.

there is an issue when embedded/anonymous structs have the same name

That's right, I remember now. I'm now in favor of this.

@jrperritt
jrperritt merged commit 25f4ca0 into gophercloud:master Aug 23, 2017
@jtopjian
jtopjian deleted the computev2-az-cleanup branch April 24, 2018 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants