[
  {
    "path": ".github/dependabot.yml",
    "content": "version: 2\nupdates:\n\n  - package-ecosystem: \"gomod\"\n    directory: \"/\"\n    schedule:\n      interval: \"daily\"\n\n  - package-ecosystem: \"github-actions\"\n    directory: \"/\"\n    schedule:\n      interval: \"daily\""
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "name: release\non:\n  push:\n    tags:\n      - '*'\n\njobs:\n  release:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout entire git history\n        uses: actions/checkout@v3.0.0\n        with:\n          fetch-depth: 0\n      - name: Set up Go\n        uses: actions/setup-go@v3\n        with:\n          go-version: '1.16'\n      - name: Run GoReleaser\n        uses: goreleaser/goreleaser-action@v2.9.1\n        with:\n          version: latest\n          args: release --rm-dist\n        env:\n          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}"
  },
  {
    "path": ".gitignore",
    "content": "#############################\n# Compiled source           #\n#############################\ndist/\nout/\n/docker-machine-driver-vmware\n/docker-machine-driver-vmware.exe\n\n#############################\n# Go files                  #\n#############################\n*.dll\n*.dylib\n*.exe\n*.exe~\n*.so\n\n#############################\n# IDE generated files       #\n#############################\n.idea/\n.vscode/\n*.iml\n\n#############################\n# Logs and temp files       #\n#############################\n*.log\n*.out\n*.tmp\n*~\n\n#############################\n# OS generated files        #\n#############################\nThumbs.db\n.directory\n.DS_Store\n"
  },
  {
    "path": ".goreleaser.yml",
    "content": "--- \nproject_name: docker-machine-driver-vmware\nbefore:\n  hooks:\n    - go mod tidy\n    # you may remove this if you don't need go generate\n    # - go generate ./...\nbuilds:\n  - env:\n      - CGO_ENABLED=0\n    goos:\n      - linux\n      - windows\n      - darwin\n    goarch: \n      - amd64\narchives:\n  - id: github\n    name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'\n    format: tar.gz\n    files:\n    - LICENSE*\n    - README*\nchecksum:\n  name_template: '{{ .ProjectName }}_{{ .Version }}_checksums.txt'\nchangelog:\n  sort: asc\n  filters:\n    exclude:\n      - '^typo'\n      - 'version bump'\nbrews:\n  - folder: Formula\n    tap:\n      owner: mikeroySoft\n      name: homebrew-tap\n    commit_author:\n      name: Michael Roy\n      email: mike@mikeroysoft.com\n    homepage: \"https://github.com/machine-drivers/docker-machine-driver-vmware/blob/master/README.md\"\n    description: \"Cross-platform docker-machine driver for VMware Fusion and Workstation\"\n    test: |\n      system \"#{bin}/docker-machine-driver-vmware -v\"\n    install: |\n      bin.install \"docker-machine-driver-vmware\""
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "Makefile",
    "content": "OUT_DIR := out\nPROG := docker-machine-driver-vmware\n\nGOOS ?= $(shell go env GOOS)\nGOARCH ?= $(shell go env GOARCH)\n\nifeq ($(GOOS),windows)\n\tBIN_SUFFIX := \".exe\"\nendif\n\n.PHONY: build\nbuild:\n\tgo build -o $(OUT_DIR)/$(PROG)$(BIN_SUFFIX) ./\n\n.PHONY: dep\ndep:\n\tdep ensure\n\n.PHONY: test\ntest:\n\tgo test -race ./...\n\n.PHONY: check\ncheck:\n\tgofmt -l -s -d pkg/ cmd/\n\tgo tool vet pkg/ cmd/\n\n.PHONY: integration\nintegration:\nifeq ($(GOOS),windows)\nelse\n\thack/integration.sh\nendif\n"
  },
  {
    "path": "README.md",
    "content": "# Docker Machine VMware Driver\n\nCreate Docker machines locally on VMware [Fusion](https://www.vmware.com/products/fusion)\nand [Workstation](https://www.vmware.com/products/workstation).\n\nThis driver requires VMware Workstation 14 (Windows/Linux) or VMware Fusion 10 (macOS)\nto be installed on your host. Earlier versions of Workstation/Fusion might still work\nwith this driver, but it's not officially supported.\n\n>\n> Docker machine has a builtin driver called `vmwarefusion`. The main difference between\n> those drivers is that `vmware` also works on VMware Workstation, while `vmwarefusion` only\n> works on VMware Fusion.\n>\n\n## License\n\nThe Docker Machine VMware Driver is released under the [Apache License 2.0](https://github.com/machine-drivers/docker-machine-driver-vmware/blob/master/LICENSE) license, for more information see LICENSE or https://www.apache.org/licenses/LICENSE-2.0\n\n## Installation\n\n### From a Release\n\nThe latest version of the `docker-machine-driver-vmware` binary is available on the\n[GitHub Releases](https://github.com/machine-drivers/docker-machine-driver-vmware/releases) page.\nDownload the binary that corresponds to your OS into a directory residing in your PATH.\n\n### From Homebrew\n\nThe driver is available for easy installation via Homebrew on macOS.\n\n```shell\n$ brew install docker-machine-driver-vmware\n```\n\n### From Source\n\nMake sure you have installed [Go](http://www.golang.org) and configured [GOPATH](http://golang.org/doc/code.html#GOPATH)\nproperly. For MacOS and Linux, make sure `$GOPATH/bin` is part of your `$PATH` for MacOS and Linux.\nFor Windows, make sure `%GOPATH%\\bin` is included in `%PATH%`.\n\nRun the following command:\n\n```shell\ngo get -u github.com/machine-drivers/docker-machine-driver-vmware\n```\n\n\n## Usage\n\n```shell\n$ docker-machine create --driver=vmware default\n```\n\n\n## Options\n\n- `--vmware-boot2docker-url`: URL for boot2docker image\n- `--vmware-configdrive-url`: URL for cloud-init configdrive\n- `--vmware-cpu-count`: Number of CPUs for the machine (-1 to use the number of CPUs available)\n- `--vmware-disk-size`: Size of disk for host VM (in MB)\n- `--vmware-memory-size`: Size of memory for host VM (in MB)\n- `--vmware-network-type`: Network connection type to use (e.g. 'nat', 'bridged', 'hostonly')\n- `--vmware-no-share`: Disable the mount of your home directory\n- `--vmware-ssh-password`: SSH password\n- `--vmware-ssh-user`: SSH user\n- `--vmware-wait-ip`: Time to wait for vmrun to get an ip (in milliseconds)\n\n#### Environment variables and default values\n\n| CLI option                 | Environment variable   | Default                  |\n|----------------------------|------------------------|--------------------------|\n| `--vmware-boot2docker-url` | VMWARE_BOOT2DOCKER_URL | *Latest boot2docker url* |\n| `--vmware-configdrive-url` | VMWARE_CONFIGDRIVE_URL | -                        |\n| `--vmware-cpu-count`       | VMWARE_CPU_COUNT       | `1`                      |\n| `--vmware-disk-size`       | VMWARE_DISK_SIZE       | `20000`                  |\n| `--vmware-memory-size`     | VMWARE_MEMORY_SIZE     | `1024`                   |\n| `--vmware-network-type`    | VMWARE_NETWORK_TYPE    | `nat`                    |\n| `--vmware-no-share`        | VMWARE_NO_SHARE        | -                        |\n| `--vmware-ssh-password`    | VMWARE_SSH_PASSWORD    | `tcuser`                 |\n| `--vmware-ssh-user`        | VMWARE_SSH_USER        | `docker`                 |\n| `--vmware-wait-ip`         | VMWARE_WAIT_IP         | `30000`                  |\n"
  },
  {
    "path": "go.mod",
    "content": "module github.com/machine-drivers/docker-machine-driver-vmware\n\ngo 1.15\n\nrequire (\n\tgithub.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect\n\tgithub.com/docker/docker v17.12.0-ce-rc1.0.20190115220918-5ec31380a5d3+incompatible // indirect\n\tgithub.com/docker/machine v0.16.2\n\tgithub.com/google/go-cmp v0.5.4 // indirect\n\tgithub.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95 // indirect\n\tgithub.com/pkg/errors v0.9.1 // indirect\n\tgithub.com/sirupsen/logrus v1.3.0 // indirect\n\tgolang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc\n\tgolang.org/x/sys v0.0.0-20190529164535-6a60838ec259\n\tgotest.tools v2.2.0+incompatible // indirect\n)\n\nreplace github.com/docker/machine => github.com/machine-drivers/machine v0.7.1-0.20210719174735-6eca26732baa\n"
  },
  {
    "path": "go.sum",
    "content": "github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 h1:w+iIsaOQNcT7OZ575w+acHgRric5iCyQh+xv+KJ4HB8=\ngithub.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8=\ngithub.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=\ngithub.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=\ngithub.com/docker/docker v17.12.0-ce-rc1.0.20190115220918-5ec31380a5d3+incompatible h1:9BKrmOW0BfGRCQUqcrYRzqlBH5e91YnmLKBOANMwc5E=\ngithub.com/docker/docker v17.12.0-ce-rc1.0.20190115220918-5ec31380a5d3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=\ngithub.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=\ngithub.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=\ngithub.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95 h1:S4qyfL2sEm5Budr4KVMyEniCy+PbS55651I/a+Kn/NQ=\ngithub.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95/go.mod h1:QiyDdbZLaJ/mZP4Zwc9g2QsfaEA4o7XvvgZegSci5/E=\ngithub.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=\ngithub.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=\ngithub.com/machine-drivers/machine v0.7.1-0.20210719174735-6eca26732baa h1:RDn5zVjqpQP8yElV/30YUNiDsjksDSqq30JVQfo1wzY=\ngithub.com/machine-drivers/machine v0.7.1-0.20210719174735-6eca26732baa/go.mod h1:79Uwa2hGd5S39LDJt58s8JZcIhGEK6pkq9bsuTbFWbk=\ngithub.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=\ngithub.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=\ngithub.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=\ngithub.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=\ngithub.com/sirupsen/logrus v1.3.0 h1:hI/7Q+DtNZ2kINb6qt/lS+IyXnHQe9e90POfeewL/ME=\ngithub.com/sirupsen/logrus v1.3.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=\ngithub.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=\ngithub.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=\ngithub.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=\ngolang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=\ngolang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc h1:F5tKCVGp+MUAHhKp5MZtGqAlGX3+oCsiL1Q629FL90M=\ngolang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=\ngolang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=\ngolang.org/x/sys v0.0.0-20190529164535-6a60838ec259 h1:so6Hr/LodwSZ5UQDu/7PmQiDeS112WwtLvU3lpSPZTU=\ngolang.org/x/sys v0.0.0-20190529164535-6a60838ec259/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=\ngolang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=\ngolang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=\ngotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=\ngotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=\n"
  },
  {
    "path": "hack/integration.sh",
    "content": "#!/bin/bash\n\nset -ex\n\nROOT=$(git rev-parse --show-toplevel)\n\ncheck_tool() {\n  echo \"Checking tool $1 ...\"\n  type \"$1\" >/dev/null || ( echo \"error: missing $1\" && exit 1 )\n}\n\ncheck_tool bats\ncheck_tool docker-machine\ncheck_tool docker-machine-driver-vmware\n\nbats $ROOT/test/*.bats\n"
  },
  {
    "path": "main.go",
    "content": "/*\nCopyright 2016 The Kubernetes Authors All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage main\n\nimport (\n\t\"github.com/docker/machine/libmachine/drivers/plugin\"\n\t\"github.com/machine-drivers/docker-machine-driver-vmware/pkg/drivers/vmware\"\n)\n\nfunc main() {\n\tplugin.RegisterDriver(vmware.NewDriver(\"\", \"\"))\n}\n"
  },
  {
    "path": "pkg/drivers/vmware/config/config.go",
    "content": "/*\nCopyright 2017 The Kubernetes Authors All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/*\n * Copyright 2017 VMware, Inc.  All rights reserved.  Licensed under the Apache v2 License.\n */\n\npackage config\n\nimport (\n\t\"github.com/docker/machine/libmachine/drivers\"\n\t\"github.com/docker/machine/libmachine/mcnflag\"\n)\n\nconst (\n\tdefaultSSHUser     = \"docker\"\n\tdefaultSSHPass     = \"tcuser\"\n\tdefaultDiskSize    = 20000\n\tdefaultCPU         = 1\n\tdefaultMemory      = 1024\n\tdefaultWaitIP      = 30000\n\tdefaultNetworkType = \"nat\"\n)\n\n// Config specifies the configuration of driver VMware\ntype Config struct {\n\t*drivers.BaseDriver\n\n\tMemory         int\n\tDiskSize       int\n\tCPU            int\n\tISO            string\n\tBoot2DockerURL string\n\n\tSSHPassword    string\n\tConfigDriveISO string\n\tConfigDriveURL string\n\tNoShare        bool\n\n\tWaitIP         int\n\tNetworkType    string\n}\n\n// NewConfig creates a new Config\nfunc NewConfig(hostname, storePath string) *Config {\n\treturn &Config{\n\t\tCPU:            defaultCPU,\n\t\tMemory:         defaultMemory,\n\t\tDiskSize:       defaultDiskSize,\n\t\tSSHPassword:    defaultSSHPass,\n\t\tWaitIP:         defaultWaitIP,\n\t\tNetworkType:    defaultNetworkType,\n\t\tBaseDriver: &drivers.BaseDriver{\n\t\t\tSSHUser:     defaultSSHUser,\n\t\t\tMachineName: hostname,\n\t\t\tStorePath:   storePath,\n\t\t},\n\t}\n}\n\n// GetCreateFlags registers the flags this driver adds to\n// \"docker hosts create\"\nfunc (c *Config) GetCreateFlags() []mcnflag.Flag {\n\treturn []mcnflag.Flag{\n\t\tmcnflag.StringFlag{\n\t\t\tEnvVar: \"VMWARE_BOOT2DOCKER_URL\",\n\t\t\tName:   \"vmware-boot2docker-url\",\n\t\t\tUsage:  \"URL for boot2docker image\",\n\t\t\tValue:  \"\",\n\t\t},\n\t\tmcnflag.StringFlag{\n\t\t\tEnvVar: \"VMWARE_CONFIGDRIVE_URL\",\n\t\t\tName:   \"vmware-configdrive-url\",\n\t\t\tUsage:  \"URL for cloud-init configdrive\",\n\t\t\tValue:  \"\",\n\t\t},\n\t\tmcnflag.IntFlag{\n\t\t\tEnvVar: \"VMWARE_CPU_COUNT\",\n\t\t\tName:   \"vmware-cpu-count\",\n\t\t\tUsage:  \"number of CPUs for the machine (-1 to use the number of CPUs available)\",\n\t\t\tValue:  defaultCPU,\n\t\t},\n\t\tmcnflag.IntFlag{\n\t\t\tEnvVar: \"VMWARE_MEMORY_SIZE\",\n\t\t\tName:   \"vmware-memory-size\",\n\t\t\tUsage:  \"size of memory for host VM (in MB)\",\n\t\t\tValue:  defaultMemory,\n\t\t},\n\t\tmcnflag.IntFlag{\n\t\t\tEnvVar: \"VMWARE_DISK_SIZE\",\n\t\t\tName:   \"vmware-disk-size\",\n\t\t\tUsage:  \"size of disk for host VM (in MB)\",\n\t\t\tValue:  defaultDiskSize,\n\t\t},\n\t\tmcnflag.StringFlag{\n\t\t\tEnvVar: \"VMWARE_SSH_USER\",\n\t\t\tName:   \"vmware-ssh-user\",\n\t\t\tUsage:  \"SSH user\",\n\t\t\tValue:  defaultSSHUser,\n\t\t},\n\t\tmcnflag.StringFlag{\n\t\t\tEnvVar: \"VMWARE_SSH_PASSWORD\",\n\t\t\tName:   \"vmware-ssh-password\",\n\t\t\tUsage:  \"SSH password\",\n\t\t\tValue:  defaultSSHPass,\n\t\t},\n\t\tmcnflag.BoolFlag{\n\t\t\tEnvVar: \"VMWARE_NO_SHARE\",\n\t\t\tName:   \"vmware-no-share\",\n\t\t\tUsage:  \"Disable the mount of your home directory\",\n\t\t},\n\t\tmcnflag.IntFlag{\n\t\t\tEnvVar: \"VMWARE_WAIT_IP\",\n\t\t\tName:   \"vmware-wait-ip\",\n\t\t\tUsage:  \"time to wait for vmrun to get an ip (in milliseconds)\",\n\t\t\tValue:  defaultWaitIP,\n\t\t},\n\t\tmcnflag.StringFlag{\n\t\t\tEnvVar: \"VMWARE_NETWORK_TYPE\",\n\t\t\tName:   \"vmware-network-type\",\n\t\t\tUsage:  \"Network connection type to use (e.g. 'nat', 'bridged', 'hostonly')\",\n\t\t\tValue:  defaultNetworkType,\n\t\t},\n\t}\n}\n"
  },
  {
    "path": "pkg/drivers/vmware/driver.go",
    "content": "/*\nCopyright 2017 The Kubernetes Authors All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/*\n * Copyright 2017 VMware, Inc.  All rights reserved.  Licensed under the Apache v2 License.\n */\n\npackage vmware\n\nimport (\n\t\"archive/tar\"\n\t\"bytes\"\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"net\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"regexp\"\n\t\"runtime\"\n\t\"strings\"\n\t\"text/template\"\n\t\"time\"\n\n\t\"github.com/docker/machine/libmachine/drivers\"\n\t\"github.com/docker/machine/libmachine/log\"\n\t\"github.com/docker/machine/libmachine/mcnutils\"\n\t\"github.com/docker/machine/libmachine/ssh\"\n\t\"github.com/docker/machine/libmachine/state\"\n\t\"github.com/machine-drivers/docker-machine-driver-vmware/pkg/drivers/vmware/config\"\n\tcryptossh \"golang.org/x/crypto/ssh\"\n)\n\nconst (\n\tisoFilename    = \"boot2docker.iso\"\n\tisoConfigDrive = \"configdrive.iso\"\n)\n\n// Driver for VMware\ntype Driver struct {\n\t*config.Config\n}\n\nfunc NewDriver(hostname, storePath string) drivers.Driver {\n\treturn &Driver{\n\t\tConfig: config.NewConfig(hostname, storePath),\n\t}\n}\n\nfunc (d *Driver) GetSSHHostname() (string, error) {\n\treturn d.GetIP()\n}\n\nfunc (d *Driver) GetSSHUsername() string {\n\tif d.SSHUser == \"\" {\n\t\td.SSHUser = \"docker\"\n\t}\n\n\treturn d.SSHUser\n}\n\n// DriverName returns the name of the driver\nfunc (d *Driver) DriverName() string {\n\treturn \"vmware\"\n}\n\nfunc (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {\n\td.Memory = flags.Int(\"vmware-memory-size\")\n\td.CPU = flags.Int(\"vmware-cpu-count\")\n\td.DiskSize = flags.Int(\"vmware-disk-size\")\n\td.Boot2DockerURL = flags.String(\"vmware-boot2docker-url\")\n\td.ConfigDriveURL = flags.String(\"vmware-configdrive-url\")\n\td.ISO = d.ResolveStorePath(isoFilename)\n\td.ConfigDriveISO = d.ResolveStorePath(isoConfigDrive)\n\td.SetSwarmConfigFromFlags(flags)\n\td.SSHUser = flags.String(\"vmware-ssh-user\")\n\td.SSHPassword = flags.String(\"vmware-ssh-password\")\n\td.SSHPort = 22\n\td.NoShare = flags.Bool(\"vmware-no-share\")\n\td.WaitIP = flags.Int(\"vmware-wait-ip\")\n\td.NetworkType = flags.String(\"vmware-network-type\")\n\n\t// We support a maximum of 16 cpu to be consistent with Virtual Hardware 10\n\t// specs.\n\tif d.CPU < 1 {\n\t\td.CPU = int(runtime.NumCPU())\n\t}\n\tif d.CPU > 16 {\n\t\td.CPU = 16\n\t}\n\n\treturn nil\n}\n\nfunc (d *Driver) GetURL() (string, error) {\n\tip, err := d.GetIP()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tif ip == \"\" {\n\t\treturn \"\", nil\n\t}\n\treturn fmt.Sprintf(\"tcp://%s\", net.JoinHostPort(ip, \"2376\")), nil\n}\n\nfunc (d *Driver) GetIP() (ip string, err error) {\n\ts, err := d.GetState()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif s != state.Running {\n\t\treturn \"\", drivers.ErrHostIsNotRunning\n\t}\n\n\t// attempt to find the address from vmrun\n\tif ip, err := d.getIPfromVmrun(); err == nil {\n\t\treturn ip, err\n\t}\n\n\t// determine MAC address for VM\n\tmacaddr, err := d.getMacAddressFromVmx()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// attempt to find the address in the vmnet configuration\n\tif ip, err = d.getIPfromVmnetConfiguration(macaddr); err == nil {\n\t\treturn ip, err\n\t}\n\n\t// address not found in vmnet so look for a DHCP lease\n\tip, err = d.getIPfromDHCPLease(macaddr)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn ip, nil\n}\n\nfunc (d *Driver) GetState() (state.State, error) {\n\t// VMRUN only tells use if the vm is running or not\n\tvmxp, err := filepath.EvalSymlinks(d.vmxPath())\n\tif err != nil {\n\t\treturn state.Error, err\n\t}\n\n\tif stdout, _, _ := vmrun(\"list\"); strings.Contains(stdout, vmxp) {\n\t\treturn state.Running, nil\n\t}\n\treturn state.Stopped, nil\n}\n\n// PreCreateCheck checks that the machine creation process can be started safely.\nfunc (d *Driver) PreCreateCheck() error {\n\t// Downloading boot2docker to cache should be done here to make sure\n\t// that a download failure will not leave a machine half created.\n\tb2dutils := mcnutils.NewB2dUtils(d.StorePath)\n\treturn b2dutils.UpdateISOCache(d.Boot2DockerURL)\n}\n\nfunc (d *Driver) Create() error {\n\tos.MkdirAll(filepath.Join(d.StorePath, \"machines\", d.GetMachineName()), 0755)\n\n\tb2dutils := mcnutils.NewB2dUtils(d.StorePath)\n\tif err := b2dutils.CopyIsoToMachineDir(d.Boot2DockerURL, d.MachineName); err != nil {\n\t\treturn err\n\t}\n\n\t// download cloud-init config drive\n\tif d.ConfigDriveURL != \"\" {\n\t\tif err := b2dutils.DownloadISO(d.ResolveStorePath(\".\"), isoConfigDrive, d.ConfigDriveURL); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tlog.Infof(\"Creating SSH key...\")\n\tif err := ssh.GenerateSSHKey(d.GetSSHKeyPath()); err != nil {\n\t\treturn err\n\t}\n\n\tlog.Infof(\"Creating VM...\")\n\tif err := os.MkdirAll(d.ResolveStorePath(\".\"), 0755); err != nil {\n\t\treturn err\n\t}\n\n\tif _, err := os.Stat(d.vmxPath()); err == nil {\n\t\treturn ErrMachineExist\n\t}\n\n\t// Generate vmx config file from template\n\tvmxt := template.Must(template.New(\"vmx\").Parse(vmx))\n\tvmxfile, err := os.Create(d.vmxPath())\n\tif err != nil {\n\t\treturn err\n\t}\n\tvmxt.Execute(vmxfile, d)\n\n\t// Generate vmdk file\n\tdiskImg := d.ResolveStorePath(fmt.Sprintf(\"%s.vmdk\", d.MachineName))\n\tif _, err := os.Stat(diskImg); err != nil {\n\t\tif !os.IsNotExist(err) {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := vdiskmanager(diskImg, d.DiskSize); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\treturn d.Start()\n}\n\nfunc (d *Driver) Start() error {\n\tlog.Infof(\"Starting %s...\", d.MachineName)\n\tvmrun(\"start\", d.vmxPath(), \"nogui\")\n\n\tvar ip string\n\tvar err error\n\n\tlog.Infof(\"Waiting for VM to come online...\")\n\tfor i := 1; i <= 60; i++ {\n\t\tip, err = d.GetIP()\n\t\tif err != nil {\n\t\t\tlog.Debugf(\"Not there yet %d/%d, error: %s\", i, 60, err)\n\t\t\ttime.Sleep(2 * time.Second)\n\t\t\tcontinue\n\t\t}\n\n\t\tif ip != \"\" {\n\t\t\tlog.Debugf(\"Got an ip: %s\", ip)\n\t\t\tconn, err := net.DialTimeout(\"tcp\", fmt.Sprintf(\"%s:%d\", ip, 22), time.Duration(2*time.Second))\n\t\t\tif err != nil {\n\t\t\t\tlog.Debugf(\"SSH Daemon not responding yet: %s\", err)\n\t\t\t\ttime.Sleep(2 * time.Second)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconn.Close()\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif ip == \"\" {\n\t\treturn fmt.Errorf(\"Machine didn't return an IP after 120 seconds, aborting\")\n\t}\n\n\t// we got an IP, let's copy ssh keys over\n\td.IPAddress = ip\n\n\t// Do not execute the rest of boot2docker specific configuration\n\t// The upload of the public ssh key uses a ssh connection,\n\t// this works without installed vmware client tools\n\tif d.ConfigDriveURL != \"\" {\n\t\tvar keyfh *os.File\n\t\tvar keycontent []byte\n\n\t\tlog.Infof(\"Copy public SSH key to %s [%s]\", d.MachineName, d.IPAddress)\n\n\t\t// create .ssh folder in users home\n\t\tif err := executeSSHCommand(fmt.Sprintf(\"mkdir -p /home/%s/.ssh\", d.SSHUser), d); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// read generated public ssh key\n\t\tif keyfh, err = os.Open(d.publicSSHKeyPath()); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer keyfh.Close()\n\n\t\tif keycontent, err = ioutil.ReadAll(keyfh); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// add public ssh key to authorized_keys\n\t\tif err := executeSSHCommand(fmt.Sprintf(\"echo '%s' > /home/%s/.ssh/authorized_keys\", string(keycontent), d.SSHUser), d); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\t// make it secure\n\t\tif err := executeSSHCommand(fmt.Sprintf(\"chmod 600 /home/%s/.ssh/authorized_keys\", d.SSHUser), d); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tlog.Debugf(\"Leaving create sequence early, configdrive found\")\n\t\treturn nil\n\t}\n\n\t// Generate a tar keys bundle\n\tif err := d.generateKeyBundle(); err != nil {\n\t\treturn err\n\t}\n\n\t// Test if /var/lib/boot2docker exists\n\tvmrun(\"-gu\", d.SSHUser, \"-gp\", d.SSHPassword, \"directoryExistsInGuest\", d.vmxPath(), \"/var/lib/boot2docker\")\n\n\t// Copy SSH keys bundle\n\tvmrun(\"-gu\", d.SSHUser, \"-gp\", d.SSHPassword, \"CopyFileFromHostToGuest\", d.vmxPath(), d.ResolveStorePath(\"userdata.tar\"), \"/home/docker/userdata.tar\")\n\n\t// Expand tar file.\n\tvmrun(\"-gu\", d.SSHUser, \"-gp\", d.SSHPassword, \"runScriptInGuest\", d.vmxPath(), \"/bin/sh\", \"sudo sh -c \\\"tar xvf /home/docker/userdata.tar -C /home/docker > /var/log/userdata.log 2>&1 && chown -R docker:staff /home/docker\\\"\")\n\n\t// copy to /var/lib/boot2docker\n\tvmrun(\"-gu\", d.SSHUser, \"-gp\", d.SSHPassword, \"runScriptInGuest\", d.vmxPath(), \"/bin/sh\", \"sudo /bin/mv /home/docker/userdata.tar /var/lib/boot2docker/userdata.tar\")\n\n\t// Enable Shared Folders\n\tvmrun(\"-gu\", d.SSHUser, \"-gp\", d.SSHPassword, \"enableSharedFolders\", d.vmxPath())\n\n\tshareName, hostDir, shareDir := getShareDriveAndName()\n\tif hostDir != \"\" && !d.NoShare {\n\t\tif _, err := os.Stat(hostDir); err != nil && !os.IsNotExist(err) {\n\t\t\treturn err\n\t\t} else if !os.IsNotExist(err) {\n\t\t\t// add shared folder, create mountpoint and mount it.\n\t\t\tvmrun(\"-gu\", d.SSHUser, \"-gp\", d.SSHPassword, \"addSharedFolder\", d.vmxPath(), shareName, hostDir)\n\t\t\tcommand := mountCommand(shareName, shareDir)\n\t\t\tvmrun(\"-gu\", d.SSHUser, \"-gp\", d.SSHPassword, \"runScriptInGuest\", d.vmxPath(), \"/bin/sh\", command)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (d *Driver) Stop() error {\n\t_, _, err := vmrun(\"stop\", d.vmxPath(), \"nogui\")\n\treturn err\n}\n\nfunc (d *Driver) Restart() error {\n\t// Stop VM gracefully\n\tif err := d.Stop(); err != nil {\n\t\treturn err\n\t}\n\t// Start it again and mount shared folder\n\treturn d.Start()\n}\n\nfunc (d *Driver) Kill() error {\n\t_, _, err := vmrun(\"stop\", d.vmxPath(), \"hard nogui\")\n\treturn err\n}\n\nfunc (d *Driver) Remove() error {\n\ts, _ := d.GetState()\n\tif s == state.Running {\n\t\tif err := d.Kill(); err != nil {\n\t\t\treturn fmt.Errorf(\"Error stopping VM before deletion\")\n\t\t}\n\t}\n\tlog.Infof(\"Deleting %s...\", d.MachineName)\n\tvmrun(\"deleteVM\", d.vmxPath(), \"nogui\")\n\treturn nil\n}\n\nfunc (d *Driver) Upgrade() error {\n\treturn fmt.Errorf(\"VMware does not currently support the upgrade operation\")\n}\n\nfunc (d *Driver) vmxPath() string {\n\treturn d.ResolveStorePath(fmt.Sprintf(\"%s.vmx\", d.MachineName))\n}\n\nfunc (d *Driver) vmdkPath() string {\n\treturn d.ResolveStorePath(fmt.Sprintf(\"%s.vmdk\", d.MachineName))\n}\n\nfunc (d *Driver) getMacAddressFromVmx() (string, error) {\n\tvar vmxfh *os.File\n\tvar vmxcontent []byte\n\tvar err error\n\n\tif vmxfh, err = os.Open(d.vmxPath()); err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer vmxfh.Close()\n\n\tif vmxcontent, err = ioutil.ReadAll(vmxfh); err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Look for generatedAddress as we're passing a VMX with addressType = \"generated\".\n\tvar macaddr string\n\tvmxparse := regexp.MustCompile(`^ethernet0.generatedAddress\\s*=\\s*\"(.*?)\"\\s*$`)\n\tfor _, line := range strings.Split(string(vmxcontent), \"\\n\") {\n\t\tif matches := vmxparse.FindStringSubmatch(line); matches == nil {\n\t\t\tcontinue\n\t\t} else {\n\t\t\tmacaddr = strings.ToLower(matches[1])\n\t\t}\n\t}\n\n\tif macaddr == \"\" {\n\t\treturn \"\", fmt.Errorf(\"couldn't find MAC address in VMX file %s\", d.vmxPath())\n\t}\n\n\tlog.Debugf(\"MAC address in VMX: %s\", macaddr)\n\n\treturn macaddr, nil\n}\n\nfunc (d *Driver) getIPfromVmrun() (string, error) {\n\tvmx := d.vmxPath()\n\n\tip := regexp.MustCompile(`\\d+\\.\\d+\\.\\d+\\.\\d+`)\n\tstdout, _, _ := vmrun_wait(time.Duration(d.WaitIP)*time.Millisecond, \"getGuestIPAddress\", vmx, \"-wait\")\n\tif match := ip.FindString(stdout); match != \"\" {\n\t\treturn match, nil\n\t}\n\n\treturn \"\", fmt.Errorf(\"could not get IP from vmrun\")\n}\n\nfunc (d *Driver) getIPfromVmnetConfiguration(macaddr string) (string, error) {\n\n\t// DHCP lease table for NAT vmnet interface\n\tconfFiles, _ := filepath.Glob(DhcpConfigFiles())\n\tfor _, conffile := range confFiles {\n\t\tlog.Debugf(\"Trying to find IP address in configuration file: %s\", conffile)\n\t\tif ipaddr, err := d.getIPfromVmnetConfigurationFile(conffile, macaddr); err == nil {\n\t\t\treturn ipaddr, err\n\t\t}\n\t}\n\n\treturn \"\", fmt.Errorf(\"IP not found for MAC %s in vmnet configuration files\", macaddr)\n}\n\nfunc (d *Driver) getIPfromVmnetConfigurationFile(conffile, macaddr string) (string, error) {\n\tvar conffh *os.File\n\tvar confcontent []byte\n\n\tvar currentip string\n\tvar lastipmatch string\n\tvar lastmacmatch string\n\n\tvar err error\n\n\tif conffh, err = os.Open(conffile); err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer conffh.Close()\n\n\tif confcontent, err = ioutil.ReadAll(conffh); err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// find all occurrences of 'host .* { .. }' and extract\n\t// out of the inner block the MAC and IP addresses\n\n\t// key = MAC, value = IP\n\tm := make(map[string]string)\n\n\t// Begin of a host block, that contains the IP, MAC\n\thostbegin := regexp.MustCompile(`^host (.+?) {`)\n\t// End of a host block\n\thostend := regexp.MustCompile(`^}`)\n\n\t// Get the IP address.\n\tip := regexp.MustCompile(`^\\s*fixed-address (.+?);\\r?$`)\n\t// Get the MAC address associated.\n\tmac := regexp.MustCompile(`^\\s*hardware ethernet (.+?);\\r?$`)\n\n\t// we use a block depth so that just in case inner blocks exists\n\t// we are not being fooled by them\n\tblockdepth := 0\n\tfor _, line := range strings.Split(string(confcontent), \"\\n\") {\n\n\t\tif matches := hostbegin.FindStringSubmatch(line); matches != nil {\n\t\t\tblockdepth = blockdepth + 1\n\t\t\tcontinue\n\t\t}\n\n\t\t// we are only in interested in endings if we in a block. Otherwise we will count\n\t\t// ending of non host blocks as well\n\t\tif matches := hostend.FindStringSubmatch(line); blockdepth > 0 && matches != nil {\n\t\t\tblockdepth = blockdepth - 1\n\n\t\t\tif blockdepth == 0 {\n\t\t\t\t// add data\n\t\t\t\tm[lastmacmatch] = lastipmatch\n\n\t\t\t\t// reset all temp var holders\n\t\t\t\tlastipmatch = \"\"\n\t\t\t\tlastmacmatch = \"\"\n\t\t\t}\n\n\t\t\tcontinue\n\t\t}\n\n\t\t// only if we are within the first level of a block\n\t\t// we are looking for addresses to extract\n\t\tif blockdepth == 1 {\n\t\t\tif matches := ip.FindStringSubmatch(line); matches != nil {\n\t\t\t\tlastipmatch = matches[1]\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tif matches := mac.FindStringSubmatch(line); matches != nil {\n\t\t\t\tlastmacmatch = strings.ToLower(matches[1])\n\t\t\t\tcontinue\n\t\t\t}\n\t\t}\n\t}\n\n\tlog.Debugf(\"Following IPs found %s\", m)\n\n\t// map is filled to now lets check if we have a MAC associated to an IP\n\tcurrentip, ok := m[strings.ToLower(macaddr)]\n\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"IP not found for MAC %s in vmnet configuration\", macaddr)\n\t}\n\n\tlog.Debugf(\"IP found in vmnet configuration file: %s\", currentip)\n\n\treturn currentip, nil\n\n}\n\nfunc (d *Driver) getIPfromDHCPLease(macaddr string) (string, error) {\n\n\t// DHCP lease table for NAT vmnet interface\n\tleasesFiles, _ := filepath.Glob(DhcpLeaseFiles())\n\tfor _, dhcpfile := range leasesFiles {\n\t\tlog.Debugf(\"Trying to find IP address in leases file: %s\", dhcpfile)\n\t\tif ipaddr, err := d.getIPfromDHCPLeaseFile(dhcpfile, macaddr); err == nil {\n\t\t\treturn ipaddr, err\n\t\t}\n\t}\n\n\treturn \"\", fmt.Errorf(\"IP not found for MAC %s in DHCP leases\", macaddr)\n}\n\nfunc (d *Driver) getIPfromDHCPLeaseFile(dhcpfile, macaddr string) (string, error) {\n\tvar dhcpfh *os.File\n\tvar dhcpcontent []byte\n\tvar lastipmatch string\n\tvar currentip string\n\tvar lastleaseendtime time.Time\n\tvar currentleadeendtime time.Time\n\tvar err error\n\n\tif dhcpfh, err = os.Open(dhcpfile); err != nil {\n\t\treturn \"\", err\n\t}\n\tdefer dhcpfh.Close()\n\n\tif dhcpcontent, err = ioutil.ReadAll(dhcpfh); err != nil {\n\t\treturn \"\", err\n\t}\n\n\t// Get the IP from the lease table.\n\tleaseip := regexp.MustCompile(`^lease (.+?) {\\r?$`)\n\t// Get the lease end date time.\n\tleaseend := regexp.MustCompile(`^\\s*ends \\d (.+?);\\r?$`)\n\t// Get the MAC address associated.\n\tleasemac := regexp.MustCompile(`^\\s*hardware ethernet (.+?);\\r?$`)\n\n\tfor _, line := range strings.Split(string(dhcpcontent), \"\\n\") {\n\n\t\tif matches := leaseip.FindStringSubmatch(line); matches != nil {\n\t\t\tlastipmatch = matches[1]\n\t\t\tcontinue\n\t\t}\n\n\t\tif matches := leaseend.FindStringSubmatch(line); matches != nil {\n\t\t\tlastleaseendtime, _ = time.Parse(\"2006/01/02 15:04:05\", matches[1])\n\t\t\tcontinue\n\t\t}\n\n\t\tif matches := leasemac.FindStringSubmatch(line); matches != nil && matches[1] == macaddr && currentleadeendtime.Before(lastleaseendtime) {\n\t\t\tcurrentip = lastipmatch\n\t\t\tcurrentleadeendtime = lastleaseendtime\n\t\t}\n\t}\n\n\tif currentip == \"\" {\n\t\treturn \"\", fmt.Errorf(\"IP not found for MAC %s in DHCP leases\", macaddr)\n\t}\n\n\tlog.Debugf(\"IP found in DHCP lease table: %s\", currentip)\n\n\treturn currentip, nil\n}\n\nfunc (d *Driver) publicSSHKeyPath() string {\n\treturn d.GetSSHKeyPath() + \".pub\"\n}\n\n// Make a boot2docker userdata.tar key bundle\nfunc (d *Driver) generateKeyBundle() error {\n\tlog.Debugf(\"Creating Tar key bundle...\")\n\n\tmagicString := \"boot2docker, this is vmware speaking\"\n\n\ttf, err := os.Create(d.ResolveStorePath(\"userdata.tar\"))\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer tf.Close()\n\tvar fileWriter = tf\n\n\ttw := tar.NewWriter(fileWriter)\n\tdefer tw.Close()\n\n\t// magicString first so we can figure out who originally wrote the tar.\n\tfile := &tar.Header{Name: magicString, Size: int64(len(magicString))}\n\tif err := tw.WriteHeader(file); err != nil {\n\t\treturn err\n\t}\n\tif _, err := tw.Write([]byte(magicString)); err != nil {\n\t\treturn err\n\t}\n\t// .ssh/key.pub => authorized_keys\n\tfile = &tar.Header{Name: \".ssh\", Typeflag: tar.TypeDir, Mode: 0700}\n\tif err := tw.WriteHeader(file); err != nil {\n\t\treturn err\n\t}\n\tpubKey, err := ioutil.ReadFile(d.publicSSHKeyPath())\n\tif err != nil {\n\t\treturn err\n\t}\n\tfile = &tar.Header{Name: \".ssh/authorized_keys\", Size: int64(len(pubKey)), Mode: 0644}\n\tif err := tw.WriteHeader(file); err != nil {\n\t\treturn err\n\t}\n\tif _, err := tw.Write([]byte(pubKey)); err != nil {\n\t\treturn err\n\t}\n\tfile = &tar.Header{Name: \".ssh/authorized_keys2\", Size: int64(len(pubKey)), Mode: 0644}\n\tif err := tw.WriteHeader(file); err != nil {\n\t\treturn err\n\t}\n\tif _, err := tw.Write([]byte(pubKey)); err != nil {\n\t\treturn err\n\t}\n\n\treturn tw.Close()\n}\n\n// execute command over SSH with user / password authentication\nfunc executeSSHCommand(command string, d *Driver) error {\n\tlog.Debugf(\"Execute executeSSHCommand: %s\", command)\n\n\tconfig := &cryptossh.ClientConfig{\n\t\tUser: d.SSHUser,\n\t\tAuth: []cryptossh.AuthMethod{\n\t\t\tcryptossh.Password(d.SSHPassword),\n\t\t},\n\t}\n\n\tclient, err := cryptossh.Dial(\"tcp\", fmt.Sprintf(\"%s:%d\", d.IPAddress, d.SSHPort), config)\n\tif err != nil {\n\t\tlog.Debugf(\"Failed to dial:\", err)\n\t\treturn err\n\t}\n\n\tsession, err := client.NewSession()\n\tif err != nil {\n\t\tlog.Debugf(\"Failed to create session: \" + err.Error())\n\t\treturn err\n\t}\n\tdefer session.Close()\n\n\tvar b bytes.Buffer\n\tsession.Stdout = &b\n\n\tif err := session.Run(command); err != nil {\n\t\tlog.Debugf(\"Failed to run: \" + err.Error())\n\t\treturn err\n\t}\n\tlog.Debugf(\"Stdout from executeSSHCommand: %s\", b.String())\n\n\treturn nil\n}\n\nfunc mountCommand(shareName, shareDir string) string {\n\t// Replace C:\\ to / due to Windows/Linux path difference\n\tshareDir = strings.Replace(shareDir, \"C:\\\\\", \"/\", 1)\n\treturn \"[ ! -d \" + shareDir + \" ]&& sudo mkdir \" + shareDir + \"; sudo mount --bind /mnt/hgfs/\" + shareDir + \" \" + shareDir + \" || [ -f /usr/local/bin/vmhgfs-fuse ]&& sudo /usr/local/bin/vmhgfs-fuse -o allow_other .host:/\" + shareName + \" \" + shareDir + \" || sudo mount -t vmhgfs -o uid=$(id -u),gid=$(id -g) .host:/\" + shareName + \" \" + shareDir\n}\n"
  },
  {
    "path": "pkg/drivers/vmware/driver_test.go",
    "content": "/*\nCopyright 2017 The Kubernetes Authors All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage vmware\n\nimport (\n\t\"io/ioutil\"\n\t\"log\"\n\t\"os\"\n\t\"testing\"\n\n\t\"github.com/docker/machine/libmachine/drivers\"\n\t\"github.com/docker/machine/libmachine/state\"\n)\n\nvar skip = !check(vmrunbin) || !check(vdiskmanbin)\n\nfunc check(path string) bool {\n\t_, err := os.Stat(path)\n\tif err != nil {\n\t\tlog.Printf(\"%q is missing\", path)\n\t\treturn false\n\t}\n\n\treturn true\n}\n\nfunc TestSetConfigFromFlags(t *testing.T) {\n\tdriver := NewDriver(\"default\", \"path\")\n\n\tcheckFlags := &drivers.CheckDriverOptions{\n\t\tFlagsValues: map[string]interface{}{},\n\t\tCreateFlags: driver.GetCreateFlags(),\n\t}\n\n\terr := driver.SetConfigFromFlags(checkFlags)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tif len(checkFlags.InvalidFlags) != 0 {\n\t\tt.Fatalf(\"expect len(checkFlags.InvalidFlags) == 0; got %d\", len(checkFlags.InvalidFlags))\n\t}\n}\n\nfunc TestDriver(t *testing.T) {\n\t// skip driver tests\n\tif true {\n\t\tt.Skip()\n\t}\n\n\tpath, err := ioutil.TempDir(\"\", \"vmware-driver-test\")\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tdefer os.RemoveAll(path)\n\n\tdriver := NewDriver(\"default\", path)\n\n\tcheckFlags := &drivers.CheckDriverOptions{\n\t\tFlagsValues: map[string]interface{}{},\n\t\tCreateFlags: driver.GetCreateFlags(),\n\t}\n\n\terr = driver.SetConfigFromFlags(checkFlags)\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tdriver.(*Driver).Boot2DockerURL = \"https://github.com/boot2docker/boot2docker/releases/download/v17.10.0-ce-rc2/boot2docker.iso\"\n\n\terr = driver.Create()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\n\tdefer driver.Remove()\n\n\tst, err := driver.GetState()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif st != state.Running {\n\t\tt.Fatalf(\"expect state == Running; got %s\", st.String())\n\t}\n\n\tip, err := driver.GetIP()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif ip == \"\" {\n\t\tt.Fatal(\"expect ip non-zero; got ''\")\n\t}\n\n\tusername := driver.GetSSHUsername()\n\tif username == \"\" {\n\t\tt.Fatal(\"expect username non-zero; got ''\")\n\t}\n\n\tkey := driver.GetSSHKeyPath()\n\tif key == \"\" {\n\t\tt.Fatal(\"expect key non-zero; got ''\")\n\t}\n\n\tport, err := driver.GetSSHPort()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif port == 0 {\n\t\tt.Fatal(\"expect port not 0; got 0\")\n\t}\n\n\thost, err := driver.GetSSHHostname()\n\tif err != nil {\n\t\tt.Fatal(err)\n\t}\n\tif host == \"\" {\n\t\tt.Fatal(\"expect host non-zero; got ''\")\n\t}\n}\n"
  },
  {
    "path": "pkg/drivers/vmware/vmrun.go",
    "content": "/*\nCopyright 2017 The Kubernetes Authors All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/*\n * Copyright 2017 VMware, Inc.  All rights reserved.  Licensed under the Apache v2 License.\n */\n\npackage vmware\n\nimport (\n\t\"bytes\"\n\t\"context\"\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"os/exec\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/docker/machine/libmachine/log\"\n)\n\nvar (\n\tvmrunbin    = setVmwareCmd(\"vmrun\")\n\tvdiskmanbin = setVmwareCmd(\"vmware-vdiskmanager\")\n)\n\nvar (\n\tErrMachineExist    = errors.New(\"machine already exists\")\n\tErrMachineNotExist = errors.New(\"machine does not exist\")\n\tErrVMRUNNotFound   = errors.New(\"VMRUN not found\")\n)\n\nfunc init() {\n\t// vmrun with nogui on VMware Fusion through at least 8.0.1 doesn't work right\n\t// if the umask is set to not allow world-readable permissions\n\tSetUmask()\n}\n\nfunc isMachineDebugEnabled() bool {\n\treturn os.Getenv(\"MACHINE_DEBUG\") != \"\"\n}\n\nfunc vmrun(args ...string) (string, string, error) {\n\tcmd := exec.Command(vmrunbin, args...)\n\treturn vmrun_cmd(cmd)\n}\n\nfunc vmrun_wait(timeout time.Duration, args ...string) (string, string, error) {\n\tctx, cancel := context.WithTimeout(context.Background(), timeout)\n\tdefer cancel()\n\n\tcmd := exec.CommandContext(ctx, vmrunbin, args...)\n\treturn vmrun_cmd(cmd)\n}\n\nfunc vmrun_cmd(cmd *exec.Cmd) (string, string, error) {\n\tvar stdout bytes.Buffer\n\tvar stderr bytes.Buffer\n\tcmd.Stdout, cmd.Stderr = &stdout, &stderr\n\n\tif isMachineDebugEnabled() {\n\t\t// write stdout to stderr because stdout is used for parsing sometimes\n\t\tcmd.Stdout = io.MultiWriter(os.Stderr, cmd.Stdout)\n\t\tcmd.Stderr = io.MultiWriter(os.Stderr, cmd.Stderr)\n\t}\n\n\tlog.Debugf(\"executing: %v\", strings.Join(cmd.Args, \" \"))\n\n\terr := cmd.Run()\n\tif err != nil {\n\t\tif ee, ok := err.(*exec.Error); ok && ee == exec.ErrNotFound {\n\t\t\terr = ErrVMRUNNotFound\n\t\t}\n\t}\n\n\treturn stdout.String(), stderr.String(), err\n}\n\n// Make a vmdk disk image with the given size (in MB).\nfunc vdiskmanager(dest string, size int) error {\n\tcmd := exec.Command(vdiskmanbin, \"-c\", \"-t\", \"0\", \"-s\", fmt.Sprintf(\"%dMB\", size), \"-a\", \"lsilogic\", dest)\n\tif isMachineDebugEnabled() {\n\t\t// write stdout to stderr because stdout is used for parsing sometimes\n\t\tcmd.Stdout = os.Stderr\n\t\tcmd.Stderr = os.Stderr\n\t}\n\n\tif stdout := cmd.Run(); stdout != nil {\n\t\tif ee, ok := stdout.(*exec.Error); ok && ee == exec.ErrNotFound {\n\t\t\treturn ErrVMRUNNotFound\n\t\t}\n\t}\n\treturn nil\n}\n"
  },
  {
    "path": "pkg/drivers/vmware/vmware.go",
    "content": "// +build !darwin,!linux,!windows\n\n/*\nCopyright 2017 The Kubernetes Authors All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage vmware\n\nimport \"github.com/docker/machine/libmachine/drivers\"\n\nfunc NewDriver(hostName, storePath string) drivers.Driver {\n\treturn drivers.NewDriverNotSupported(\"vmware\", hostName, storePath)\n}\n\nfunc DhcpConfigFiles() string {\n\treturn \"\"\n}\n\nfunc DhcpLeaseFiles() string {\n\treturn \"\"\n}\n\nfunc SetUmask() {\n}\n\nfunc setVmwareCmd(cmd string) string {\n\treturn \"\"\n}\n\nfunc getShareDriveAndName() (string, string, string) {\n\treturn \"\", \"\", \"\"\n}\n"
  },
  {
    "path": "pkg/drivers/vmware/vmware_darwin.go",
    "content": "/*\nCopyright 2017 The Kubernetes Authors All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage vmware\n\nimport (\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"syscall\"\n)\n\nfunc DhcpConfigFiles() string {\n\treturn \"/Library/Preferences/VMware Fusion/vmnet*/dhcpd.conf\"\n}\n\nfunc DhcpLeaseFiles() string {\n\treturn \"/var/db/vmware/*.leases\"\n}\n\nfunc SetUmask() {\n\t_ = syscall.Umask(022)\n}\n\n// detect the vmrun and vmware-vdiskmanager cmds' path if needed\nfunc setVmwareCmd(cmd string) string {\n\tif path, err := exec.LookPath(cmd); err == nil {\n\t\treturn path\n\t}\n\tfor _, fp := range []string{\n\t\t\"/Applications/VMware Fusion.app/Contents/Library/\",\n\t} {\n\t\tp := filepath.Join(fp, cmd)\n\t\t_, err := os.Stat(p)\n\t\tif err == nil {\n\t\t\treturn p\n\t\t}\n\t}\n\treturn cmd\n}\n\nfunc getShareDriveAndName() (string, string, string) {\n\treturn \"Users\", \"/Users\", \"/hosthome\"\n}\n"
  },
  {
    "path": "pkg/drivers/vmware/vmware_linux.go",
    "content": "/*\nCopyright 2017 The Kubernetes Authors All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage vmware\n\nimport (\n\t\"os/exec\"\n\t\"syscall\"\n)\n\nfunc DhcpConfigFiles() string {\n\treturn \"/etc/vmware/vmnet*/dhcpd/dhcpd.conf\"\n}\n\nfunc DhcpLeaseFiles() string {\n\treturn \"/etc/vmware/vmnet*/dhcpd/dhcpd.leases\"\n}\n\nfunc SetUmask() {\n\t_ = syscall.Umask(022)\n}\n\n// detect the vmrun and vmware-vdiskmanager cmds' path if needed\nfunc setVmwareCmd(cmd string) string {\n\tif path, err := exec.LookPath(cmd); err == nil {\n\t\treturn path\n\t}\n\treturn cmd\n}\n\nfunc getShareDriveAndName() (string, string, string) {\n\treturn \"hosthome\", \"/home\", \"/hosthome\"\n}\n"
  },
  {
    "path": "pkg/drivers/vmware/vmware_windows.go",
    "content": "/*\nCopyright 2017 The Kubernetes Authors All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\npackage vmware\n\nimport (\n\t\"fmt\"\n\t\"os\"\n\t\"path/filepath\"\n\n\t\"golang.org/x/sys/windows/registry\"\n)\n\n// https://docs.microsoft.com/en-us/windows/deployment/usmt/usmt-recognized-environment-variables\n\nfunc DhcpConfigFiles() string {\n\treturn filepath.Join(os.Getenv(\"ALLUSERSPROFILE\"), `VMware\\vmnetdhcp.conf`)\n}\n\nfunc DhcpLeaseFiles() string {\n\treturn filepath.Join(os.Getenv(\"ALLUSERSPROFILE\"), `VMware\\vmnetdhcp.leases`)\n}\n\nfunc SetUmask() {\n}\n\nfunc setVmwareCmd(cmd string) string {\n\tcmd = cmd + \".exe\"\n\tDefaultVMWareWSProductionRegistryKey := `SOFTWARE\\WOW6432Node\\VMware, Inc.`\n\tDefaultVMwareCorePathKey := \"Core\"\n\tk, err := registry.OpenKey(registry.LOCAL_MACHINE, DefaultVMWareWSProductionRegistryKey, registry.QUERY_VALUE)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tdefer k.Close()\n\tproduction, _, err := k.GetStringValue(DefaultVMwareCorePathKey)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\n\t//Get the VMware Product Install Path\n\tDefaultVMwareWSRegistryKey := fmt.Sprintf(`SOFTWARE\\WOW6432Node\\VMware, Inc.\\%s`, production)\n\tDefaultVMwareWSInstallPathKey := \"InstallPath\"\n\n\tkey, err := registry.OpenKey(registry.LOCAL_MACHINE, DefaultVMwareWSRegistryKey, registry.QUERY_VALUE)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\tdefer key.Close()\n\n\tvalue, _, err := key.GetStringValue(DefaultVMwareWSInstallPathKey)\n\tif err != nil {\n\t\treturn \"\"\n\t}\n\twindowsInstallDir := value\n\treturn filepath.Join(windowsInstallDir, cmd)\n}\n\nfunc getShareDriveAndName() (string, string, string) {\n\treturn \"Users\", os.Getenv(\"PUBLIC\"), \"/hosthome\"\n}\n"
  },
  {
    "path": "pkg/drivers/vmware/vmx.go",
    "content": "/*\nCopyright 2017 The Kubernetes Authors All rights reserved.\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n*/\n\n/*\n * Copyright 2017 VMware, Inc.  All rights reserved.  Licensed under the Apache v2 License.\n */\n\npackage vmware\n\nconst vmx = `\n.encoding = \"UTF-8\"\nconfig.version = \"8\"\ndisplayName = \"{{.MachineName}}\"\nethernet0.present = \"TRUE\"\nethernet0.connectionType = \"{{.NetworkType}}\"\nethernet0.virtualDev = \"vmxnet3\"\nethernet0.wakeOnPcktRcv = \"FALSE\"\nethernet0.addressType = \"generated\"\nethernet0.linkStatePropagation.enable = \"TRUE\"\npciBridge0.present = \"TRUE\"\npciBridge4.present = \"TRUE\"\npciBridge4.virtualDev = \"pcieRootPort\"\npciBridge4.functions = \"8\"\npciBridge5.present = \"TRUE\"\npciBridge5.virtualDev = \"pcieRootPort\"\npciBridge5.functions = \"8\"\npciBridge6.present = \"TRUE\"\npciBridge6.virtualDev = \"pcieRootPort\"\npciBridge6.functions = \"8\"\npciBridge7.present = \"TRUE\"\npciBridge7.virtualDev = \"pcieRootPort\"\npciBridge7.functions = \"8\"\npciBridge0.pciSlotNumber = \"17\"\npciBridge4.pciSlotNumber = \"21\"\npciBridge5.pciSlotNumber = \"22\"\npciBridge6.pciSlotNumber = \"23\"\npciBridge7.pciSlotNumber = \"24\"\nscsi0.pciSlotNumber = \"160\"\nusb.pciSlotNumber = \"32\"\nethernet0.pciSlotNumber = \"192\"\nsound.pciSlotNumber = \"33\"\nvmci0.pciSlotNumber = \"35\"\nsata0.pciSlotNumber = \"36\"\nfloppy0.present = \"FALSE\"\nguestOS = \"other3xlinux-64\"\nhpet0.present = \"TRUE\"\nsata0.present = \"TRUE\"\nsata0:1.present = \"TRUE\"\nsata0:1.fileName = \"{{.ISO}}\"\nsata0:1.deviceType = \"cdrom-image\"\n{{ if .ConfigDriveURL }}\nsata0:2.present = \"TRUE\"\nsata0:2.fileName = \"{{.ConfigDriveISO}}\"\nsata0:2.deviceType = \"cdrom-image\"\n{{ end }}\nvmci0.present = \"TRUE\"\nmem.hotadd = \"TRUE\"\nmemsize = \"{{.Memory}}\"\npowerType.powerOff = \"soft\"\npowerType.powerOn = \"soft\"\npowerType.reset = \"soft\"\npowerType.suspend = \"soft\"\nscsi0.present = \"TRUE\"\nscsi0.virtualDev = \"pvscsi\"\nscsi0:0.fileName = \"{{.MachineName}}.vmdk\"\nscsi0:0.present = \"TRUE\"\ntools.synctime = \"TRUE\"\nvirtualHW.productCompatibility = \"hosted\"\nvirtualHW.version = \"10\"\nmsg.autoanswer = \"TRUE\"\nuuid.action = \"create\"\nnumvcpus = \"{{.CPU}}\"\nhgfs.mapRootShare = \"FALSE\"\nhgfs.linkRootShare = \"FALSE\"\n`\n"
  },
  {
    "path": "test/docker-machine.bats",
    "content": "#!/usr/bin/env bats\n\nload test_helper\nload env\n\n@test \"lifecycle\" {\n  id=\"vm-$$\"\n  run docker-machine create --driver=\"${DRIVER}\" \"${id}\"\n  assert_success\n\n  run docker-machine status \"${id}\"\n  assert_output \"Running\"\n\n  run docker-machine url \"${id}\"\n  assert_matches \"^[a-z]+://([0-9]{1,3}\\.){3}[0-9]{1,3}:[0-9]+$\"\n\n  run docker-machine ip \"${id}\"\n  assert_matches \"^([0-9]{1,3}\\.){3}[0-9]{1,3}$\"\n\n  run docker-machine ssh \"$id\" ls\n  assert_matches \"boot2docker\"\n\n  run docker-machine restart \"${id}\"\n  assert_success\n\n  run docker-machine stop \"${id}\"\n  assert_success\n\n  run docker-machine status \"${id}\"\n  assert_output \"Stopped\"\n\n  run docker-machine start \"${id}\"\n  assert_success\n\n  run docker-machine kill \"${id}\"\n  assert_success\n\n  run docker-machine status \"${id}\"\n  assert_output \"Stopped\"\n\n  run docker-machine rm \"${id}\" -f\n  assert_success\n\n  run docker-machine status \"${id}\"\n  assert_failure\n}\n"
  },
  {
    "path": "test/env.bash",
    "content": "DRIVER=vmware\n"
  },
  {
    "path": "test/test_helper.bash",
    "content": "# the following helpers are borrowed from the test_helper.bash in https://github.com/sstephenson/rbenv\n\nflunk() {\n  { if [ \"$#\" -eq 0 ]; then cat -\n    else echo \"$@\"\n    fi\n  } >&2\n  return 1\n}\n\nassert_success() {\n  if [ \"$status\" -ne 0 ]; then\n    flunk \"command failed with exit status $status: $output\"\n  elif [ \"$#\" -gt 0 ]; then\n    assert_output \"$1\"\n  fi\n}\n\nassert_failure() {\n  if [ \"$status\" -ne 1 ]; then\n    flunk $(printf \"expected failed exit status=1, got status=%d\" $status)\n  elif [ \"$#\" -gt 0 ]; then\n    assert_output \"$1\"\n  fi\n}\n\nassert_equal() {\n  if [ \"$1\" != \"$2\" ]; then\n    { echo \"expected: $1\"\n      echo \"actual:   $2\"\n    } | flunk\n  fi\n}\n\nassert_output() {\n  local expected\n  if [ $# -eq 0 ]; then expected=\"$(cat -)\"\n  else expected=\"$1\"\n  fi\n  assert_equal \"$expected\" \"$output\"\n}\n\nassert_matches() {\n  local pattern=\"${1}\"\n  local actual=\"${2}\"\n\n  if [ $# -eq 1 ]; then\n    actual=\"$output\"\n  fi\n\n  if ! grep -E -q \"${pattern}\" <<<\"${actual}\"; then\n    { echo \"pattern: ${pattern}\"\n      echo \"actual:  ${actual}\"\n    } | flunk\n  fi\n}\n\nassert_number() {\n  assert_matches \"^-?[0-9]+$\" \"$output\"\n}\n\nassert_empty() {\n  local actual=\"${1}\"\n\n  if [ $# -eq 0 ]; then\n    actual=\"$(cat -)\"\n  fi\n\n  if [ -n \"${actual}\" ]; then\n    { echo \"actual: ${actual}\"\n    } | flunk\n  fi\n}\n\nassert_line() {\n  if [ \"$1\" -ge 0 ] 2>/dev/null; then\n    assert_equal \"$2\" \"$(collapse_ws ${lines[$1]})\"\n  else\n    local line\n    for line in \"${lines[@]}\"; do\n      if [ \"$(collapse_ws $line)\" = \"$1\" ]; then return 0; fi\n    done\n    flunk \"expected line \\`$1'\"\n  fi\n}\n\nrefute_line() {\n  if [ \"$1\" -ge 0 ] 2>/dev/null; then\n    local num_lines=\"${#lines[@]}\"\n    if [ \"$1\" -lt \"$num_lines\" ]; then\n      flunk \"output has $num_lines lines\"\n    fi\n  else\n    local line\n    for line in \"${lines[@]}\"; do\n      if [ \"$line\" = \"$1\" ]; then\n        flunk \"expected to not find line \\`$line'\"\n      fi\n    done\n  fi\n}\n\nassert() {\n  if ! \"$@\"; then\n    flunk \"failed: $*\"\n  fi\n}\n"
  }
]