vagrant-vmck 0.2.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 702e962985deff117d960b6ab57a2a4ac0050902
4
- data.tar.gz: a23724d365f4d744a291762a6a9a51effb070b36
2
+ SHA256:
3
+ metadata.gz: 82d621045e2fc2b556bcacaa6fc5a55aca78109566f9ffaeedb27ec82640d3c3
4
+ data.tar.gz: e1a349611a010f24749e6e656f4f354c51ed0689135f4743171a4665078612f2
5
5
  SHA512:
6
- metadata.gz: 0eab0cbd1c8dda52425372fac1ed3ea63609ca515592a33b630dba634afbba2d3d16f5855120b389ac3ba5d29276c3d58b57310d7c084f3c87d45da638d0b057
7
- data.tar.gz: 4e6df24ec7a661e36e3475e973b438365f18fc437114b00a672a4749c81743616588fac97e0937262ae62bcd18119ecf5139da4f2d01755894be7150906b2425
6
+ metadata.gz: ac952fc7c5845af3bf8a2961e7e561db9fec0fdb1ec58dc2928a26695c42da8dc7d51e799dd95f01ce896966e5bfe72316f0e6a9358c1431a243a922ebabdcd2
7
+ data.tar.gz: 143dc9e194e9ca8d4c4effe52d2d062af97a1bfbf943fa9bbd4a6c4eb78cf3f8f8df2f08f3655fee58e65008826bed23473d69d7eb8cacd195c231bbfb0b1a3f
data/.drone.yml CHANGED
@@ -71,6 +71,9 @@ steps:
71
71
  when:
72
72
  event:
73
73
  - push
