Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attribute aliases work only partially #237

Open
Temikus opened this issue Jul 16, 2018 · 11 comments
Open

Attribute aliases work only partially #237

Temikus opened this issue Jul 16, 2018 · 11 comments
Labels

Comments

@Temikus
Copy link
Member

Temikus commented Jul 16, 2018

For example, we create a model with those attributes:

(#<Fog::Compute::Google::Network>)> attributes
=> {:name=>"fog-test-networkscol-9ca8d6cc-4686-4d3f-9cd2-8d28a9383154", :ipv4_range=>"10.240.133.0/24"}

When created actually turns into proper model fields:

=> {:name=>"fog-test-networkscol-9ca8d6cc-4686-4d3f-9cd2-8d28a9383154", :ipv4_range=>"10.240.133.0/24"}
my_network
=>   <Fog::Compute::Google::Network
    name="fog-test-networkscol-9ca8d6cc-4686-4d3f-9cd2-8d28a9383154",
    auto_create_subnetworks=nil,
    creation_timestamp="2018-04-12T22:59:17.787-07:00",
    description=nil,
    gateway_i_pv4="10.240.0.1",
    i_pv4_range="10.240.0.0/16",
    id=REDACTED,
    kind="compute#network",
    peerings=nil,
    routing_config={:routing_mode=>"REGIONAL"},
    self_link="https://www.googleapis.com/compute/v1/projects/REDACTED/global/networks/fog-test-networkscol-9ca8d6cc-4686-4d3f-9cd2-8d28a9383154",
    subnetworks=nil

But when I try to call it:

NoMethodError: undefined method `ipv4_range' for #<Fog::Compute::Google::Network:0x00007fe5221bae40>
Did you mean?  i_pv4_range
               i_pv4_range=
from (pry):3:in `test_network_workflow'```

It seems there is a bug - the alias mapping is only being done when doing a plain new object or reloading:

if self.class.aliases[key]

But the actual method setters don't:
https://github.com/fog/fog-core/tree/master/lib/fog/core/attributes

Maybe we should move that alias code to inside the setter definition or do an alias automatically?

@Temikus
Copy link
Member Author

Temikus commented Jul 16, 2018

This is a result of my chat with @plribeiro3000 earlier. Didn't have much time to look into it deeply to actually fix, but I feel this needs to at least be documented.

Temikus added a commit to Temikus/fog-google that referenced this issue Jul 16, 2018
Alias doesn’t work on .create, possibly related to: fog/fog-core#237
@plribeiro3000
Copy link
Member

I'm ok with doing a setter for the alias.

This is something i struggled myself in the past when working on fog-xenserver.

@geemus any thoughts?

@geemus
Copy link
Member

geemus commented Jul 23, 2018

Sounds reasonable to me, thanks!

@stale
Copy link

stale bot commented Sep 21, 2018

This issue has been automatically marked stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 21, 2018
@plribeiro3000
Copy link
Member

plribeiro3000 commented Sep 22, 2018 via email

@stale stale bot removed the wontfix label Sep 22, 2018
@stale
Copy link

stale bot commented Nov 21, 2018

This issue has been automatically marked stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Nov 21, 2018
@stale stale bot closed this as completed Nov 28, 2018
@plribeiro3000 plribeiro3000 reopened this Nov 28, 2018
@stale stale bot removed the wontfix label Nov 28, 2018
@stale
Copy link

stale bot commented Jan 27, 2019

This issue has been automatically marked stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 27, 2019
@stale stale bot closed this as completed Feb 4, 2019
@plribeiro3000 plribeiro3000 reopened this Feb 4, 2019
@stale stale bot closed this as completed Feb 11, 2019
@Temikus Temikus added pinned and removed wontfix labels Feb 13, 2019
@Temikus Temikus reopened this Feb 13, 2019
@Temikus
Copy link
Member Author

Temikus commented Feb 13, 2019

Reopening and pinning to deactivate stalebot as this looks like something @plribeiro3000 is working on.

If not - no worries, just close out.

@geemus
Copy link
Member

geemus commented Feb 13, 2019

Sounds good, thanks!

@plribeiro3000
Copy link
Member

@Temikus Not really working on this now but i would leave it open since it looks like something we should tackle.

@plribeiro3000
Copy link
Member

@Temikus Is this something you guys still need?

I will try to find some spare time to tackle this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants