vagrant-goodhosts 1.0.9 → 1.0.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.
- checksums.yaml +4 -4
 - data/README.md +9 -0
 - data/lib/vagrant-goodhosts/GoodHosts.rb +27 -9
 - data/lib/vagrant-goodhosts/config.rb +5 -0
 - data/lib/vagrant-goodhosts/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b6661999d4e2dfba792e5a925f4674cca24b6b3e523b8f2b3427933ce09570c6
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: c869c926f280627a4198f8cebcfe47aefffc24e1993e6558a637726d0471dd1a
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ee107d64bdd466fe0d96778dff5f71a9783ebe0e77392909eb0e7f041941fe436987c39a1d1967b89ef4922aed18ae579c117677c5c3b0e08e276be318d3e1e0
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 5ccb050a4ff37df1db7c0ba61788cf1149d28c6b05d9e470e91263538c3ef9c287ac1777f03500f84ae205c3460ac1793aed94e49bc0506dc4f057501d9230df
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -78,6 +78,15 @@ config.goodhosts.remove_on_suspend = false 
     | 
|
| 
       78 
78 
     | 
    
         | 
| 
       79 
79 
     | 
    
         
             
            This disables `vagrant-goodhosts` from running on **suspend** and **halt**.
         
     | 
| 
       80 
80 
     | 
    
         | 
| 
      
 81 
     | 
    
         
            +
            ### Disable file hosts clean
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
            If you don't want `/etc/hosts` file cleaned add in your `VagrantFile`:
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 86 
     | 
    
         
            +
            config.goodhosts.disable_clean = true
         
     | 
