Skip to content

Commit

Permalink
changing code style,reconfiguring travis
Browse files Browse the repository at this point in the history
  • Loading branch information
IuriiMedvedev committed Nov 7, 2017
1 parent 86cc0b6 commit 28bd3d6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 56 deletions.
49 changes: 6 additions & 43 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,45 +1,8 @@
sudo: false

language: go
go:
- 1.9

env:
- GIMME_OS=linux GIMME_ARCH=amd64
- GIMME_OS=darwin GIMME_ARCH=amd64
- GIMME_OS=windows GIMME_ARCH=amd64

branches:
only:
- master

# workaround for travis-ci/gimme#25 to pick up latest version of gimme and run again
before_install:
- curl -o gimme -sL https://raw.githubusercontent.com/travis-ci/gimme/master/gimme
- chmod u+x gimme
- unset GOROOT GOTOOLDIR
- eval "$(./gimme 1.9)"
- go version
- go env

go: 1.9.1
install:
- date -u +"%Y-%m-%dT%H:%M:%SZ"
- go get -d -v ./...

script:
- go build -v -o terraform-provider-virtualbox
- tar czvf terraform-provider-virtualbox_${TRAVIS_TAG}_${GIMME_OS}_${GIMME_ARCH}.tar.gz terraform-provider-virtualbox

deploy:
# setup with "travis setup releases"
provider: releases
skip_cleanup: true
api_key:
secure: x_replace_via___travis_setup_releases___x
file: terraform-provider-virtualbox_*
file_glob: true
on:
repo: pyToshka/terraform-provider-virtualbox
#all_branches: true
branch: master
tags: true
- go get github.com/mitchellh/gox
- go get github.com/hashicorp/terraform
- go get
- go vet
- gox -os "freebsd darwin linux windows" -arch "386 amd64"
5 changes: 2 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ package main

import (
"github.com/hashicorp/terraform/plugin"
"./provider"
"github.com/pyToshka/terraform-provider-virtualbox/provider"
)

func main() {
plugin.Serve(&plugin.ServeOpts{
ProviderFunc: provider.Provider,
})
ProviderFunc: provider.Provider})
}
8 changes: 5 additions & 3 deletions provider/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import (
"os"
"os/exec"

"path/filepath"
"hash"
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"hash"
"io"
"path/filepath"
)

type Image struct {
// Image URL where to download from
URL string
Expand All @@ -25,6 +26,7 @@ type Image struct {
// Internal file reference
file *os.File
}

func unpackImage(image, toDir string) error {
/* Check if toDir exists */
_, err := os.Stat(toDir)
Expand Down Expand Up @@ -106,4 +108,4 @@ func (img *Image) verify() error {
}

return nil
}
}
15 changes: 8 additions & 7 deletions provider/resource_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ import (
"sync"
"time"

vbox "github.com/pyToshka/go-virtualbox"
"github.com/hashicorp/terraform/helper/schema"
multierror "github.com/hashicorp/go-multierror"
"os/exec"
"runtime"
"github.com/hashicorp/terraform/helper/schema"
vbox "github.com/pyToshka/go-virtualbox"
"io"
"net/http"
"os/exec"
"runtime"
)

var (
VBM string // Path to VBoxManage utility.
VBM string // Path to VBoxManage utility.
)

func init() {
Expand Down Expand Up @@ -224,7 +225,7 @@ func resourceVMCreate(d *schema.ResourceData, meta interface{}) error {
if p := os.Getenv("VBOX_INSTALL_PATH"); p != "" && runtime.GOOS == "windows" {
VBM = filepath.Join(p, "VBoxManage.exe")
}
setuiid := exec.Command(VBM + "internalcommands sethduuid " +src)
setuiid := exec.Command(VBM + "internalcommands sethduuid " + src)
err := setuiid.Run()
imageOpMutex.Lock() // Sequentialize image cloning to improve disk performance
err = vbox.CloneHD(src, target)
Expand Down Expand Up @@ -424,7 +425,7 @@ func WaitUntilVMIsReady(d *schema.ResourceData, vm *vbox.Machine, meta interface
continue
}
key := fmt.Sprintf("network_adapter.%d.ipv4_address_available", i)
_, err = WaitForVMAttribute(d,[]string{"yes"}, []string{"no"}, key, meta, 3*time.Second, 3*time.Second)
_, err = WaitForVMAttribute(d, []string{"yes"}, []string{"no"}, key, meta, 3*time.Second, 3*time.Second)
if err != nil {
return fmt.Errorf(
"Error waiting for VM (%s) to become ready: %s", d.Get("name"), err)
Expand Down

0 comments on commit 28bd3d6

Please sign in to comment.