af 0.5.0.beta.5 → 0.5.0.beta.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjE3N2IxMmU2NDFjY2Q1ZWJhOTQwMGI4OWI5NzJjMjBmYWEzYjQ3MQ==
4
+ MDhjMjcyMGIzZWJiOGQ3ODkzYmMyN2U5OTRkZGZjMGVjZjJlOGY3NQ==
5
5
  data.tar.gz: !binary |-
6
- YzY2YzdiNGRlMWE0OGU5ZWI2ZWZiOTk1OGZjNjU2NGRiYzAyODYzZA==
6
+ ZTQyNGM4YmJjOWU0M2Q3ZTIxZmE2OGI5MDRjOGQwMjBlNmYzNDllNA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjgzYjA4OWZhY2I2ZDUwY2E0MDM3ZjZiYjMyYzkyZDZjY2Q4ZDI4ODI4ZGU1
10
- ZWQ5NzE2OGRiYTdjZTcyYWE1ZTBkMjNiYWZjMjVmOGQyMTMyOWE2YzM3OWFl
11
- NThkNGJjNDg3OTVmZDk3YmM3NTlmZGE5ZDUwYWMwMzhlNDczNTc=
9
+ NTAyZDhlZDgwNDEyYTlkOTYwMzI5YTllN2I1NGNjZTUyZmI1ZjQyNDBhMjhm
10
+ NTFjMjczYTAyZDFhMDMxZDg1N2Q5ZGM2MDI0Yjc5ODI2MDNhZGRkYWIzZDYw
11
+ OTc3YWQ0YjU4ZTU0NmM1MGNhY2RmNzQ3ZjUyYzM0YmE4YzIzZmE=
12
12
  data.tar.gz: !binary |-
13
- ZmE3ZTM2OTBkNGU4MTNiMjZlZmJiNTg4MjA5NzEyNzNmM2FhNWM4NGQ2ZTEz
14
- MzllZWY0OTIyY2M3MDE2M2ZmYWIyNGIwZDM2NjhjMjRiZGNhZDA0NTY0ZDI5
15
- YWJlNzU2NDZkNGRlOWZmY2RlMjlhMDM5YzUxNzYyYzhiZTA2NzA=
13
+ MzQ5YjYxODU2NjQ0ZjY2ZWM2YjAwMGNiOTQ4Zjk2ZmI2MDkwZDlkMDBhNzI4
14
+ ZTdkNjM3N2YzZTNmYTRmNGNmZTg4MDI0YzhlZDQ3MTUyZjhmZjU5ZWI0NmM4
15
+ ZjlmMjJjMDA2NWM0MWExNWYwYzBiYWVmZTZmOWEwMDBhMjJkOGM=
data/lib/af/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module AF
2
- VERSION = "0.5.0.beta.5".freeze
2
+ VERSION = "0.5.0.beta.6".freeze
3
3
  end
@@ -78,7 +78,7 @@ module VMC::App
78
78
 
79
79
  seconds = 0
80
80
  until app.healthy?
81
- sleep 1
81
+ sleep 4
82
82
  seconds += 1
83
83
  if seconds == APP_CHECK_LIMIT
84
84
  s.give_up do
@@ -5,28 +5,76 @@ module VMC::Route
5
5
  def precondition; end
6
6
 
7
7
  desc "Add a URL mapping"
8
- group :apps, :info
8
+ group :apps, :info, :hidden => true
9
9
  input :app, :desc => "Application to add the URL to",
10
10
  :argument => :optional, :from_given => by_name(:app)
11
- input :url, :desc => "URL to map", :argument => :optional
11
+ input :host, :desc => "Host name for the route",
12
+ :argument => :optional, :default => ""
13
+ input :domain, :desc => "Domain to add the route to",
14
+ :argument => true,
15
+ :from_given => proc { |name, space|
16
+ if v2?
17
+ space.domain_by_name(name) ||
18
+ fail_unknown("domain", name)
19
+ else
20
+ name
21
+ end
22
+ }
12
23
  def map
13
24
  app = input[:app]
14
- url = input[:url]
25
+ space = app.space if v2?
15
26
 
16
- with_progress("Updating #{c(app.name, :name)}") do
17
- app.urls << url
18
- app.update!
27
+ host = input[:host]
28
+ domain = input[:domain, space]
29
+
30
+ if v2?
31
+ route = find_or_create_route(domain, host, space)
32
+ bind_route(route, app) if app
33
+ else
34
+ with_progress("Updating #{c(app.name, :name)}") do
35
+ app.urls << domain
36
+ app.update!
37
+ end
19
38
  end
20
39
  end
21
40
 
22
41
  private
23
42
 
24
- def ask_app
25
- ask("Which application?", :choices => client.apps, :display => proc(&:name))
43
+ def bind_route(route, app)
44
+ with_progress("Binding #{c(route.name, :name)} to #{c(app.name, :name)}") do
45
+ app.add_route(route)
46
+ end
26
47
  end
27
48
 