| 
      
 87 
     | 
    
         
            +
            ```
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            This disables `vagrant-goodhosts` from running the clean command.
         
     | 
| 
       81 
90 
     | 
    
         | 
| 
       82 
91 
     | 
    
         
             
            ## Suppressing prompts for elevating privileges
         
     | 
| 
       83 
92 
     | 
    
         | 
| 
         @@ -79,25 +79,38 @@ module VagrantPlugins 
     | 
|
| 
       79 
79 
     | 
    
         | 
| 
       80 
80 
     | 
    
         
             
                    return hostnames
         
     | 
| 
       81 
81 
     | 
    
         
             
                  end
         
     | 
| 
      
 82 
     | 
    
         
            +
                  
         
     | 
| 
      
 83 
     | 
    
         
            +
                  def shouldClean(ip_address)
         
     | 
| 
      
 84 
     | 
    
         
            +
                    unless ip_address.nil?
         
     | 
| 
      
 85 
     | 
    
         
            +
                      return @machine.config.goodhosts.disable_clean
         
     | 
| 
      
 86 
     | 
    
         
            +
                    end
         
     | 
| 
      
 87 
     | 
    
         
            +
                    return true
         
     | 
| 
      
 88 
     | 
    
         
            +
                  end
         
     | 
| 
       82 
89 
     | 
    
         | 
| 
       83 
90 
     | 
    
         
             
                  def addHostEntries
         
     | 
| 
       84 
91 
     | 
    
         
             
                    error = false
         
     | 
| 
       85 
92 
     | 
    
         
             
                    errorText = ""
         
     | 
| 
       86 
93 
     | 
    
         
             
                    cli = get_cli
         
     | 
| 
       87 
94 
     | 
    
         
             
                    hostnames_by_ips = generateHostnamesByIps
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
                    return if hostnames_by_ips. 
     | 
| 
      
 95 
     | 
    
         
            +
                    
         
     | 
| 
      
 96 
     | 
    
         
            +
                    return if not hostnames_by_ips.any?
         
     | 
| 
       90 
97 
     | 
    
         | 
| 
       91 
98 
     | 
    
         
             
                    hostnames_by_ips.each do |ip_address, hostnames|
         
     | 
| 
       92 
     | 
    
         
            -
                      next if hostnames.empty?
         
     | 
| 
       93 
99 
     | 
    
         
             
                      if ip_address.nil?
         
     | 
| 
       94 
100 
     | 
    
         
             
                        @ui.error "[vagrant-goodhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
         
     | 
| 
       95 
101 
     | 
    
         
             
                        next
         
     | 
| 
       96 
102 
     | 
    
         
             
                      end
         
     | 
| 
      
 103 
     | 
    
         
            +
                      clean  = ''
         
     | 
| 
       97 
104 
     | 
    
         
             
                      if cli.include? ".exe"
         
     | 
| 
       98 
     | 
    
         
            -
                         
     | 
| 
      
 105 
     | 
    
         
            +
                        if not shouldClean(ip_address)
         
     | 
| 
      
 106 
     | 
    
         
            +
                          clean = "\"--clean\","
         
     | 
| 
      
 107 
     | 
    
         
            +
                        end
         
     | 
| 
      
 108 
     | 
    
         
            +
                        stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"add\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
         
     | 
| 
       99 
109 
     | 
    
         
             
                      else
         
     | 
| 
       100 
     | 
    
         
            -
                         
     | 
| 
      
 110 
     | 
    
         
            +
                        if not shouldClean(ip_address)
         
     | 
| 
      
 111 
     | 
    
         
            +
                          clean = "--clean"
         
     | 
| 
      
 112 
     | 
    
         
            +
                        end
         
     | 
| 
      
 113 
     | 
    
         
            +
                        stdin, stdout, stderr, wait_thr = Open3.popen3("sudo", cli, "add", clean, ip_address, hostnames)
         
     | 
| 
       101 
114 
     | 
    
         
             
                      end
         
     | 
| 
       102 
115 
     | 
    
         
             
                      if !wait_thr.value.success?
         
     | 
| 
       103 
116 
     | 
    
         
             
                        error = true
         
     | 
| 
         @@ -113,18 +126,23 @@ module VagrantPlugins 
     | 
|
| 
       113 
126 
     | 
    
         
             
                    cli = get_cli
         
     | 
| 
       114 
127 
     | 
    
         
             
                    hostnames_by_ips = generateHostnamesByIps
         
     | 
| 
       115 
128 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
                    return if hostnames_by_ips. 
     | 
| 
      
 129 
     | 
    
         
            +
                    return if not hostnames_by_ips.any?
         
     | 
| 
       117 
130 
     | 
    
         | 
| 
       118 
131 
     | 
    
         
             
                    hostnames_by_ips.each do |ip_address, hostnames|
         
     | 
| 
       119 
     | 
    
         
            -
                      next if hostnames.empty?
         
     | 
| 
       120 
132 
     | 
    
         
             
                      if ip_address.nil?
         
     | 
| 
       121 
133 
     | 
    
         
             
                        @ui.error "[vagrant-goodhosts] Error adding some hosts, no IP was provided for the following hostnames: #{hostnames}"
         
     | 
| 
       122 
134 
     | 
    
         
             
                        next
         
     | 
| 
       123 
135 
     | 
    
         
             
                      end
         
     | 
| 
       124 
136 
     | 
    
         
             
                      if cli.include? ".exe"
         
     | 
| 
       125 
     | 
    
         
            -
                         
     | 
| 
      
 137 
     | 
    
         
            +
                        if not shouldClean(ip_address)
         
     | 
| 
      
 138 
     | 
    
         
            +
                          clean = "\"--clean\","
         
     | 
| 
      
 139 
     | 
    
         
            +
                        end
         
     | 
| 
      
 140 
     | 
    
         
            +
                        stdin, stdout, stderr, wait_thr = Open3.popen3("powershell", "-Command", "Start-Process '#{cli}' -ArgumentList \"remove\",#{clean}\"#{ip_address}\",\"#{hostnames}\" -Verb RunAs")
         
     | 
| 
       126 
141 
     | 
    
         
             
                      else
         
     | 
| 
       127 
     | 
    
         
            -
                         
     | 
| 
      
 142 
     | 
    
         
            +
                        if not shouldClean(ip_address)
         
     | 
| 
      
 143 
     | 
    
         
            +
                          clean = "--clean"
         
     | 
| 
      
 144 
     | 
    
         
            +
                        end
         
     | 
| 
      
 145 
     | 
    
         
            +
                        stdin, stdout, stderr, wait_thr = Open3.popen3("sudo", cli, "remove", clean, ip_address, hostnames)
         
     | 
| 
       128 
146 
     | 
    
         
             
                      end
         
     | 
| 
       129 
147 
     | 
    
         
             
                      if !wait_thr.value.success?
         
     | 
| 
       130 
148 
     | 
    
         
             
                        error = true
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: vagrant-goodhosts
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.0.10
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Daniele Scasciafratte
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-01-18 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       81 
81 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       82 
82 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       83 
83 
     | 
    
         
             
            requirements: []
         
     | 
| 
       84 
     | 
    
         
            -
            rubygems_version: 3.2. 
     | 
| 
      
 84 
     | 
    
         
            +
            rubygems_version: 3.2.5
         
     | 
| 
       85 
85 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       86 
86 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       87 
87 
     | 
    
         
             
            summary: Enables Vagrant to update hosts file on the host machine with goodhosts
         
     |