vmc 0.5.0.beta.7 → 0.5.0.beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +1277 -746
- data/Rakefile +22 -23
- data/lib/vmc/cli.rb +21 -27
- data/lib/vmc/cli/app/push.rb +1 -0
- data/lib/vmc/cli/app/push/create.rb +3 -2
- data/lib/vmc/cli/app/push/sync.rb +11 -8
- data/lib/vmc/cli/app/scale.rb +19 -17
- data/lib/vmc/cli/domain/map.rb +55 -0
- data/lib/vmc/cli/domain/unmap.rb +56 -0
- data/lib/vmc/cli/route/map.rb +74 -0
- data/lib/vmc/cli/route/unmap.rb +94 -0
- data/lib/vmc/cli/service/create.rb +4 -1
- data/lib/vmc/cli/start/base.rb +2 -2
- data/lib/vmc/cli/start/login.rb +5 -2
- data/lib/vmc/cli/start/target.rb +4 -3
- data/lib/vmc/cli/user/base.rb +19 -0
- data/lib/vmc/cli/user/passwd.rb +7 -19
- data/lib/vmc/cli/{start → user}/register.rb +12 -23
- data/lib/vmc/constants.rb +1 -1
- data/lib/vmc/test_support.rb +4 -0
- data/lib/vmc/test_support/command_helper.rb +38 -0
- data/{spec/support → lib/vmc/test_support}/common_input_examples.rb +0 -0
- data/lib/vmc/test_support/fake_home_dir.rb +16 -0
- data/lib/vmc/test_support/interact_helper.rb +29 -0
- data/lib/vmc/version.rb +1 -1
- data/spec/features/new_user_flow_spec.rb +43 -51
- data/spec/spec_helper.rb +24 -12
- data/spec/vmc/cli/app/instances_spec.rb +3 -8
- data/spec/vmc/cli/app/push/create_spec.rb +10 -7
- data/spec/vmc/cli/app/push_spec.rb +1 -1
- data/spec/vmc/cli/app/rename_spec.rb +1 -1
- data/spec/vmc/cli/app/scale_spec.rb +81 -0
- data/spec/vmc/cli/app/stats_spec.rb +3 -7
- data/spec/vmc/cli/domain/map_spec.rb +140 -0
- data/spec/vmc/cli/domain/unmap_spec.rb +73 -0
- data/spec/vmc/cli/organization/orgs_spec.rb +13 -16
- data/spec/vmc/cli/organization/rename_spec.rb +1 -1
- data/spec/vmc/cli/route/map_spec.rb +142 -0
- data/spec/vmc/cli/route/unmap_spec.rb +215 -0
- data/spec/vmc/cli/service/rename_spec.rb +1 -1
- data/spec/vmc/cli/space/rename_spec.rb +15 -18
- data/spec/vmc/cli/space/spaces_spec.rb +18 -25
- data/spec/vmc/cli/start/info_spec.rb +44 -46
- data/spec/vmc/cli/start/login_spec.rb +40 -0
- data/spec/vmc/cli/user/create_spec.rb +54 -0
- data/spec/vmc/cli/user/passwd_spec.rb +7 -14
- data/spec/vmc/cli/{start → user}/register_spec.rb +26 -22
- data/spec/vmc/cli_spec.rb +164 -6
- metadata +46 -39
- data/lib/vmc/cli/app/routes.rb +0 -100
- data/lib/vmc/cli/domain/add_domain.rb +0 -25
- data/lib/vmc/cli/domain/create_domain.rb +0 -28
- data/lib/vmc/cli/domain/delete_domain.rb +0 -56
- data/lib/vmc/cli/domain/remove_domain.rb +0 -28
- data/lib/vmc/cli/route/create_route.rb +0 -49
- data/lib/vmc/cli/route/delete.rb +0 -47
- data/spec/support/feature_helpers.rb +0 -16
- data/spec/support/interact_helpers.rb +0 -27
- data/spec/vmc/cli/route/delete_route_spec.rb +0 -162
    
        data/spec/vmc/cli_spec.rb
    CHANGED
    
    | @@ -2,19 +2,20 @@ require 'spec_helper' | |
| 2 2 |  | 
| 3 3 | 
             
            describe VMC::CLI do
         | 
| 4 4 | 
             
              let(:cmd) { Class.new(VMC::CLI).new }
         | 
| 5 | 
            +
              let(:cli) { VMC::CLI.new }
         | 
| 5 6 |  | 
| 6 7 | 
             
              describe '#execute' do
         | 
| 7 8 | 
             
                let(:inputs) { {} }
         | 
| 8 9 |  | 
| 9 10 | 
             
                subject do
         | 
| 10 | 
            -
                   | 
| 11 | 
            +
                  capture_output do
         | 
| 11 12 | 
             
                    stub(cmd).input { inputs }
         | 
| 12 13 | 
             
                    cmd.execute(nil, [])
         | 
| 13 14 | 
             
                  end
         | 
