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

Action 'delete' is already defined on DropletKit::CDNResource #305

Open
ivs opened this issue Oct 4, 2022 · 2 comments
Open

Action 'delete' is already defined on DropletKit::CDNResource #305

ivs opened this issue Oct 4, 2022 · 2 comments

Comments

@ivs
Copy link

ivs commented Oct 4, 2022

Hi! Any call to droplet_kit api gives me this error:

ArgumentError: Action 'delete' is already defined on `DropletKit::CDNResource`
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/resource_kit-0.1.8/lib/resource_kit/method_factory.rb:6:in `block in construct'
C:/Ruby31-x64/lib/ruby/3.1.0/forwardable.rb:238:in `each'
C:/Ruby31-x64/lib/ruby/3.1.0/forwardable.rb:238:in `each'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/resource_kit-0.1.8/lib/resource_kit/method_factory.rb:4:in `construct'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/resource_kit-0.1.8/lib/resource_kit/resource.rb:20:in `resources'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/droplet_kit-3.18.0/lib/droplet_kit/resources/cdn_resource.rb:7:in `<class:CDNResource>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/droplet_kit-3.18.0/lib/droplet_kit/resources/cdn_resource.rb:4:in `<module:DropletKit>'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/droplet_kit-3.18.0/lib/droplet_kit/resources/cdn_resource.rb:3:in `<top (required)>'
<internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:96:in `require'
<internal:C:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:96:in `require'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/droplet_kit-3.18.0/lib/droplet_kit/client.rb:34:in `resources'
C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/droplet_kit-3.18.0/lib/droplet_kit/client.rb:69:in `method_missing'

I've commented out this exception in resource_kit/method_factory.rb like this:

module ResourceKit
  class MethodFactory
    def self.construct(object, resource_collection, invoker = ActionInvoker)
      resource_collection.each do |action|
        if object.method_defined?(action.name)
          # raise ArgumentError, "Action '#{action.name}' is already defined on `#{object}`"
          next
        end

And it works fine. Exception raised for delete action for each resource.

@andrewsomething
Copy link
Member

Hi @ivs,

I am unable to reproduce this issue. Can you share anything more about your code and environment that might help use reproduce the problem?

@ivs
Copy link
Author

ivs commented Oct 10, 2022

I'm using lib from capistrano like this:

require "droplet_kit"
do_client = DropletKit::Client.new(access_token: '')
task :create_nodes do
    locations = ['nyc3', 'lon1', 'lon1']
    locations.each_with_index do |loc, i|
        droplet = DropletKit::Droplet.new(name: "relay#{i}", region: loc, image: 'ubuntu-22-04-x64', size: 's-1vcpu-1gb', tags: ["web"], ssh_keys: [123])   
        do_client.droplets.create droplet
    end
end

Capistrano Version: 3.17.1 (Rake Version: 13.0.6)

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

No branches or pull requests

2 participants