28
- def ask_url
29
- ask("Enter URL?")
49
+ def find_or_create_route(domain, host, space)
50
+ find_route(domain, host) || create_route(domain, host, space)
51
+ end
52
+
53
+ def find_route(domain, host)
54
+ client.routes_by_host(host, :depth => 0).find { |r| r.domain == domain }
55
+ end
56
+
57
+ def create_route(domain, host, space)
58
+ route = client.route
59
+ route.host = host
60
+ route.domain = domain
61
+ route.space = space
62
+
63
+ with_progress("Creating route #{c(route.name, :name)}") do
64
+ route.create!
65
+ end
66
+
67
+ route
68
+ end
69
+
70
+ def find_domain(space, name)
71
+ domain = space.domain_by_name(name, :depth => 0)
72
+ fail "Invalid domain '#{name}'" unless domain
73
+ domain
74
+ end
75
+
76
+ def ask_app
77
+ ask("Which application?", :choices => client.apps, :display => proc(&:name))
30
78
  end
31
79
  end
32
80
  end
@@ -3,23 +3,70 @@ require "vmc/cli/route/base"
3
3
  module VMC::Route
4
4
  class Unmap < Base
5
5
  desc "Remove a URL mapping"
6
- group :apps, :info
6
+ group :apps, :info, :hidden => true
7
+ input :url, :desc => "URL to unmap", :argument => :optional,
8
+ :from_given => find_by_name("route") { client.routes }
7
9
  input :app, :desc => "Application to remove the URL from",
8
10
  :argument => :optional, :from_given => by_name(:app)
9
- input :url, :desc => "URL to unmap", :argument => :optional
11
+ input :delete, :desc => "Delete route", :type => :boolean
10
12
  input :all, :desc => "Act on all routes", :type => :boolean
13
+ input :really, :type => :boolean, :forget => true, :hidden => true,
14
+ :default => proc { force? || interact }
11
15
  def unmap
16
+ return invoke :v1_unmap, input.inputs, input.given unless v2?
17
+
18
+ if input[:all]
19
+ if input.has?(:app)
20
+ app = target = input[:app]
21
+ return unless !input[:delete] || input[:really, "ALL URLS bound to #{target.name}", :bad]
22
+ else
23
+ target = client
24
+ return unless !input[:delete] || input[:really, "ALL URLS", :bad]
25
+ end
26
+
27
+ target.routes.each do |r|
28
+ begin
29
+ invoke :unmap, :delete => input[:delete], :url => r, :really => true, :app => app
30
+ rescue CFoundry::APIError => e
31
+ err "#{e.class}: #{e.message}"
32
+ end
33
+ end
34
+
35
+ return
36
+ end
37
+
12
38
  app = input[:app]
39
+ url = input[:url, app ? app.routes : client.routes]
40
+
41
+ if input[:delete]
42
+ with_progress("Deleting route #{c(url.name, :name)}") do
43
+ url.delete!
44
+ end
45
+ elsif app
46
+ with_progress("Unbinding #{c(url.name, :name)} from #{c(app.name, :name)}") do
47
+ app.remove_route(url)
48
+ end
49
+ else
50
+ fail "Missing either --delete or --app."
51
+ end
52
+ end
13
53
 
14
- fail "No urls to unmap." if app.urls.empty?
15
54
 
16
- url = input[:url, (app.urls.map{|url| OpenStruct.new({name: url})})] unless input[:all]
55
+ desc "V1 ONLY UNMAP YOU SHOULD NOT SEE THIS"
56
+ input :url, :desc => "URL to unmap", :argument => :optional,
57
+ :interact => :v1_ask_url
58
+ input :app, :desc => "Application to remove the URL from",
59
+ :argument => :optional, :from_given => by_name(:app)
60
+ input :all, :desc => "Act on all routes", :type => :boolean
61
+ def v1_unmap
62
+ app = input[:app]
63
+ url = input[:url, app.urls] unless input[:all]
17
64
 
18
65
  with_progress("Updating #{c(app.name, :name)}") do |s|
19
66
  if input[:all]
20
67
  app.urls = []
21
68
  else
22
- simple = url.name.sub(/^https?:\/\/(.*)\/?/i, '\1')
69
+ simple = url.sub(/^https?:\/\/(.*)\/?/i, '\1')
23
70
 
24
71
  unless app.urls.delete(simple)
25
72
  fail "URL #{url} is not mapped to this application."
@@ -32,12 +79,16 @@ module VMC::Route
32
79
 
33
80
  private
34
81
 
35
- def ask_app
36
- ask("Which application?", :choices => client.apps, :display => proc(&:name))
37
- end
38
-
39
82
  def ask_url(choices)
40
83
  ask("Which URL?", :choices => choices.sort_by(&:name), :display => proc(&:name))
41
84
  end
85
+
86
+ def v1_ask_url(choices)
87
+ ask("Which URL?", :choices => choices.sort)
88
+ end
89
+
90
+ def ask_really(name, color)
91
+ ask("Really delete #{c(name, color)}?", :default => false)
92
+ end
42
93
  end
43
94
  end
@@ -92,12 +92,12 @@ module VMC::Service
92
92
 
93
93
  private
94
94
 
95
- def ask_infra(choices, default, other)
96
- [ask("Infrastructure?", :choices => client.infras,
95
+ def ask_infra
96
+ ask("Infrastructure?", :choices => client.infras,
97
97
  :display => proc { |s|
98
98
  str = "#{c(s.name, :name)} - #{s.description}"
99
99
  },
100
- :complete => proc { |s| "#{s.name} #{s.description}" })]
100
+ :complete => proc { |s| "#{s.name} #{s.description}" })
101
101
  end
102
102
 
103
103
  def ask_offering(offerings)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: af
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.beta.5
4
+ version: 0.5.0.beta.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cloud Foundry Team
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-11 00:00:00.000000000 Z
12
+ date: 2013-03-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json_pure