| 14 15 | 
             
                end
         | 
| 15 16 |  | 
| 16 17 | 
             
                it 'wraps Timeout::Error with a more friendly message' do
         | 
| 17 | 
            -
                  stub(cmd).precondition { raise CFoundry::Timeout.new( | 
| 18 | 
            +
                  stub(cmd).precondition { raise CFoundry::Timeout.new("GET", "/foo") }
         | 
| 18 19 |  | 
| 19 20 | 
             
                  mock(cmd).err 'GET /foo timed out'
         | 
| 20 21 | 
             
                  subject
         | 
| @@ -42,7 +43,7 @@ describe VMC::CLI do | |
| 42 43 | 
             
              describe '#log_error' do
         | 
| 43 44 | 
             
                subject do
         | 
| 44 45 | 
             
                  cmd.log_error(exception)
         | 
| 45 | 
            -
                  File.read(VMC::CRASH_FILE)
         | 
| 46 | 
            +
                  File.read(File.expand_path(VMC::CRASH_FILE))
         | 
| 46 47 | 
             
                end
         | 
| 47 48 |  | 
| 48 49 | 
             
                context 'when the exception is a normal error' do
         | 
| @@ -60,10 +61,10 @@ describe VMC::CLI do | |
| 60 61 | 
             
                end
         | 
| 61 62 |  | 
| 62 63 | 
             
                context 'when the exception is an APIError' do
         | 
| 63 | 
            -
                  let(:request) {  | 
| 64 | 
            -
                  let(:response) {  | 
| 64 | 
            +
                  let(:request) { { :method => "GET", :url => "http://api.cloudfoundry.com/foo", :headers => {}, :body => nil } }
         | 
| 65 | 
            +
                  let(:response) { { :status => 404, :body => "bar", :headers => {} } }
         | 
| 65 66 | 
             
                  let(:exception) do
         | 
| 66 | 
            -
                    error = CFoundry::APIError.new(request, response)
         | 
| 67 | 
            +
                    error = CFoundry::APIError.new(nil, nil, request, response)
         | 
| 67 68 | 
             
                    error.set_backtrace(["fo/gems/bar", "baz quick"])
         | 
| 68 69 | 
             
                    error
         | 
| 69 70 | 
             
                  end
         | 
| @@ -76,5 +77,162 @@ describe VMC::CLI do | |
| 76 77 | 
             
                  it { should include "RESPONSE: " }
         | 
| 77 78 | 
             
                end
         | 
| 78 79 | 
             
              end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
              describe "#client_target" do
         | 
| 82 | 
            +
                subject { cli.client_target }
         | 
| 83 | 
            +
             | 
| 84 | 
            +
                context "when a ~/.vmc/target exists" do
         | 
| 85 | 
            +
                  use_fake_home_dir { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
         | 
| 86 | 
            +
             | 
| 87 | 
            +
                  it "returns the target in that file" do
         | 
| 88 | 
            +
                    expect(subject).to eq "https://api.some-domain.com"
         | 
| 89 | 
            +
                  end
         | 
| 90 | 
            +
                end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
                context "when a ~/.vmc_target exists" do
         | 
| 93 | 
            +
                  use_fake_home_dir { "#{SPEC_ROOT}/fixtures/fake_home_dirs/old" }
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                  it "returns the target in that file" do
         | 
| 96 | 
            +
                    expect(subject).to eq "https://api.some-domain.com"
         | 
| 97 | 
            +
                  end
         | 
| 98 | 
            +
                end
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                context "when no target file exists" do
         | 
| 101 | 
            +
                  use_fake_home_dir { "#{SPEC_ROOT}/fixtures/fake_home_dirs/no_config" }
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                  it "displays an error to the user" do
         | 
| 104 | 
            +
                    expect{ subject }.to raise_error(VMC::UserError, /Please select a target/)
         | 
| 105 | 
            +
                  end
         | 
| 106 | 
            +
                end
         | 
| 107 | 
            +
              end
         | 
| 108 | 
            +
             | 
| 109 | 
            +
              describe "#targets_info" do
         | 
| 110 | 
            +
                subject { cli.targets_info }
         | 
| 111 | 
            +
             | 
| 112 | 
            +
                context "when a ~/.vmc/tokens.yml exists" do
         | 
| 113 | 
            +
                  use_fake_home_dir { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                  it "returns the file's contents as a hash" do
         | 
| 116 | 
            +
                    expect(subject).to eq({
         | 
| 117 | 
            +
                      "https://api.some-domain.com" => {
         | 
| 118 | 
            +
                        :token => "bearer some-token",
         | 
| 119 | 
            +
                        :version => 2
         | 
| 120 | 
            +
                      }
         | 
| 121 | 
            +
                    })
         | 
| 122 | 
            +
                  end
         | 
| 123 | 
            +
                end
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                context "when a ~/.vmc_token file exists" do
         | 
| 126 | 
            +
                  use_fake_home_dir { "#{SPEC_ROOT}/fixtures/fake_home_dirs/old" }
         | 
| 127 | 
            +
             | 
| 128 | 
            +
                  it "returns the target in that file" do
         | 
| 129 | 
            +
                    expect(subject).to eq({
         | 
| 130 | 
            +
                      "https://api.some-domain.com" => {
         | 
| 131 | 
            +
                        :token => "bearer some-token"
         | 
| 132 | 
            +
                      }
         | 
| 133 | 
            +
                    })
         | 
| 134 | 
            +
                  end
         | 
| 135 | 
            +
                end
         | 
| 136 | 
            +
             | 
| 137 | 
            +
                context "when no token file exists" do
         | 
| 138 | 
            +
                  use_fake_home_dir { "#{SPEC_ROOT}/fixtures/fake_home_dirs/no_config" }
         | 
| 139 | 
            +
             | 
| 140 | 
            +
                  it "returns an empty hash" do
         | 
| 141 | 
            +
                    expect(subject).to eq({})
         | 
| 142 | 
            +
                  end
         | 
| 143 | 
            +
                end
         | 
| 144 | 
            +
              end
         | 
| 145 | 
            +
             | 
| 146 | 
            +
              describe "#target_info" do
         | 
| 147 | 
            +
                subject { VMC::CLI.new.target_info("https://api.some-domain.com") }
         | 
| 148 | 
            +
             | 
| 149 | 
            +
                context "when a ~/.vmc/tokens.yml exists" do
         | 
| 150 | 
            +
                  use_fake_home_dir { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                  it "returns the info for the given url" do
         | 
| 153 | 
            +
                    expect(subject).to eq({
         | 
| 154 | 
            +
                      :token => "bearer some-token",
         | 
| 155 | 
            +
                      :version => 2
         | 
| 156 | 
            +
                    })
         | 
| 157 | 
            +
                  end
         | 
| 158 | 
            +
                end
         | 
| 159 | 
            +
             | 
| 160 | 
            +
                context "when a ~/.vmc_token file exists" do
         | 
| 161 | 
            +
                  use_fake_home_dir { "#{SPEC_ROOT}/fixtures/fake_home_dirs/old" }
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                  it "returns the info for the given url" do
         | 
| 164 | 
            +
                    expect(subject).to eq({
         | 
| 165 | 
            +
                      :token => "bearer some-token"
         | 
| 166 | 
            +
                    })
         | 
| 167 | 
            +
                  end
         | 
| 168 | 
            +
                end
         | 
| 169 | 
            +
             | 
| 170 | 
            +
                context "when no token file exists" do
         | 
| 171 | 
            +
                  use_fake_home_dir { "#{SPEC_ROOT}/fixtures/fake_home_dirs/no_config" }
         | 
| 172 | 
            +
             | 
| 173 | 
            +
                  it "returns an empty hash" do
         | 
| 174 | 
            +
                    expect(subject).to eq({})
         | 
| 175 | 
            +
                  end
         | 
| 176 | 
            +
                end
         | 
| 177 | 
            +
              end
         | 
| 178 | 
            +
             | 
| 179 | 
            +
              describe "methods that update the token info" do
         | 
| 180 | 
            +
                let!(:tmpdir) { Dir.mktmpdir }
         | 
| 181 | 
            +
                use_fake_home_dir { tmpdir }
         | 
| 182 | 
            +
             | 
| 183 | 
            +
                before do
         | 
| 184 | 
            +
                  stub(cli).targets_info do
         | 
| 185 | 
            +
                    {
         | 
| 186 | 
            +
                      "https://api.some-domain.com" => { :token => "bearer token1" },
         | 
| 187 | 
            +
                      "https://api.some-other-domain.com" => { :token => "bearer token2" }
         | 
| 188 | 
            +
                    }
         | 
| 189 | 
            +
                  end
         | 
| 190 | 
            +
                end
         | 
| 191 | 
            +
             | 
| 192 | 
            +
                after { FileUtils.rm_rf tmpdir }
         | 
| 193 | 
            +
             | 
| 194 | 
            +
                describe "#save_target_info" do
         | 
| 195 | 
            +
                  it "adds the given target info, and writes the result to ~/.vmc/tokens.yml" do
         | 
| 196 | 
            +
                    cli.save_target_info({ :token => "bearer token3" }, "https://api.some-domain.com")
         | 
| 197 | 
            +
                    YAML.load_file(File.expand_path("~/.vmc/tokens.yml")).should == {
         | 
| 198 | 
            +
                      "https://api.some-domain.com" => { :token => "bearer token3" },
         | 
| 199 | 
            +
                      "https://api.some-other-domain.com" => { :token => "bearer token2" }
         | 
| 200 | 
            +
                    }
         | 
| 201 | 
            +
                  end
         | 
| 202 | 
            +
                end
         | 
| 203 | 
            +
             | 
| 204 | 
            +
                describe "#remove_target_info" do
         | 
| 205 | 
            +
                  it "removes the given target, and writes the result to ~/.vmc/tokens.yml" do
         | 
| 206 | 
            +
                    cli.remove_target_info("https://api.some-domain.com")
         | 
| 207 | 
            +
                    YAML.load_file(File.expand_path("~/.vmc/tokens.yml")).should == {
         | 
| 208 | 
            +
                      "https://api.some-other-domain.com" => { :token => "bearer token2" }
         | 
| 209 | 
            +
                    }
         | 
| 210 | 
            +
                  end
         | 
| 211 | 
            +
                end
         | 
| 212 | 
            +
              end
         | 
| 213 | 
            +
             | 
| 214 | 
            +
              describe "#client" do
         | 
| 215 | 
            +
                use_fake_home_dir { "#{SPEC_ROOT}/fixtures/fake_home_dirs/new" }
         | 
| 216 | 
            +
                before { stub(cli).input { {} } }
         | 
| 217 | 
            +
             | 
| 218 | 
            +
                describe "the client's token" do
         | 
| 219 | 
            +
                  it "constructs an AuthToken object with the data from the tokens.yml file" do
         | 
| 220 | 
            +
                    expect(cli.client.token).to be_a(CFoundry::AuthToken)
         | 
| 221 | 
            +
                    expect(cli.client.token.auth_header).to eq("bearer some-token")
         | 
| 222 | 
            +
                  end
         | 
| 223 | 
            +
             | 
| 224 | 
            +
                  it "does not assign an AuthToken on the client if there is no token stored" do
         | 
| 225 | 
            +
                    mock(cli).target_info("some-fake-target") { { :version => 2 } }
         | 
| 226 | 
            +
                    expect(cli.client("some-fake-target").token).to be_nil
         | 
| 227 | 
            +
                  end
         | 
| 228 | 
            +
                end
         | 
| 229 | 
            +
             | 
| 230 | 
            +
                describe "the client's version" do
         | 
| 231 | 
            +
                  it "uses the version stored in the yml file" do
         | 
| 232 | 
            +
             | 
| 233 | 
            +
                    expect(cli.client.version).to eq(2)
         | 
| 234 | 
            +
                  end
         | 
| 235 | 
            +
                end
         | 
| 236 | 
            +
              end
         | 
| 79 237 | 
             
            end
         | 
| 80 238 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,23 +1,24 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: vmc
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: -3788488616
         | 
| 5 5 | 
             
              prerelease: 6
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 0
         | 
| 8 8 | 
             
              - 5
         | 
| 9 9 | 
             
              - 0
         | 
| 10 10 | 
             
              - beta
         | 
| 11 | 
            -
              -  | 
| 12 | 
            -
              version: 0.5.0.beta. | 
| 11 | 
            +
              - 10
         | 
| 12 | 
            +
              version: 0.5.0.beta.10
         | 
| 13 13 | 
             
            platform: ruby
         | 
| 14 14 | 
             
            authors: 
         | 
| 15 | 
            +
            - Cloud Foundry Team
         | 
| 15 16 | 
             
            - Alex Suraci
         | 
| 16 17 | 
             
            autorequire: 
         | 
| 17 18 | 
             
            bindir: bin
         | 
| 18 19 | 
             
            cert_chain: []
         | 
| 19 20 |  | 
| 20 | 
            -
            date: 2013- | 
| 21 | 
            +
            date: 2013-02-05 00:00:00 Z
         | 
| 21 22 | 
             
            dependencies: 
         | 
| 22 23 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 23 24 | 
             
              version_requirements: &id001 !ruby/object:Gem::Requirement 
         | 
| @@ -71,12 +72,12 @@ dependencies: | |
| 71 72 | 
             
                requirements: 
         | 
| 72 73 | 
             
                - - ~>
         | 
| 73 74 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 74 | 
            -
                    hash:  | 
| 75 | 
            +
                    hash: 39
         | 
| 75 76 | 
             
                    segments: 
         | 
| 76 77 | 
             
                    - 0
         | 
| 77 78 | 
             
                    - 4
         | 
| 78 | 
            -
                    -  | 
| 79 | 
            -
                    version: 0.4. | 
| 79 | 
            +
                    - 20
         | 
| 80 | 
            +
                    version: 0.4.20
         | 
| 80 81 | 
             
              prerelease: false
         | 
| 81 82 | 
             
              type: :runtime
         | 
| 82 83 | 
             
              name: cfoundry
         | 
| @@ -103,12 +104,12 @@ dependencies: | |
| 103 104 | 
             
                requirements: 
         | 
| 104 105 | 
             
                - - ~>
         | 
| 105 106 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 106 | 
            -
                    hash:  | 
| 107 | 
            +
                    hash: 11
         | 
| 107 108 | 
             
                    segments: 
         | 
| 108 109 | 
             
                    - 0
         | 
| 109 | 
            -
                    -  | 
| 110 | 
            +
                    - 5
         | 
| 110 111 | 
             
                    - 0
         | 
| 111 | 
            -
                    version: 0. | 
| 112 | 
            +
                    version: 0.5.0
         | 
| 112 113 | 
             
              prerelease: false
         | 
| 113 114 | 
             
              type: :runtime
         | 
| 114 115 | 
             
              name: mothership
         | 
| @@ -119,12 +120,12 @@ dependencies: | |
| 119 120 | 
             
                requirements: 
         | 
| 120 121 | 
             
                - - ~>
         | 
| 121 122 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 122 | 
            -
                    hash:  | 
| 123 | 
            +
                    hash: 11
         | 
| 123 124 | 
             
                    segments: 
         | 
| 124 125 | 
             
                    - 0
         | 
| 125 | 
            -
                    -  | 
| 126 | 
            -
                    -  | 
| 127 | 
            -
                    version: 0. | 
| 126 | 
            +
                    - 5
         | 
| 127 | 
            +
                    - 0
         | 
| 128 | 
            +
                    version: 0.5.0
         | 
| 128 129 | 
             
              prerelease: false
         | 
| 129 130 | 
             
              type: :runtime
         | 
| 130 131 | 
             
              name: manifests-vmc-plugin
         | 
| @@ -135,15 +136,15 @@ dependencies: | |
| 135 136 | 
             
                requirements: 
         | 
| 136 137 | 
             
                - - ~>
         | 
| 137 138 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 138 | 
            -
                    hash:  | 
| 139 | 
            +
                    hash: 13
         | 
| 139 140 | 
             
                    segments: 
         | 
| 140 141 | 
             
                    - 0
         | 
| 141 | 
            -
                    -  | 
| 142 | 
            -
                    -  | 
| 143 | 
            -
                    version: 0. | 
| 142 | 
            +
                    - 1
         | 
| 143 | 
            +
                    - 11
         | 
| 144 | 
            +
                    version: 0.1.11
         | 
| 144 145 | 
             
              prerelease: false
         | 
| 145 146 | 
             
              type: :runtime
         | 
| 146 | 
            -
              name: tunnel- | 
| 147 | 
            +
              name: tunnel-vmc-plugin
         | 
| 147 148 | 
             
              requirement: *id008
         | 
| 148 149 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 149 150 | 
             
              version_requirements: &id009 !ruby/object:Gem::Requirement 
         | 
| @@ -207,7 +208,7 @@ dependencies: | |
| 207 208 | 
             
              requirement: *id012
         | 
| 208 209 | 
             
            description: 
         | 
| 209 210 | 
             
            email: 
         | 
| 210 | 
            -
            -  | 
| 211 | 
            +
            - vcap-dev@googlegroups.com
         | 
| 211 212 | 
             
            executables: 
         | 
| 212 213 | 
             
            - vmc
         | 
| 213 214 | 
             
            extensions: []
         | 
| @@ -234,17 +235,14 @@ files: | |
| 234 235 | 
             
            - lib/vmc/cli/app/push.rb
         | 
| 235 236 | 
             
            - lib/vmc/cli/app/rename.rb
         | 
| 236 237 | 
             
            - lib/vmc/cli/app/restart.rb
         | 
| 237 | 
            -
            - lib/vmc/cli/app/routes.rb
         | 
| 238 238 | 
             
            - lib/vmc/cli/app/scale.rb
         | 
| 239 239 | 
             
            - lib/vmc/cli/app/start.rb
         | 
| 240 240 | 
             
            - lib/vmc/cli/app/stats.rb
         | 
| 241 241 | 
             
            - lib/vmc/cli/app/stop.rb
         | 
| 242 | 
            -
            - lib/vmc/cli/domain/add_domain.rb
         | 
| 243 242 | 
             
            - lib/vmc/cli/domain/base.rb
         | 
| 244 | 
            -
            - lib/vmc/cli/domain/create_domain.rb
         | 
| 245 | 
            -
            - lib/vmc/cli/domain/delete_domain.rb
         | 
| 246 243 | 
             
            - lib/vmc/cli/domain/domains.rb
         | 
| 247 | 
            -
            - lib/vmc/cli/domain/ | 
| 244 | 
            +
            - lib/vmc/cli/domain/map.rb
         | 
| 245 | 
            +
            - lib/vmc/cli/domain/unmap.rb
         | 
| 248 246 | 
             
            - lib/vmc/cli/help.rb
         | 
| 249 247 | 
             
            - lib/vmc/cli/interactive.rb
         | 
| 250 248 | 
             
            - lib/vmc/cli/organization/base.rb
         | 
| @@ -254,9 +252,9 @@ files: | |
| 254 252 | 
             
            - lib/vmc/cli/organization/orgs.rb
         | 
| 255 253 | 
             
            - lib/vmc/cli/organization/rename.rb
         | 
| 256 254 | 
             
            - lib/vmc/cli/route/base.rb
         | 
| 257 | 
            -
            - lib/vmc/cli/route/ | 
| 258 | 
            -
            - lib/vmc/cli/route/delete.rb
         | 
| 255 | 
            +
            - lib/vmc/cli/route/map.rb
         | 
| 259 256 | 
             
            - lib/vmc/cli/route/routes.rb
         | 
| 257 | 
            +
            - lib/vmc/cli/route/unmap.rb
         | 
| 260 258 | 
             
            - lib/vmc/cli/service/base.rb
         | 
| 261 259 | 
             
            - lib/vmc/cli/service/bind.rb
         | 
| 262 260 | 
             
            - lib/vmc/cli/service/create.rb
         | 
| @@ -277,7 +275,6 @@ files: | |
| 277 275 | 
             
            - lib/vmc/cli/start/info.rb
         | 
| 278 276 | 
             
            - lib/vmc/cli/start/login.rb
         | 
| 279 277 | 
             
            - lib/vmc/cli/start/logout.rb
         | 
| 280 | 
            -
            - lib/vmc/cli/start/register.rb
         | 
| 281 278 | 
             
            - lib/vmc/cli/start/target.rb
         | 
| 282 279 | 
             
            - lib/vmc/cli/start/target_interactions.rb
         | 
| 283 280 | 
             
            - lib/vmc/cli/start/targets.rb
         | 
| @@ -285,6 +282,7 @@ files: | |
| 285 282 | 
             
            - lib/vmc/cli/user/create.rb
         | 
| 286 283 | 
             
            - lib/vmc/cli/user/delete.rb
         | 
| 287 284 | 
             
            - lib/vmc/cli/user/passwd.rb
         | 
| 285 | 
            +
            - lib/vmc/cli/user/register.rb
         | 
| 288 286 | 
             
            - lib/vmc/cli/user/users.rb
         | 
| 289 287 | 
             
            - lib/vmc/cli.rb
         | 
| 290 288 | 
             
            - lib/vmc/constants.rb
         | 
| @@ -293,25 +291,31 @@ files: | |
| 293 291 | 
             
            - lib/vmc/plugin.rb
         | 
| 294 292 | 
             
            - lib/vmc/spacing.rb
         | 
| 295 293 | 
             
            - lib/vmc/spec_helper.rb
         | 
| 294 | 
            +
            - lib/vmc/test_support/command_helper.rb
         | 
| 295 | 
            +
            - lib/vmc/test_support/common_input_examples.rb
         | 
| 296 | 
            +
            - lib/vmc/test_support/fake_home_dir.rb
         | 
| 297 | 
            +
            - lib/vmc/test_support/interact_helper.rb
         | 
| 298 | 
            +
            - lib/vmc/test_support.rb
         | 
| 296 299 | 
             
            - lib/vmc/version.rb
         | 
| 297 300 | 
             
            - lib/vmc.rb
         | 
| 298 301 | 
             
            - spec/assets/hello-sinatra/Gemfile
         | 
| 299 302 | 
             
            - spec/assets/hello-sinatra/main.rb
         | 
| 300 303 | 
             
            - spec/features/new_user_flow_spec.rb
         | 
| 301 304 | 
             
            - spec/spec_helper.rb
         | 
| 302 | 
            -
            - spec/support/common_input_examples.rb
         | 
| 303 | 
            -
            - spec/support/feature_helpers.rb
         | 
| 304 | 
            -
            - spec/support/interact_helpers.rb
         | 
| 305 305 | 
             
            - spec/vmc/cli/app/base_spec.rb
         | 
| 306 306 | 
             
            - spec/vmc/cli/app/delete_spec.rb
         | 
| 307 307 | 
             
            - spec/vmc/cli/app/instances_spec.rb
         | 
| 308 308 | 
             
            - spec/vmc/cli/app/push/create_spec.rb
         | 
| 309 309 | 
             
            - spec/vmc/cli/app/push_spec.rb
         | 
| 310 310 | 
             
            - spec/vmc/cli/app/rename_spec.rb
         | 
| 311 | 
            +
            - spec/vmc/cli/app/scale_spec.rb
         | 
| 311 312 | 
             
            - spec/vmc/cli/app/stats_spec.rb
         | 
| 313 | 
            +
            - spec/vmc/cli/domain/map_spec.rb
         | 
| 314 | 
            +
            - spec/vmc/cli/domain/unmap_spec.rb
         | 
| 312 315 | 
             
            - spec/vmc/cli/organization/orgs_spec.rb
         | 
| 313 316 | 
             
            - spec/vmc/cli/organization/rename_spec.rb
         | 
| 314 | 
            -
            - spec/vmc/cli/route/ | 
| 317 | 
            +
            - spec/vmc/cli/route/map_spec.rb
         | 
| 318 | 
            +
            - spec/vmc/cli/route/unmap_spec.rb
         | 
| 315 319 | 
             
            - spec/vmc/cli/service/bind_spec.rb
         | 
| 316 320 | 
             
            - spec/vmc/cli/service/delete_spec.rb
         | 
| 317 321 | 
             
            - spec/vmc/cli/service/rename_spec.rb
         | 
| @@ -321,12 +325,13 @@ files: | |
| 321 325 | 
             
            - spec/vmc/cli/space/spaces_spec.rb
         | 
| 322 326 | 
             
            - spec/vmc/cli/start/info_spec.rb
         | 
| 323 327 | 
             
            - spec/vmc/cli/start/login_spec.rb
         | 
| 324 | 
            -
            - spec/vmc/cli/ | 
| 328 | 
            +
            - spec/vmc/cli/user/create_spec.rb
         | 
| 325 329 | 
             
            - spec/vmc/cli/user/passwd_spec.rb
         | 
| 330 | 
            +
            - spec/vmc/cli/user/register_spec.rb
         | 
| 326 331 | 
             
            - spec/vmc/cli_spec.rb
         | 
| 327 332 | 
             
            - spec/vmc/detect_spec.rb
         | 
| 328 333 | 
             
            - bin/vmc
         | 
| 329 | 
            -
            homepage: http:// | 
| 334 | 
            +
            homepage: http://github.com/cloudfoundry/vmc
         | 
| 330 335 | 
             
            licenses: []
         | 
| 331 336 |  | 
| 332 337 | 
             
            post_install_message: 
         | 
| @@ -366,19 +371,20 @@ test_files: | |
| 366 371 | 
             
            - spec/assets/hello-sinatra/main.rb
         | 
| 367 372 | 
             
            - spec/features/new_user_flow_spec.rb
         | 
| 368 373 | 
             
            - spec/spec_helper.rb
         | 
| 369 | 
            -
            - spec/support/common_input_examples.rb
         | 
| 370 | 
            -
            - spec/support/feature_helpers.rb
         | 
| 371 | 
            -
            - spec/support/interact_helpers.rb
         | 
| 372 374 | 
             
            - spec/vmc/cli/app/base_spec.rb
         | 
| 373 375 | 
             
            - spec/vmc/cli/app/delete_spec.rb
         | 
| 374 376 | 
             
            - spec/vmc/cli/app/instances_spec.rb
         | 
| 375 377 | 
             
            - spec/vmc/cli/app/push/create_spec.rb
         | 
| 376 378 | 
             
            - spec/vmc/cli/app/push_spec.rb
         | 
| 377 379 | 
             
            - spec/vmc/cli/app/rename_spec.rb
         | 
| 380 | 
            +
            - spec/vmc/cli/app/scale_spec.rb
         | 
| 378 381 | 
             
            - spec/vmc/cli/app/stats_spec.rb
         | 
| 382 | 
            +
            - spec/vmc/cli/domain/map_spec.rb
         | 
| 383 | 
            +
            - spec/vmc/cli/domain/unmap_spec.rb
         | 
| 379 384 | 
             
            - spec/vmc/cli/organization/orgs_spec.rb
         | 
| 380 385 | 
             
            - spec/vmc/cli/organization/rename_spec.rb
         | 
| 381 | 
            -
            - spec/vmc/cli/route/ | 
| 386 | 
            +
            - spec/vmc/cli/route/map_spec.rb
         | 
| 387 | 
            +
            - spec/vmc/cli/route/unmap_spec.rb
         | 
| 382 388 | 
             
            - spec/vmc/cli/service/bind_spec.rb
         | 
| 383 389 | 
             
            - spec/vmc/cli/service/delete_spec.rb
         | 
| 384 390 | 
             
            - spec/vmc/cli/service/rename_spec.rb
         | 
| @@ -388,7 +394,8 @@ test_files: | |
| 388 394 | 
             
            - spec/vmc/cli/space/spaces_spec.rb
         | 
| 389 395 | 
             
            - spec/vmc/cli/start/info_spec.rb
         | 
| 390 396 | 
             
            - spec/vmc/cli/start/login_spec.rb
         | 
| 391 | 
            -
            - spec/vmc/cli/ | 
| 397 | 
            +
            - spec/vmc/cli/user/create_spec.rb
         | 
| 392 398 | 
             
            - spec/vmc/cli/user/passwd_spec.rb
         | 
| 399 | 
            +
            - spec/vmc/cli/user/register_spec.rb
         | 
| 393 400 | 
             
            - spec/vmc/cli_spec.rb
         | 
| 394 401 | 
             
            - spec/vmc/detect_spec.rb
         | 
    
        data/lib/vmc/cli/app/routes.rb
    DELETED
    
    | @@ -1,100 +0,0 @@ | |
| 1 | 
            -
            require "vmc/cli/app/base"
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            # TODO: split up, as the URL interaction will differ (see other TODO)
         | 
| 4 | 
            -
            module VMC::App
         | 
| 5 | 
            -
              class Routes < Base
         | 
| 6 | 
            -
                desc "Add a URL mapping for an app"
         | 
| 7 | 
            -
                group :apps, :info, :hidden => true
         | 
| 8 | 
            -
                input :app, :desc => "Application to add the URL to", :argument => true,
         | 
| 9 | 
            -
                      :from_given => by_name(:app)
         | 
| 10 | 
            -
                input :url, :desc => "URL to map to the application", :argument => true
         | 
| 11 | 
            -
                # TODO: move push's URL interaction here, and have it just invoke
         | 
| 12 | 
            -
                def map
         | 
| 13 | 
            -
                  app = input[:app]
         | 
| 14 | 
            -
             | 
| 15 | 
            -
                  simple = input[:url].sub(/^https?:\/\/(.*)\/?/i, '\1')
         | 
| 16 | 
            -
             | 
| 17 | 
            -
                  if v2?
         | 
| 18 | 
            -
                    host, domain_name = simple.split(".", 2)
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                    domain =
         | 
| 21 | 
            -
                      client.current_space.domain_by_name(domain_name, :depth => 0)
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                    fail "Invalid domain '#{domain_name}'" unless domain
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                    route = client.routes_by_host(host, :depth => 0).find do |r|
         | 
| 26 | 
            -
                      r.domain == domain
         | 
| 27 | 
            -
                    end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
                    unless route
         | 
| 30 | 
            -
                      route = client.route
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                      with_progress("Creating route #{c(simple, :name)}") do
         | 
| 33 | 
            -
                        route.host = host
         | 
| 34 | 
            -
                        route.domain = domain
         | 
| 35 | 
            -
                        route.space = app.space
         | 
| 36 | 
            -
                        route.create!
         | 
| 37 | 
            -
                      end
         | 
| 38 | 
            -
                    end
         | 
| 39 | 
            -
             | 
| 40 | 
            -
                    with_progress("Binding #{c(simple, :name)} to #{c(app.name, :name)}") do
         | 
| 41 | 
            -
                      app.add_route(route)
         | 
| 42 | 
            -
                    end
         | 
| 43 | 
            -
                  else
         | 
| 44 | 
            -
                    with_progress("Updating #{c(app.name, :name)}") do
         | 
| 45 | 
            -
                      app.urls << simple
         | 
| 46 | 
            -
                      app.update!
         | 
| 47 | 
            -
                    end
         | 
| 48 | 
            -
                  end
         | 
| 49 | 
            -
                end
         | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 52 | 
            -
                desc "Remove a URL mapping from an app"
         | 
| 53 | 
            -
                group :apps, :info, :hidden => true
         | 
| 54 | 
            -
                input :app, :desc => "Application to remove the URL from",
         | 
| 55 | 
            -
                      :argument => true, :from_given => by_name(:app)
         | 
| 56 | 
            -
                input :url, :desc => "URL to unmap", :argument => :optional
         | 
| 57 | 
            -
                def unmap
         | 
| 58 | 
            -
                  app = input[:app]
         | 
| 59 | 
            -
                  url = input[:url, app.urls]
         | 
| 60 | 
            -
             | 
| 61 | 
            -
                  simple = url.sub(/^https?:\/\/(.*)\/?/i, '\1')
         | 
| 62 | 
            -
             | 
| 63 | 
            -
                  if v2?
         | 
| 64 | 
            -
                    host, domain_name = simple.split(".", 2)
         | 
| 65 | 
            -
             | 
| 66 | 
            -
                    domain =
         | 
| 67 | 
            -
                      client.current_space.domain_by_name(domain_name, :depth => 0)
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                    fail "Invalid domain '#{domain_name}'" unless domain
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                    route = app.routes_by_host(host, :depth => 0).find do |r|
         | 
| 72 | 
            -
                      r.domain == domain
         | 
| 73 | 
            -
                    end
         | 
| 74 | 
            -
             | 
| 75 | 
            -
                    fail "Invalid route '#{simple}'" unless route
         | 
| 76 | 
            -
             | 
| 77 | 
            -
                    with_progress("Removing route #{c(simple, :name)}") do
         | 
| 78 | 
            -
                      app.remove_route(route)
         | 
| 79 | 
            -
                    end
         | 
| 80 | 
            -
                  else
         | 
| 81 | 
            -
                    with_progress("Updating #{c(app.name, :name)}") do |s|
         | 
| 82 | 
            -
                      unless app.urls.delete(simple)
         | 
| 83 | 
            -
                        s.fail do
         | 
| 84 | 
            -
                          err "URL #{url} is not mapped to this application."
         | 
| 85 | 
            -
                          return
         | 
| 86 | 
            -
                        end
         | 
| 87 | 
            -
                      end
         | 
| 88 | 
            -
             | 
| 89 | 
            -
                      app.update!
         | 
| 90 | 
            -
                    end
         | 
| 91 | 
            -
                  end
         | 
| 92 | 
            -
                end
         | 
| 93 | 
            -
             | 
| 94 | 
            -
                private
         | 
| 95 | 
            -
             | 
| 96 | 
            -
                def ask_url(choices)
         | 
| 97 | 
            -
                  ask("Which URL?", :choices => choices)
         | 
| 98 | 
            -
                end
         | 
| 99 | 
            -
              end
         | 
| 100 | 
            -
            end
         |