74
+ branch:
75
+ exclude:
76
+ - dependabot/*
74
77
 
75
78
  - name: docker push autotag + latest
76
79
  image: plugins/docker
@@ -81,17 +84,3 @@ steps:
81
84
  from_secret: docker_username
82
85
  password:
83
86
  from_secret: docker_password
84
-
85
- ---
86
- kind: secret
87
- name: docker_username
88
- get:
89
- path: liquid/ci/drone.docker
90
- name: username
91
-
92
- ---
93
- kind: secret
94
- name: docker_password
95
- get:
96
- path: liquid/ci/drone.docker
97
- name: password
@@ -0,0 +1,29 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ jobs:
9
+ build:
10
+ name: Build + Publish
11
+ runs-on: ubuntu-latest
12
+
13
+ steps:
14
+ - uses: actions/checkout@master
15
+ - name: Set up Ruby 2.6
16
+ uses: actions/setup-ruby@v1
17
+ with:
18
+ version: 2.6.x
19
+
20
+ - name: Publish to RubyGems
21
+ run: |
22
+ mkdir -p $HOME/.gem
23
+ touch $HOME/.gem/credentials
24
+ chmod 0600 $HOME/.gem/credentials
25
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
26
+ gem build *.gemspec
27
+ gem push *.gem
28
+ env:
29
+ GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
data/.gitignore CHANGED
@@ -1,5 +1,3 @@
1
1
  /.bundle/
2
2
  /Gemfile.lock
3
3
  .vagrant
4
- Vagrantfile
5
- !example_box/Vagrantfile
data/Dockerfile CHANGED
@@ -7,7 +7,9 @@ ADD . .
7
7
 
8
8
  RUN set -e \
9
9
  && apt-get update -q \
10
- && apt-get install -yq wget git procps kmod rsync ruby-dev \
10
+ && apt-get install -yq wget git procps kmod rsync ruby-dev curl \
11
+ && wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -O /usr/bin/jq \
12
+ && chmod +x /usr/bin/jq \
11
13
  && wget https://releases.hashicorp.com/vagrant/2.2.4/vagrant_2.2.4_x86_64.deb \
12
14
  && dpkg -i vagrant_2.2.4_x86_64.deb \
13
15
  && rm vagrant_2.2.4_x86_64.deb \
data/Gemfile CHANGED
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  group :development do
4
4
  gem 'vagrant', tag: 'v2.2.4', git: 'https://github.com/hashicorp/vagrant.git'
5
+ gem 'vagrant-env'
5
6
  end
6
7
 
7
8
  group :plugins do
data/Readme.md CHANGED
@@ -28,13 +28,30 @@ The vmck provider is also packaged as a docker image:
28
28
  ./examples/docker.sh --dev --env VMCK_URL=http://10.66.60.1:9995
29
29
  ```
30
30
 
31
+
32
+ ## Development
33
+
34
+ You can test the code using `bundle exec`:
35
+
36
+ ```shell
37
+ export VMCK_URL=http://localhost:10000
38
+ export VMCK_NAME="example"
39
+ export VAGRANT_CWD=examples/box
40
+
41
+ bundle install
42
+ bundle exec vagrant up
43
+ ```
44
+
45
+
31
46
  ## Release
47
+
32
48
  1. Update `lib/vagrant-vmck/version.rb` and commit
33
49
  2. `git tag v1.2.3; git push --tags`
34
- 3. `gem install gem-release; gem release`
35
- 4. `docker build . --tag vmck/vagrant-vmck:1.2.3 --no-cache`
36
- 5. `docker build . --tag vmck/vagrant-vmck` (should reuse the previous build)
37
- 6. `docker push vmck/vagrant-vmck`
50
+
51
+ The [gempush workflow](.github/workflows/gempush.yml) takes care of the rest,
52
+ see it work away in the [actions
53
+ tab](https://github.com/vmck/vagrant-vmck/actions).
54
+
38
55
 
39
56
  ## License
40
57
 
@@ -0,0 +1 @@
1
+ /.env
@@ -0,0 +1,28 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ Vagrant.configure("2") do |config|
5
+ if Vagrant.has_plugin?("vagrant-env")
6
+ config.env.enable
7
+ end
8
+
9
+ config.vm.box = "base"
10
+ config.nfs.functional = false
11
+ config.smb.functional = false
12
+
13
+ config.vm.provision 'hello', type: 'shell', inline: "
14
+ set -x
15
+ echo hello world
16
+ "
17
+
18
+ config.vm.provider :vmck do |vmck|
19
+ vmck.image_path = 'imgbuild-master.qcow2.tar.gz'
20
+ vmck.vmck_url = ENV['VMCK_URL']
21
+ vmck.memory = 512
22
+ vmck.cpus = 1
23
+ vmck.restrict_network = false
24
+ vmck.storage = ENV['VMCK_STORAGE']
25
+ vmck.name = ENV['VMCK_NAME']
26
+ end
27
+
28
+ end
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+ set -ex
3
+ vagrant plugin install vagrant-vmck vagrant-env
@@ -14,15 +14,22 @@ module VagrantPlugins
14
14
  def call(env)
15
15
  client = env[:vmck]
16
16
 
17
- env[:ui].info("Vmck starting job ...")
18
- options = {
19
- 'cpus': env[:machine].provider_config.cpus,
20
- 'memory': env[:machine].provider_config.memory,
21
- 'image_path': env[:machine].provider_config.image_path,
22
- 'storage': env[:machine].provider_config.storage,
23
- 'name': env[:machine].provider_config.name,
24
- }
25
- id = client.create(options)['id'].to_s
17
+ if ENV['VMCK_JOB_ID'].nil?
18
+ env[:ui].info("Vmck starting job ...")
19
+ options = {
20
+ 'cpus': env[:machine].provider_config.cpus,
21
+ 'memory': env[:machine].provider_config.memory,
22
+ 'image_path': env[:machine].provider_config.image_path,
23
+ 'storage': env[:machine].provider_config.storage,
24
+ 'name': env[:machine].provider_config.name,
25
+ 'restrict_network': env[:machine].provider_config.restrict_network,
26
+ }
27
+ id = client.create(options)['id'].to_s
28
+ else
29
+ id = ENV['VMCK_JOB_ID']
30
+ env[:ui].info("Vmck using existing job #{id}")
31
+ end
32
+
26
33
  env[:machine].id = id
27
34
 
28
35
  env[:ui].info("Vmck waiting for job #{id} to be ready ...")
@@ -1,3 +1,4 @@
1
+ require 'log4r'
1
2
  require 'faraday'
2
3
  require 'json'
3
4
 
@@ -6,7 +7,7 @@ module VagrantPlugins
6
7
  class Client
7
8
 
8
9
  def initialize(url)
9
- @logger = Log4r::Logger.new('vmck::client')
10
+ @logger = Log4r::Logger.new("vagrant_vmck::client")
10
11
  @client = Faraday.new({ :url => url })
11
12
  end
12
13
 
@@ -17,6 +18,7 @@ module VagrantPlugins
17
18
  req.url(path)
18
19
  if data
19
20
  req.headers['Content-Type'] = 'application/json'
21
+ @logger.info "Request body: #{data}"
20
22
  req.body = JSON.generate(data)
21
23
  end
22
24
  end
@@ -8,6 +8,7 @@ module VagrantPlugins
8
8
  attr_accessor :image_path
9
9
  attr_accessor :storage
10
10
  attr_accessor :name
11
+ attr_accessor :restrict_network
11
12
 
12
13
  def initialize
13
14
  @vmck_url = UNSET_VALUE
@@ -17,6 +18,7 @@ module VagrantPlugins
17
18
  @image_path = UNSET_VALUE
18
19
  @storage = UNSET_VALUE
19
20
  @name = UNSET_VALUE
21
+ @restrict_network = UNSET_VALUE
20
22
  end
21
23
 
22
24
  def finalize!
@@ -27,6 +29,7 @@ module VagrantPlugins
27
29
  @image_path = 'imgbuild-master.qcow2.tar.gz' if @image_path == UNSET_VALUE
28
30
  @storage = nil if @storage == UNSET_VALUE
29
31
  @name = 'default' if @name == UNSET_VALUE
32
+ @restrict_network = false if @restrict_network == UNSET_VALUE
30
33
  end
31
34
 
32
35
  end
@@ -9,10 +9,32 @@ module VagrantPlugins
9
9
  end
10
10
 
11
11
  provider :vmck do
12
+ setup_logging
13
+
12
14
  require_relative 'provider'
13
15
  Provider
14
16
  end
15
- end
16
17
 
18
+ def self.setup_logging
19
+ require "log4r"
20
+
21
+ level = nil
22
+ begin
23
+ level = Log4r.const_get(ENV["VAGRANT_LOG"].upcase)
24
+ rescue NameError
25
+ level = nil
26
+ end
27
+
28
+ level = nil if !level.is_a?(Integer)
29
+
30
+ if level
31
+ logger = Log4r::Logger.new("vagrant_vmck")
32
+ logger.outputters = Log4r::Outputter.stderr
33
+ logger.level = level
34
+ logger = nil
35
+ end
36
+ end
37
+
38
+ end
17
39
  end
18
40
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module Vmck
3
- VERSION = "0.2.1"
3
+ VERSION = "0.4.2"
4
4
  end
5
5
  end
@@ -0,0 +1,13 @@
1
+ Vagrant.configure("2") do |config|
2
+ config.vm.box = 'base'
3
+
4
+ if Vagrant.has_plugin?('vagrant-env')
5
+ config.env.enable
6
+ end
7
+
8
+ config.nfs.functional = false
9
+
10
+ config.vm.provider :vmck do |vmck|
11
+ vmck.vmck_url = ENV['VMCK_URL']
12
+ end
13
+ end
@@ -0,0 +1,31 @@
1
+ #!/bin/bash -ex
2
+
3
+ cd "$( dirname "${BASH_SOURCE[0]}" )"
4
+
5
+ trap "vagrant destroy -f" EXIT
6
+
7
+ curl "${VMCK_ARCHIVE_URL}" -o archive.zip
8
+ curl "${VMCK_SCRIPT_URL}" -o script.sh
9
+ curl "${VMCK_ARTIFACT_URL}" -o artifact.zip
10
+
11
+ chmod +x script.sh
12
+
13
+ vagrant up
14
+ (
15
+ set +e
16
+ vagrant ssh -- 'cd /vagrant; ./script.sh' &> result.out
17
+ echo $? > result.exit_code
18
+ )
19
+
20
+ exit_code=$(cat result.exit_code)
21
+ base64 result.out > stdout.tmp
22
+ cat stdout.tmp | tr -d '\n' > stdout
23
+
24
+ jq -n \
25
+ --rawfile out stdout \
26
+ --arg code $exit_code \
27
+ '{stdout: $out, exit_code: $code,}' > out.json
28
+
29
+ curl -X POST "${VMCK_CALLBACK_URL}" -d @out.json \
30
+ --header "Content-Type: application/json" \
31
+ --retry 20 --retry-connrefused
@@ -21,5 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency "log4r"
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 2.0"
24
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rake", "~> 13.0"
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-vmck
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Morega
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-03 00:00:00.000000000 Z
11
+ date: 2020-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '10.0'
75
+ version: '13.0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '10.0'
82
+ version: '13.0'
83
83
  description: Enables Vagrant to use Vmck jobs.
84
84
  email:
85
85
  - alex@grep.ro
@@ -88,13 +88,16 @@ extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
90
  - ".drone.yml"
91
+ - ".github/workflows/gempush.yml"
91
92
  - ".gitignore"
92
93
  - Dockerfile
93
94
  - Gemfile
94
95
  - LICENSE.txt
95
96
  - Readme.md
97
+ - examples/box/.gitignore
96
98
  - examples/box/Vagrantfile
97
99
  - examples/docker.sh
100
+ - examples/install.sh
98
101
  - lib/vagrant-vmck.rb
99
102
  - lib/vagrant-vmck/action.rb
100
103
  - lib/vagrant-vmck/action/connect_vmck.rb
@@ -107,6 +110,8 @@ files:
107
110
  - lib/vagrant-vmck/provider.rb
108
111
  - lib/vagrant-vmck/version.rb
109
112
  - run-test.sh
113
+ - submission/Vagrantfile
114
+ - submission/launch.sh
110
115
  - vagrant-vmck.gemspec
111
116
  homepage: https://github.com/mgax/vagrant-vmck
112
117
  licenses:
@@ -127,8 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
132
  - !ruby/object:Gem::Version
128
133
  version: '0'
129
134
  requirements: []
130
- rubyforge_project:
131
- rubygems_version: 2.5.2.3
135
+ rubygems_version: 3.0.3
132
136
  signing_key:
133
137
  specification_version: 4
134
138
  summary: Vagrant provider plugin for Vmck.