### Install go-colorable Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/README.md Use the go get command to add the package to your project. ```bash $ go get github.com/mattn/go-colorable ``` -------------------------------- ### Install go-isatty Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/README.md Command to install the library via the Go toolchain. ```bash $ go get github.com/mattn/go-isatty ``` -------------------------------- ### Install doublestar Package Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md Use 'go get' to install the doublestar package. This command fetches and installs the package and its dependencies. ```bash go get github.com/bmatcuk/doublestar ``` -------------------------------- ### Installation Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md Instructions on how to install and import the doublestar package. ```bash go get github.com/bmatcuk/doublestar ``` ```go import "github.com/bmatcuk/doublestar" ``` -------------------------------- ### Example Output Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/gopkg.in/yaml.v2/README.md The expected output generated by running the provided Go example code. ```text --- t: {Easy! {2 [3 4]}} --- t dump: a: Easy! b: c: 2 d: [3, 4] --- m: map[a:Easy! b:map[c:2 d:[3 4]]] --- m dump: a: Easy! b: c: 2 d: - 3 - 4 ``` -------------------------------- ### Setup Ginkgo Development Environment Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/CONTRIBUTING.md Commands to fetch the repository, configure remotes, and verify the environment with tests and linters. ```bash go get github.com/onsi/ginkgo go get github.com/onsi/gomega/... cd $GOPATH/src/github.com/onsi/ginkgo git remote add fork git@github.com:/ginkgo.git ginkgo -r -p # ensure tests are green go vet ./... # ensure linter is happy ``` -------------------------------- ### Install Ginkgo CLI Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/README.md Installs the Ginkgo command-line interface globally. Ensure your $GOBIN is in your $PATH. ```bash go get -u github.com/onsi/ginkgo/ginkgo ``` -------------------------------- ### Install nxadm/tail Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/nxadm/tail/README.md Command to install the library using the Go toolchain. ```bash go get github.com/nxadm/tail/... ``` -------------------------------- ### Install YAML package Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/gopkg.in/yaml.v2/README.md Command to install the package via the Go toolchain. ```bash go get gopkg.in/yaml.v2 ``` -------------------------------- ### Create VM Operation Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Go interface definition and example cloud properties for the CreateVM operation. ```go // CreateVM creates a new VM from a stemcell func (a VMs) CreateVM( agentID apiv1.AgentID, stemcellCID apiv1.StemcellCID, cloudProps apiv1.VMCloudProps, networks apiv1.Networks, diskCIDs []apiv1.DiskCID, env apiv1.VMEnv, ) (apiv1.VMCID, error) // Example cloud_properties for CreateVM { "cpus": 2, "memory": 2048, "ephemeral_disk": 5000, "firmware": "efi64", "paravirtprovider": "default", "audio": "none" } ``` -------------------------------- ### Install dependencies Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/fsnotify/fsnotify/README.md Command to ensure the latest version of the required system package is installed. ```console go get -u golang.org/x/sys/... ``` -------------------------------- ### Describe a test suite with Ginkgo Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/README.md Use `Describe`, `Context`, and `When` to structure tests. This example demonstrates testing the `strings.Contains` function. ```go Describe("the strings package", func() { Context("strings.Contains()", func() { When("the string contains the substring in the middle", func() { It("returns `true`", func() { Expect(strings.Contains("Ginkgo is awesome", "is")).To(BeTrue()) }) }) }) }) ``` -------------------------------- ### Configure Manual Network Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/docs/cloud-props.md Example of a manual network configuration matching any name with defined subnet ranges. ```yaml networks: - name: private type: manual subnets: - range: 192.168.50.0/24 gateway: 192.168.50.1 dns: [192.168.50.1] ``` -------------------------------- ### Define VM Types Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/docs/cloud-props.md Example configuration for a VM type specifying CPU, memory, disk, and hardware virtualization properties. ```yaml vm_types: - name: default cloud_properties: cpus: 2 memory: 2_048 ephemeral_disk: 4_096 paravirtprovider: kvm audio: alsa ``` -------------------------------- ### Define Availability Zones Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/docs/cloud-props.md Example configuration for defining an availability zone in the BOSH manifest. ```yaml azs: - name: z1 ``` -------------------------------- ### BOSH Manifest Network Configuration Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/docs/networks-nat-network.md Examples for defining NAT network settings in a BOSH manifest for dynamic and manual IP allocation. ```yaml networks: - name: outbound type: dynamic dns: ["8.8.8.8"] # use public DNS cloud_properties: name: mynatnet # Network Name from configuration dialog type: natnetwork ``` ```yaml networks: - name: network-in-nat-network-mode subnets: - range: 10.0.13.0/24 # Network CIDR from configuration dialog gateway: 10.0.13.1 # has to end with .1 dns: ["8.8.8.8"] # use public DNS static: - 10.0.2.4 cloud_properties: name: mynatnet # Network Name from configuration dialog type: natnetwork ``` -------------------------------- ### Example BOSH Manifest Network Configuration in NAT Mode Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/docs/networks-nat.md Use this configuration in your BOSH manifest for VMs requiring internet access via NAT. Ensure the subnet range, gateway, and DNS IPs adhere to the specified format (10.0.x.0/24, .2 for gateway, .3 for DNS). ```yaml networks: - name: network-in-nat-mode subnets: - range: 10.0.2.0/24 # has to be 10.0.x.0/24 gateway: 10.0.2.2 # has to end with .2 dns: ["10.0.2.3"] # has to end with .3 static: - 10.0.2.4 cloud_properties: type: nat ``` -------------------------------- ### Configure NAT Network via Command Line Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/docs/networks-nat-network.md Use VBoxManage to create and verify a NAT network named NatNetwork. ```bash $ VBoxManage natnetwork add --netname NatNetwork --network 10.0.2.0/24 --dhcp on $ VBoxManage list natnetworks ``` -------------------------------- ### Bootstrap Ginkgo Test Suite Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/README.md Commands to set up a new Ginkgo test suite in your package. After bootstrapping and generating a sample file, you can add your tests and run them using 'go test', 'ginkgo bootstrap', or 'ginkgo generate'. ```bash cd path/to/package/you/want/to/test ginkgo bootstrap # set up a new ginkgo suite ginkgo generate # will create a sample test file. edit this file and add your tests then... go test # to run your tests ginkgo # also runs your tests ``` -------------------------------- ### Tail a file in Go Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/nxadm/tail/README.md Initializes a tail process on a specified file and iterates over incoming lines. Requires the tail package and appropriate file permissions. ```Go // Create a tail t, err := tail.TailFile( "/var/log/nginx.log", tail.Config{Follow: true, ReOpen: true}) if err != nil { panic(err) } // Print the text of each received line for line := range t.Lines { fmt.Println(line.Text) } ``` -------------------------------- ### BOSH Deployment Integration Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Commands to create a BOSH release and deploy a director on VirtualBox. ```bash # Create BOSH release tarball bosh create-release --force --tarball /tmp/vbox-cpi-release # Deploy BOSH director bosh create-env bosh-deployment/bosh.yml \ --state state.json \ --vars-store creds.yml \ -o bosh-deployment/virtualbox/cpi.yml \ -o bosh-deployment/virtualbox/outbound-network.yml \ -o bosh-deployment/bosh-lite.yml \ -o bosh-deployment/jumpbox-user.yml \ -v director_name=vbox \ -v internal_ip=192.168.50.6 \ -v internal_gw=192.168.50.1 \ -v internal_cidr=192.168.50.0/24 \ -v network_name=vboxnet0 \ -v outbound_network_name=NatNetwork ``` -------------------------------- ### Monitor file system events Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/fsnotify/fsnotify/README.md Basic implementation for creating a watcher, handling events, and monitoring a specific file path. ```go package main import ( "log" "github.com/fsnotify/fsnotify" ) func main() { watcher, err := fsnotify.NewWatcher() if err != nil { log.Fatal(err) } defer watcher.Close() done := make(chan bool) go func() { for { select { case event, ok := <-watcher.Events: if !ok { return } log.Println("event:", event) if event.Op&fsnotify.Write == fsnotify.Write { log.Println("modified file:", event.Name) } case err, ok := <-watcher.Errors: if !ok { return } log.Println("error:", err) } } }() err = watcher.Add("/tmp/foo") if err != nil { log.Fatal(err) } <-done } ``` -------------------------------- ### Create GitHub Release Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/RELEASING.md Create a new release on GitHub using the GitHub CLI. ```bash gh release create "vM.m.p" ``` -------------------------------- ### Abstracting the os package Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md Information on how to abstract the 'os' package for testing and interoperability using GlobOS and PathMatchOS. ```APIDOC ## Abstracting the `os` package **doublestar** by default uses the `Open`, `Stat`, and `Lstat`, functions and `PathSeparator` value from the standard library's `os` package. To abstract this, for example to be able to perform tests of Windows paths on Linux, or to interoperate with your own filesystem code, it includes the functions `GlobOS` and `PathMatchOS` which are identical to `Glob` and `PathMatch` except that they operate on an `OS` interface: ```go type OS interface { Lstat(name string) (os.FileInfo, error) Open(name string) (*os.File, error) PathSeparator() rune Stat(name string) (os.FileInfo, error) } ``` `StandardOS` is a value that implements this interface by calling functions in the standard library's `os` package. ``` -------------------------------- ### Define Syscall Assembly Entry Points Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/golang.org/x/sys/unix/README.md Assembly entry points for system call dispatch, implemented per GOOS/GOARCH pair. ```go func Syscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2, err uintptr) func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2, err uintptr) ``` -------------------------------- ### Check Network Interface Configuration Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/docs/networks-host-only.md After configuring the host-only network, use this command to verify the network interface details, including its IP address, netmask, and broadcast address. Ensure 'vboxnet0' has the expected IP configuration. ```bash $ ifconfig _...other entries..._ vboxnet0: flags=8843 mtu 1500 ether 0a:00:27:00:00:00 inet 192.168.50.1 netmask 0xffffff00 broadcast 192.168.50.255 ``` -------------------------------- ### VM State Operations Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Methods for checking existence, rebooting, and querying the state of a VM. ```go // HasVM checks if a VM exists func (a VMs) HasVM(cid apiv1.VMCID) (bool, error) // RebootVM restarts a VM func (a VMs) RebootVM(cid apiv1.VMCID) error // State returns the current VM state (running, poweroff, missing, inaccessible) func (vm VMImpl) State() (string, error) ``` -------------------------------- ### Create Disk Operation Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Creates a new persistent disk with a specified size in megabytes. ```go // CreateDisk creates a new persistent disk func (a Disks) CreateDisk(size int, _ apiv1.DiskCloudProps, _ *apiv1.VMCID) (apiv1.DiskCID, error) // Internally executes: // VBoxManage createhd --filename /disk.vmdk --size --format VMDK --variant Standard ``` -------------------------------- ### Configure Bridged Networking Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Commands and configuration for exposing VMs directly on the local network. ```bash # List available bridged interfaces VBoxManage list bridgedifs ``` ```yaml # Variables file internal_ip: 192.168.43.252 internal_gw: 192.168.43.3 internal_cidr: 192.168.43.0/24 network_device: "en0: Wi-Fi (Wireless)" ``` ```yaml # Ops file for bridged network - type: replace path: /networks/name=default/subnets/0/cloud_properties? value: type: bridged name: ((network_device)) ``` ```bash # Add route for container network sudo ip route add 10.244.0.0/16 via 192.168.43.252 dev en0 ``` -------------------------------- ### Configure Host-Only Networking Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Commands and configuration for setting up private VM-to-VM communication. ```bash # Create host-only network VBoxManage hostonlyif create VBoxManage hostonlyif ipconfig vboxnet0 --ip 192.168.50.1 --netmask 255.255.255.0 # Verify configuration VBoxManage list hostonlyifs ``` ```yaml networks: - name: private type: manual subnets: - range: 192.168.50.0/24 gateway: 192.168.50.1 dns: [192.168.50.1] static: - 192.168.50.4 cloud_properties: name: vboxnet0 type: hostonly ``` -------------------------------- ### Fetch Tags from Origin Master Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/RELEASING.md Fetch all tags from the origin master branch after creating a release. ```bash git fetch --tags origin master ``` -------------------------------- ### Configure VirtualBox CPI Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt JSON configuration file for setting connection parameters, storage paths, and agent options. ```json { "Host": "192.168.50.1", "Username": "ubuntu", "PrivateKey": "-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----", "BinPath": "VBoxManage", "StoreDir": "~/.bosh_virtualbox_cpi", "StorageController": "sata", "AutoEnableNetworks": true, "Agent": { "NTP": ["0.pool.ntp.org", "1.pool.ntp.org"], "mbus": "nats://nats:nats-password@192.168.50.4:4222" } } ``` -------------------------------- ### Configure logrus with go-colorable Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-colorable/README.md Use NewColorableStdout to enable ANSI color support for logrus output on Windows. ```go logrus.SetFormatter(&logrus.TextFormatter{ForceColors: true}) logrus.SetOutput(colorable.NewColorableStdout()) logrus.Info("succeeded") logrus.Warn("not correct") logrus.Error("something error") logrus.Fatal("panic") ``` -------------------------------- ### List Host-Only Network Interfaces Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/docs/networks-host-only.md Use this command to list all host-only network interfaces configured on your VirtualBox host. This helps in identifying the interface name, such as 'vboxnet0'. ```bash $ VBoxManage list hostonlyifs ``` -------------------------------- ### Go Module for Tools Package Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/README.md Defines a tools.go file to manage development dependencies like Ginkgo within a Go module. This allows for reproducible versions of development tools. ```go // +build tools package tools import ( _ "github.com/onsi/ginkgo/ginkgo" ) // This file imports packages that are used when running go generate, or used // during the development process but not otherwise depended on by built code. ``` -------------------------------- ### PathMatch with Custom OS Interface Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md PathMatchOS enables path matching against a pattern using a provided OS interface. This abstraction is beneficial for testing or when interacting with custom filesystem implementations. ```go func PathMatchOS(os OS, pattern, name string) (bool, error) ``` -------------------------------- ### Attach Disk Operation Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Attaches a persistent disk to a VM, with an optional V2 method that returns a disk hint. ```go // AttachDisk attaches a disk to a VM func (a Disks) AttachDisk(vmCID apiv1.VMCID, diskCID apiv1.DiskCID) error // AttachDiskV2 returns disk hint after attaching func (a Disks) AttachDiskV2(vmCID apiv1.VMCID, diskCID apiv1.DiskCID) (apiv1.DiskHint, error) ``` -------------------------------- ### Create Git Commit and Push Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/RELEASING.md Commit the version update and push changes to the remote repository. ```bash git commit -m "vM.m.p" git push ``` -------------------------------- ### Define VM Cloud Properties Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt YAML configuration for defining VM resource allocation and VirtualBox-specific settings. ```yaml vm_types: - name: default cloud_properties: cpus: 2 memory: 2048 ephemeral_disk: 4096 firmware: efi64 paravirtprovider: kvm audio: none - name: large cloud_properties: cpus: 4 memory: 8192 ephemeral_disk: 20480 paravirtprovider: default gui: false shared_folders: - host_path: "/Users/dev/shared" ``` -------------------------------- ### OS Interface Definition Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md The OS interface defines the methods required by doublestar for filesystem operations, including Lstat, Open, PathSeparator, and Stat. This allows for dependency injection and testing with mock file systems. ```go type OS interface { Lstat(name string) (os.FileInfo, error) Open(name string) (*os.File, error) PathSeparator() rune Stat(name string) (os.FileInfo, error) } ``` -------------------------------- ### VBoxManage Driver Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Executes VBoxManage CLI commands with retry logic and error handling. ```go // Execute runs a VBoxManage command func (d ExecDriver) Execute(args ...string) (string, error) // ExecuteComplex runs with options like ignoring non-zero exit codes func (d ExecDriver) ExecuteComplex(args []string, opts ExecuteOpts) (string, error) // Example VBoxManage commands executed by the CPI: // VBoxManage clonevm --snapshot prepared-clone --options link --name --register // VBoxManage modifyvm --memory 2048 --cpus 2 --firmware efi64 // VBoxManage startvm --type headless // VBoxManage controlvm poweroff // VBoxManage showvminfo --machinereadable ``` -------------------------------- ### Add Static Route for Container Network Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/docs/networks-bridged.md Configure a static route on your host machine to direct traffic for the container network (10.244.0.0/16) through the BOSH Director's static IP. ```bash sudo ip route add 10.244.0.0/16 via 192.168.43.252 dev en0 ``` -------------------------------- ### Unmarshal and Marshal YAML in Go Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/gopkg.in/yaml.v2/README.md Demonstrates unmarshalling YAML data into a struct or map, and marshalling them back into YAML format. Struct fields must be exported for successful unmarshalling. ```go package main import ( "fmt" "log" "gopkg.in/yaml.v2" ) var data = ` a: Easy! b: c: 2 d: [3, 4] ` // Note: struct fields must be public in order for unmarshal to // correctly populate the data. type T struct { A string B struct { RenamedC int `yaml:"c"` D []int `yaml:",flow"` } } func main() { t := T{} err := yaml.Unmarshal([]byte(data), &t) if err != nil { log.Fatalf("error: %v", err) } fmt.Printf("--- t:\n%v\n\n", t) d, err := yaml.Marshal(&t) if err != nil { log.Fatalf("error: %v", err) } fmt.Printf("--- t dump:\n%s\n\n", string(d)) m := make(map[interface{}]interface{}) err = yaml.Unmarshal([]byte(data), &m) if err != nil { log.Fatalf("error: %v", err) } fmt.Printf("--- m:\n%v\n\n", m) d, err = yaml.Marshal(&m) if err != nil { log.Fatalf("error: %v", err) } fmt.Printf("--- m dump:\n%s\n\n", string(d)) } ``` -------------------------------- ### Create Stemcell Operation Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Imports a stemcell from an image path and provides information on supported formats. ```go // CreateStemcell imports a stemcell from an image path func (a Stemcells) CreateStemcell(imagePath string, _ apiv1.StemcellCloudProps) (apiv1.StemcellCID, error) // Supported stemcell formats func (m Misc) Info() (apiv1.Info, error) { return apiv1.Info{ StemcellFormats: []string{"general-ovf", "vsphere-ovf"}, }, nil } ``` -------------------------------- ### SSH Remote Execution Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Configuration for connecting to a remote VirtualBox host via SSH. ```go type SSHRunnerOpts struct { Host string // Remote host address Username string // SSH username PrivateKey string // SSH private key content } // Configuration for remote VirtualBox { "Host": "192.168.50.1", "Username": "ubuntu", "PrivateKey": "-----BEGIN RSA PRIVATE KEY-----\n...", "BinPath": "/usr/bin/VBoxManage", "StoreDir": "/home/ubuntu/.bosh_virtualbox_cpi" } ``` -------------------------------- ### Match String Against Pattern Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md The Match function checks if a given name string conforms to a specified pattern. It uses '/' as the path separator, making it suitable for Unix-like systems or when a consistent separator is desired. This function is intended as a replacement for 'path.Match'. ```go func Match(pattern, name string) (bool, error) ``` -------------------------------- ### Glob Filesystem Paths Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md The Glob function finds all files and directories in the filesystem that match the provided pattern. It can work with relative or absolute paths and serves as a replacement for 'filepath.Glob'. ```go func Glob(pattern string) ([]string, error) ``` -------------------------------- ### Import doublestar Package in Go Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md Import the doublestar package into your Go project to use its path matching functionalities. This is required before calling any of its functions. ```go import "github.com/bmatcuk/doublestar" ``` -------------------------------- ### Glob Filesystem Paths with Custom OS Interface Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md GlobOS allows globbing using a custom OS interface, enabling testing with different filesystem implementations or simulating specific environments. This is useful for integration testing or working with non-standard file access. ```go func GlobOS(os OS, pattern string) ([]string, error) ``` -------------------------------- ### PathMatch Function Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md The PathMatch function is similar to Match but uses the system's path separator, making it a replacement for filepath.Match(). ```APIDOC ## PathMatch Function ### Description PathMatch returns true if `name` matches the file name `pattern`. The difference between Match and PathMatch is that PathMatch will automatically use your system's path separator to split `name` and `pattern`. ### Method `func PathMatch(pattern, name string) (bool, error)` ### Parameters #### Path Parameters - **pattern** (string) - Required - The pattern to match against. - **name** (string) - Required - The name to check. ### Response #### Success Response (bool) - `true` if the name matches the pattern, `false` otherwise. #### Error Response (error) - An error if the pattern is invalid. ``` -------------------------------- ### BOSH Director Ops File for Bridged Network Type Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/docs/networks-bridged.md Add this ops file to your `bosh create-env` command to specify the network type as 'bridged' and use the configured network device. ```yaml - type: replace path: /networks/name=default/subnets/0/cloud_properties? value: type: bridged name: ((network_device)) ``` -------------------------------- ### Ginkgo Pull Request Workflow Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/CONTRIBUTING.md Standard git commands for creating a feature branch and pushing changes for a pull request. ```bash git checkout -b my-feature git push fork ``` -------------------------------- ### VM Operations Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Operations for managing the lifecycle and state of VirtualBox virtual machines. ```APIDOC ## Delete VM ### Description Halts a VM, detaches persistent disks, and unregisters it from VirtualBox. ### Method DELETE ### Parameters #### Path Parameters - **cid** (VMCID) - Required - The unique identifier of the VM to delete. ``` ```APIDOC ## VM State Operations ### Description Operations to check existence, reboot, or query the state of a VM. ### Methods - **HasVM**: Checks if a VM exists. - **RebootVM**: Restarts a VM. - **State**: Returns the current VM state (running, poweroff, missing, inaccessible). ``` -------------------------------- ### Generate Git Log for Changelog Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/RELEASING.md Use this command to list commits since the last release for updating the CHANGELOG.md file. ```bash git log --pretty=format:'- %s [%h]' HEAD...vX.X.X ``` -------------------------------- ### Disk Operations Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Operations for creating, attaching, detaching, and deleting persistent disks. ```APIDOC ## Create Disk ### Description Creates a new persistent disk with a specified size in megabytes. ### Parameters - **size** (int) - Required - Size of the disk in MB. - **_** (DiskCloudProps) - Optional - Cloud properties. - **_** (VMCID) - Optional - Associated VM ID. ``` ```APIDOC ## Attach/Detach Disk ### Description Attaches or detaches a persistent disk to/from a VM. ### Methods - **AttachDisk**: Attaches a disk to a VM. - **AttachDiskV2**: Attaches a disk and returns a disk hint. - **DetachDisk**: Removes a disk from a VM. - **GetDisks**: Returns all persistent disk IDs attached to a VM. ``` -------------------------------- ### Configure NAT Network Mode Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Commands and configuration for NAT Network mode, allowing internet access and inter-VM communication. ```bash # Create NAT Network VBoxManage natnetwork add --netname NatNetwork --network 10.0.2.0/24 --dhcp on # List configured NAT networks VBoxManage list natnetworks ``` ```yaml networks: - name: outbound type: dynamic dns: ["8.8.8.8"] cloud_properties: name: NatNetwork type: natnetwork # Manual mode with static IPs - name: network-in-nat-network-mode subnets: - range: 10.0.13.0/24 gateway: 10.0.13.1 dns: ["8.8.8.8"] static: - 10.0.13.4 cloud_properties: name: mynatnet type: natnetwork ``` -------------------------------- ### Configure Availability Zones Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt YAML definition for BOSH availability zones. ```yaml azs: - name: z1 - name: z2 - name: z3 ``` -------------------------------- ### Check Terminal Status in Go Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/onsi/ginkgo/reporters/stenographer/support/go-isatty/README.md Use this to determine if a file descriptor is a terminal. Requires the github.com/mattn/go-isatty package. ```go package main import ( "fmt" "github.com/mattn/go-isatty" "os" ) func main() { if isatty.IsTerminal(os.Stdout.Fd()) { fmt.Println("Is Terminal") } else { fmt.Println("Is Not Terminal") } } ``` -------------------------------- ### Match Function Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md The Match function checks if a given name matches a pattern. It uses '/' as the path separator and is intended as a replacement for path.Match(). ```APIDOC ## Match Function ### Description Match returns true if `name` matches the file name `pattern`. `name` and `pattern` are split on forward slash (`/`) characters and may be relative or absolute. ### Method `func Match(pattern, name string) (bool, error)` ### Parameters #### Path Parameters - **pattern** (string) - Required - The pattern to match against. - **name** (string) - Required - The name to check. ### Response #### Success Response (bool) - `true` if the name matches the pattern, `false` otherwise. #### Error Response (error) - An error if the pattern is invalid. ``` -------------------------------- ### PathMatch String Against Pattern Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md PathMatch determines if a name string matches a pattern, automatically using the system's path separator. This makes it a platform-aware replacement for 'filepath.Match', suitable for cross-platform compatibility. ```go func PathMatch(pattern, name string) (bool, error) ``` -------------------------------- ### Configure NAT Mode Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt YAML configuration for individual VM NAT mode without inter-VM communication. ```yaml networks: - name: network-in-nat-mode subnets: - range: 10.0.2.0/24 # Must be 10.0.x.0/24 gateway: 10.0.2.2 # Must end with .2 dns: ["10.0.2.3"] # Must end with .3 static: - 10.0.2.4 cloud_properties: type: nat ``` -------------------------------- ### Pattern Syntax Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md Details the special terms and character classes supported in doublestar patterns. ```APIDOC ## Patterns **doublestar** supports the following special terms in the patterns: Special Terms | Meaning ------------- | ------- `*` | matches any sequence of non-path-separators `**` | matches any sequence of characters, including path separators `?` | matches any single non-path-separator character `[class]` | matches any single non-path-separator character against a class of characters ([see below](#character-classes)) `{alt1,...}` | matches a sequence of characters if one of the comma-separated alternatives matches Any character with a special meaning can be escaped with a backslash (`\`). ### Character Classes Character classes support the following: Class | Meaning ---------- | ------- `[abc]` | matches any single character within the set `[a-z]` | matches any single character in the range `[^class]` | matches any single character which does *not* match the class ``` -------------------------------- ### Delete Disk Operation Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Removes a persistent disk and checks for its existence. ```go // DeleteDisk removes a disk completely func (a Disks) DeleteDisk(cid apiv1.DiskCID) error // HasDisk checks if a disk exists func (a Disks) HasDisk(cid apiv1.DiskCID) (bool, error) ``` -------------------------------- ### Delete VM Operation Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Removes a VM and its associated resources from VirtualBox. ```go // DeleteVM removes a VM and its associated resources func (a VMs) DeleteVM(cid apiv1.VMCID) error // Internally executes: // 1. vm.HaltIfRunning() // 2. vm.detachPersistentDisks() // 3. VBoxManage unregistervm --delete // 4. vm.store.Delete() ``` -------------------------------- ### Detach Disk Operation Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Detaches a persistent disk from a VM and retrieves all attached disk IDs. ```go // DetachDisk removes a disk from a VM func (a Disks) DetachDisk(vmCID apiv1.VMCID, diskCID apiv1.DiskCID) error // GetDisks returns all persistent disk IDs attached to a VM func (a VMs) GetDisks(cid apiv1.VMCID) ([]apiv1.DiskCID, error) ``` -------------------------------- ### Glob Function Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/src/bosh-virtualbox-cpi/vendor/github.com/bmatcuk/doublestar/README.md The Glob function finds all files and directories matching a pattern, intended as a replacement for filepath.Glob(). ```APIDOC ## Glob Function ### Description Glob finds all files and directories in the filesystem that match `pattern`. `pattern` may be relative (to the current working directory), or absolute. ### Method `func Glob(pattern string) ([]string, error)` ### Parameters #### Path Parameters - **pattern** (string) - Required - The pattern to search for. ### Response #### Success Response ([]string) - A slice of strings, where each string is a path that matches the pattern. #### Error Response (error) - An error if the pattern is invalid or if there's an issue accessing the filesystem. ``` -------------------------------- ### BOSH Director Network Configuration Variables Source: https://github.com/cloudfoundry/bosh-virtualbox-cpi-release/blob/master/docs/networks-bridged.md Set these variables to configure the BOSH director for bridged networking. The `internal_ip` should be a static IP on your LAN. ```yaml internal_ip: 192.168.43.252 internal_gw: 192.168.43.3 internal_cidr: 192.168.43.0/24 outbound_network_name: NatNetwork network_device: en0 ``` -------------------------------- ### Stemcell Operations Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Operations for importing and removing stemcell images. ```APIDOC ## Create Stemcell ### Description Imports a stemcell from an OVF/OVA image path. ### Parameters - **imagePath** (string) - Required - Path to the stemcell image. - **_** (StemcellCloudProps) - Optional - Cloud properties. ``` ```APIDOC ## Delete Stemcell ### Description Removes a stemcell and its associated VirtualBox VM template. ### Parameters - **cid** (StemcellCID) - Required - The unique identifier of the stemcell. ``` -------------------------------- ### Delete Stemcell Operation Source: https://context7.com/cloudfoundry/bosh-virtualbox-cpi-release/llms.txt Removes a stemcell and its associated VirtualBox template. ```go // DeleteStemcell removes a stemcell func (a Stemcells) DeleteStemcell(cid apiv1.StemcellCID) error // Internally executes: // 1. VBoxManage unregistervm --delete // 2. rm -rf ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.