Class: Actions::Katello::Repository::Discover

Inherits:
EntryAction
  • Object
show all
Includes:
Dynflow::Action::Cancellable, EncryptValue
Defined in:
app/lib/actions/katello/repository/discover.rb

Instance Method Summary collapse

Instance Method Details

#plan(url, content_type, upstream_username, upstream_password, search) ⇒ Object



20
21
22
23
# File 'app/lib/actions/katello/repository/discover.rb', line 20

def plan(url, content_type, upstream_username, upstream_password, search)
  password = encrypt_field(upstream_password)
  plan_self(url: url, content_type: content_type, upstream_username: upstream_username, upstream_password: password, search: search)
end

#run(event = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/lib/actions/katello/repository/discover.rb', line 25

def run(event = nil)
  output[:repo_urls] = output[:repo_urls] || []
  output[:crawled] = output[:crawled] || []
  output[:to_follow] = output[:to_follow] || [input[:url]]

  match(event,
    (on nil do
      unless output[:to_follow].empty?
        password = decrypt_field(input[:upstream_password])
        repo_discovery = ::Katello::RepoDiscovery.class_for(input[:content_type]).new(
                                                                                        input[:url],
                                                                                        output[:crawled],
                                                                                        output[:repo_urls],
                                                                                        output[:to_follow],
                                                                                        {
                                                                                          upstream_username: input[:upstream_username],
                                                                                          upstream_password: password,
                                                                                          search: input[:search],
                                                                                        }
                                                                                      )

        repo_discovery.run(output[:to_follow].shift)
        suspend { |suspended_action| world.clock.ping suspended_action, 0.001 }
      end
    end),
    (on Dynflow::Action::Cancellable::Cancel do
      output[:repo_urls] = []
    end))
end

#task_outputArray<String>

Returns urls found by the action.

Returns:

  • (Array<String>)

    urls found by the action



56
57
58
# File 'app/lib/actions/katello/repository/discover.rb', line 56

def task_output
  output[:repo_urls] || []
end