├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── VERSION ├── ci ├── check-fmt.sh └── run_ci.sh ├── photon ├── .gitignore ├── client │ ├── client.go │ └── client_test.go ├── command │ ├── auth.go │ ├── auth_test.go │ ├── datastores.go │ ├── datastores_test.go │ ├── disks.go │ ├── disks_test.go │ ├── flagparsehelpers.go │ ├── flavors.go │ ├── flavors_test.go │ ├── hosts.go │ ├── hosts_test.go │ ├── images.go │ ├── images_test.go │ ├── infrastructure.go │ ├── infrastructure_test.go │ ├── iohelpers.go │ ├── iohelpers_test.go │ ├── networks.go │ ├── networks_test.go │ ├── project-quota.go │ ├── project-quota_test.go │ ├── projects.go │ ├── projects_test.go │ ├── routers.go │ ├── routers_test.go │ ├── services.go │ ├── services_test.go │ ├── srvcert.go │ ├── srvcert_test.go │ ├── subnets.go │ ├── subnets_test.go │ ├── system.go │ ├── system_test.go │ ├── target.go │ ├── target_test.go │ ├── tasks.go │ ├── tasks_test.go │ ├── tenant-quota.go │ ├── tenant-quota_test.go │ ├── tenants.go │ ├── tenants_test.go │ ├── test_helper.go │ ├── vms.go │ ├── vms_test.go │ ├── zone.go │ └── zone_test.go ├── configuration │ ├── config.go │ ├── config_test.go │ ├── configuration_suite_test.go │ └── testhelpers.go ├── main.go ├── main_test.go ├── manifest │ ├── installation.go │ ├── installation_test.go │ └── manifest_suite_test.go ├── mocks │ ├── mocks.go │ ├── responder.go │ └── transport.go ├── sample_scripts │ ├── host_cli.sh │ ├── image_cli.sh │ └── tenant_cli.sh └── utils │ └── formatting.go ├── testdata ├── TestCA.crt ├── TestKey.pub ├── tty_tiny.ova └── ttylinux-pc_i486-16.1.iso └── vendor ├── github.com ├── onsi │ ├── ginkgo │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── config │ │ │ └── config.go │ │ ├── ginkgo_dsl.go │ │ ├── internal │ │ │ ├── codelocation │ │ │ │ └── code_location.go │ │ │ ├── containernode │ │ │ │ └── container_node.go │ │ │ ├── failer │ │ │ │ └── failer.go │ │ │ ├── leafnodes │ │ │ │ ├── benchmarker.go │ │ │ │ ├── interfaces.go │ │ │ │ ├── it_node.go │ │ │ │ ├── measure_node.go │ │ │ │ ├── runner.go │ │ │ │ ├── setup_nodes.go │ │ │ │ ├── suite_nodes.go │ │ │ │ ├── synchronized_after_suite_node.go │ │ │ │ └── synchronized_before_suite_node.go │ │ │ ├── remote │ │ │ │ ├── aggregator.go │ │ │ │ ├── forwarding_reporter.go │ │ │ │ ├── output_interceptor.go │ │ │ │ ├── output_interceptor_unix.go │ │ │ │ ├── output_interceptor_win.go │ │ │ │ ├── server.go │ │ │ │ ├── syscall_dup_linux_arm64.go │ │ │ │ ├── syscall_dup_solaris.go │ │ │ │ └── syscall_dup_unix.go │ │ │ ├── spec │ │ │ │ ├── index_computer.go │ │ │ │ ├── spec.go │ │ │ │ └── specs.go │ │ │ ├── specrunner │ │ │ │ ├── random_id.go │ │ │ │ └── spec_runner.go │ │ │ ├── suite │ │ │ │ └── suite.go │ │ │ ├── testingtproxy │ │ │ │ └── testing_t_proxy.go │ │ │ └── writer │ │ │ │ ├── fake_writer.go │ │ │ │ └── writer.go │ │ ├── reporters │ │ │ ├── default_reporter.go │ │ │ ├── fake_reporter.go │ │ │ ├── junit_reporter.go │ │ │ ├── reporter.go │ │ │ ├── stenographer │ │ │ │ ├── console_logging.go │ │ │ │ ├── fake_stenographer.go │ │ │ │ └── stenographer.go │ │ │ └── teamcity_reporter.go │ │ └── types │ │ │ ├── code_location.go │ │ │ ├── synchronization.go │ │ │ └── types.go │ └── gomega │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── format │ │ └── format.go │ │ ├── gomega_dsl.go │ │ ├── internal │ │ ├── assertion │ │ │ └── assertion.go │ │ ├── asyncassertion │ │ │ └── async_assertion.go │ │ ├── oraclematcher │ │ │ └── oracle_matcher.go │ │ └── testingtsupport │ │ │ └── testing_t_support.go │ │ ├── matchers.go │ │ ├── matchers │ │ ├── and.go │ │ ├── assignable_to_type_of_matcher.go │ │ ├── be_a_directory.go │ │ ├── be_a_regular_file.go │ │ ├── be_an_existing_file.go │ │ ├── be_closed_matcher.go │ │ ├── be_empty_matcher.go │ │ ├── be_equivalent_to_matcher.go │ │ ├── be_false_matcher.go │ │ ├── be_identical_to.go │ │ ├── be_nil_matcher.go │ │ ├── be_numerically_matcher.go │ │ ├── be_sent_matcher.go │ │ ├── be_temporally_matcher.go │ │ ├── be_true_matcher.go │ │ ├── be_zero_matcher.go │ │ ├── consist_of.go │ │ ├── contain_element_matcher.go │ │ ├── contain_substring_matcher.go │ │ ├── equal_matcher.go │ │ ├── have_cap_matcher.go │ │ ├── have_key_matcher.go │ │ ├── have_key_with_value_matcher.go │ │ ├── have_len_matcher.go │ │ ├── have_occurred_matcher.go │ │ ├── have_prefix_matcher.go │ │ ├── have_suffix_matcher.go │ │ ├── match_error_matcher.go │ │ ├── match_json_matcher.go │ │ ├── match_regexp_matcher.go │ │ ├── match_yaml_matcher.go │ │ ├── not.go │ │ ├── or.go │ │ ├── panic_matcher.go │ │ ├── receive_matcher.go │ │ ├── succeed_matcher.go │ │ ├── support │ │ │ └── goraph │ │ │ │ ├── bipartitegraph │ │ │ │ ├── bipartitegraph.go │ │ │ │ └── bipartitegraphmatching.go │ │ │ │ ├── edge │ │ │ │ └── edge.go │ │ │ │ ├── node │ │ │ │ └── node.go │ │ │ │ └── util │ │ │ │ └── util.go │ │ ├── type_support.go │ │ └── with_transform.go │ │ └── types │ │ └── types.go ├── urfave │ └── cli │ │ ├── CHANGELOG.md │ │ ├── LICENSE │ │ ├── README.md │ │ ├── app.go │ │ ├── appveyor.yml │ │ ├── category.go │ │ ├── cli.go │ │ ├── command.go │ │ ├── context.go │ │ ├── errors.go │ │ ├── flag-types.json │ │ ├── flag.go │ │ ├── flag_generated.go │ │ ├── funcs.go │ │ ├── generate-flag-types │ │ ├── help.go │ │ └── runtests └── vmware │ └── photon-controller-go-sdk │ ├── LICENSE │ ├── SSPI │ ├── LICENSE.txt │ ├── README.md │ ├── sspi.go │ └── sspi_unsupported.go │ └── photon │ ├── apitypes.go │ ├── auth.go │ ├── client.go │ ├── datastores.go │ ├── disks.go │ ├── flavors.go │ ├── hosts.go │ ├── images.go │ ├── info.go │ ├── infrastructure.go │ ├── infrastructure_hosts.go │ ├── lightwave │ ├── jwttoken.go │ ├── oidcclient.go │ ├── oidcclient_sspi.go │ └── oidcclient_sspi_unsupported.go │ ├── projects.go │ ├── restclient.go │ ├── routers.go │ ├── services.go │ ├── subnets.go │ ├── system.go │ ├── tasks.go │ ├── tenants.go │ ├── util.go │ ├── vms.go │ └── zones.go ├── golang.org └── x │ ├── crypto │ ├── LICENSE │ ├── PATENTS │ └── ssh │ │ └── terminal │ │ ├── terminal.go │ │ ├── util.go │ │ ├── util_bsd.go │ │ ├── util_linux.go │ │ └── util_windows.go │ └── sys │ ├── LICENSE │ ├── PATENTS │ └── unix │ ├── asm.s │ ├── asm_darwin_386.s │ ├── asm_darwin_amd64.s │ ├── asm_darwin_arm.s │ ├── asm_darwin_arm64.s │ ├── asm_dragonfly_386.s │ ├── asm_dragonfly_amd64.s │ ├── asm_freebsd_386.s │ ├── asm_freebsd_amd64.s │ ├── asm_freebsd_arm.s │ ├── asm_linux_386.s │ ├── asm_linux_amd64.s │ ├── asm_linux_arm.s │ ├── asm_linux_arm64.s │ ├── asm_linux_ppc64x.s │ ├── asm_netbsd_386.s │ ├── asm_netbsd_amd64.s │ ├── asm_netbsd_arm.s │ ├── asm_openbsd_386.s │ ├── asm_openbsd_amd64.s │ ├── asm_solaris_amd64.s │ ├── constants.go │ ├── env_unix.go │ ├── env_unset.go │ ├── flock.go │ ├── flock_linux_32bit.go │ ├── gccgo.go │ ├── gccgo_c.c │ ├── gccgo_linux_amd64.go │ ├── mkall.sh │ ├── mkerrors.sh │ ├── mksyscall.pl │ ├── mksyscall_solaris.pl │ ├── mksysctl_openbsd.pl │ ├── mksysnum_darwin.pl │ ├── mksysnum_dragonfly.pl │ ├── mksysnum_freebsd.pl │ ├── mksysnum_linux.pl │ ├── mksysnum_netbsd.pl │ ├── mksysnum_openbsd.pl │ ├── race.go │ ├── race0.go │ ├── sockcmsg_linux.go │ ├── sockcmsg_unix.go │ ├── str.go │ ├── syscall.go │ ├── syscall_bsd.go │ ├── syscall_darwin.go │ ├── syscall_darwin_386.go │ ├── syscall_darwin_amd64.go │ ├── syscall_darwin_arm.go │ ├── syscall_darwin_arm64.go │ ├── syscall_dragonfly.go │ ├── syscall_dragonfly_386.go │ ├── syscall_dragonfly_amd64.go │ ├── syscall_freebsd.go │ ├── syscall_freebsd_386.go │ ├── syscall_freebsd_amd64.go │ ├── syscall_freebsd_arm.go │ ├── syscall_linux.go │ ├── syscall_linux_386.go │ ├── syscall_linux_amd64.go │ ├── syscall_linux_arm.go │ ├── syscall_linux_arm64.go │ ├── syscall_linux_ppc64x.go │ ├── syscall_netbsd.go │ ├── syscall_netbsd_386.go │ ├── syscall_netbsd_amd64.go │ ├── syscall_netbsd_arm.go │ ├── syscall_no_getwd.go │ ├── syscall_openbsd.go │ ├── syscall_openbsd_386.go │ ├── syscall_openbsd_amd64.go │ ├── syscall_solaris.go │ ├── syscall_solaris_amd64.go │ ├── syscall_unix.go │ ├── types_darwin.go │ ├── types_dragonfly.go │ ├── types_freebsd.go │ ├── types_linux.go │ ├── types_netbsd.go │ ├── types_openbsd.go │ ├── types_solaris.go │ ├── zerrors_darwin_386.go │ ├── zerrors_darwin_amd64.go │ ├── zerrors_darwin_arm.go │ ├── zerrors_darwin_arm64.go │ ├── zerrors_dragonfly_386.go │ ├── zerrors_dragonfly_amd64.go │ ├── zerrors_freebsd_386.go │ ├── zerrors_freebsd_amd64.go │ ├── zerrors_freebsd_arm.go │ ├── zerrors_linux_386.go │ ├── zerrors_linux_amd64.go │ ├── zerrors_linux_arm.go │ ├── zerrors_linux_arm64.go │ ├── zerrors_linux_ppc64.go │ ├── zerrors_linux_ppc64le.go │ ├── zerrors_netbsd_386.go │ ├── zerrors_netbsd_amd64.go │ ├── zerrors_netbsd_arm.go │ ├── zerrors_openbsd_386.go │ ├── zerrors_openbsd_amd64.go │ ├── zerrors_solaris_amd64.go │ ├── zsyscall_darwin_386.go │ ├── zsyscall_darwin_amd64.go │ ├── zsyscall_darwin_arm.go │ ├── zsyscall_darwin_arm64.go │ ├── zsyscall_dragonfly_386.go │ ├── zsyscall_dragonfly_amd64.go │ ├── zsyscall_freebsd_386.go │ ├── zsyscall_freebsd_amd64.go │ ├── zsyscall_freebsd_arm.go │ ├── zsyscall_linux_386.go │ ├── zsyscall_linux_amd64.go │ ├── zsyscall_linux_arm.go │ ├── zsyscall_linux_arm64.go │ ├── zsyscall_linux_ppc64.go │ ├── zsyscall_linux_ppc64le.go │ ├── zsyscall_netbsd_386.go │ ├── zsyscall_netbsd_amd64.go │ ├── zsyscall_netbsd_arm.go │ ├── zsyscall_openbsd_386.go │ ├── zsyscall_openbsd_amd64.go │ ├── zsyscall_solaris_amd64.go │ ├── zsysctl_openbsd.go │ ├── zsysnum_darwin_386.go │ ├── zsysnum_darwin_amd64.go │ ├── zsysnum_darwin_arm.go │ ├── zsysnum_darwin_arm64.go │ ├── zsysnum_dragonfly_386.go │ ├── zsysnum_dragonfly_amd64.go │ ├── zsysnum_freebsd_386.go │ ├── zsysnum_freebsd_amd64.go │ ├── zsysnum_freebsd_arm.go │ ├── zsysnum_linux_386.go │ ├── zsysnum_linux_amd64.go │ ├── zsysnum_linux_arm.go │ ├── zsysnum_linux_arm64.go │ ├── zsysnum_linux_ppc64.go │ ├── zsysnum_linux_ppc64le.go │ ├── zsysnum_netbsd_386.go │ ├── zsysnum_netbsd_amd64.go │ ├── zsysnum_netbsd_arm.go │ ├── zsysnum_openbsd_386.go │ ├── zsysnum_openbsd_amd64.go │ ├── zsysnum_solaris_amd64.go │ ├── ztypes_darwin_386.go │ ├── ztypes_darwin_amd64.go │ ├── ztypes_darwin_arm.go │ ├── ztypes_darwin_arm64.go │ ├── ztypes_dragonfly_386.go │ ├── ztypes_dragonfly_amd64.go │ ├── ztypes_freebsd_386.go │ ├── ztypes_freebsd_amd64.go │ ├── ztypes_freebsd_arm.go │ ├── ztypes_linux_386.go │ ├── ztypes_linux_amd64.go │ ├── ztypes_linux_arm.go │ ├── ztypes_linux_arm64.go │ ├── ztypes_linux_ppc64.go │ ├── ztypes_linux_ppc64le.go │ ├── ztypes_netbsd_386.go │ ├── ztypes_netbsd_amd64.go │ ├── ztypes_netbsd_arm.go │ ├── ztypes_openbsd_386.go │ ├── ztypes_openbsd_amd64.go │ └── ztypes_solaris_amd64.go ├── gopkg.in └── yaml.v2 │ ├── LICENSE │ ├── LICENSE.libyaml │ ├── README.md │ ├── apic.go │ ├── decode.go │ ├── emitterc.go │ ├── encode.go │ ├── parserc.go │ ├── readerc.go │ ├── resolve.go │ ├── scannerc.go │ ├── sorter.go │ ├── writerc.go │ ├── yaml.go │ ├── yamlh.go │ └── yamlprivateh.go └── vendor.json /.gitignore: -------------------------------------------------------------------------------- 1 | /bin 2 | /pkg 3 | 4 | .idea 5 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Makefile to help building go components 2 | 3 | COMMAND_NAME=photon 4 | VERSION=$(shell cat VERSION) 5 | LDFLAGS="-X main.githash=`git rev-parse --short HEAD` -X main.commandName=$(COMMAND_NAME) -X main.version=$(VERSION)" 6 | GOBUILD=go build -ldflags $(LDFLAGS) 7 | 8 | all: test build binaries 9 | 10 | binaries: darwin/amd64 windows/amd64 linux/amd64 11 | 12 | darwin/amd64: 13 | $(eval export GOOS=darwin) 14 | $(eval export GOARCH=amd64) 15 | $(eval export fileext=) 16 | make build 17 | 18 | windows/amd64: 19 | $(eval export GOOS=windows) 20 | $(eval export GOARCH=amd64) 21 | $(eval export fileext=.exe) 22 | make build 23 | 24 | linux/amd64: 25 | $(eval export GOOS=linux) 26 | $(eval export GOARCH=amd64) 27 | $(eval export fileext=) 28 | make build 29 | 30 | # go build arch is controlled by env var GOOS and GOARCH, when not set it use current machine native arch 31 | build: 32 | $(GOBUILD) -o bin/$(GOOS)$(GOARCH)/$(COMMAND_NAME)$(fileext) ./photon 33 | 34 | # 35 | # get the tools 36 | # 37 | tools: 38 | go get -u github.com/toliaqat/errcheck 39 | go get -u golang.org/x/tools/cmd/goimports 40 | go get -u github.com/golang/lint/golint 41 | go get -u github.com/tools/godep 42 | go get -u github.com/kardianos/govendor 43 | 44 | test: tools 45 | errcheck ./photon/... 46 | go vet `go list ./... | grep -v '/vendor/'` 47 | golint 48 | chmod +x ci/check-fmt.sh 49 | ./ci/check-fmt.sh 50 | go test -v ./... 51 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.3 2 | -------------------------------------------------------------------------------- /ci/check-fmt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # Terminate script on error 4 | set -e 5 | 6 | # Fail if there is any go fmt error. 7 | if [[ -n "$(gofmt -l photon)" ]]; then 8 | echo Fix gofmt errors 9 | gofmt -d photon 10 | exit 1 11 | fi 12 | -------------------------------------------------------------------------------- /ci/run_ci.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | # Terminate script on error 4 | set -e 5 | 6 | export GOPATH=$WORKSPACE 7 | export PATH=$PATH:$WORKSPACE/bin 8 | 9 | # $WORKSPACE will be the root of the git repo that is pulled in by Jenkins. 10 | # We need to move its contents into the expected package path inside 11 | # $GOPATH/src (defined by PACKAGESRC) before we can build. 12 | PACKAGESRC=src/github.com/vmware/photon-controller-cli 13 | 14 | REPOFILES=(*) 15 | mkdir -p $PACKAGESRC 16 | cp -r ${REPOFILES[*]} $PACKAGESRC/ 17 | pushd $PACKAGESRC 18 | 19 | make all 20 | 21 | rm -rf $WORKSPACE/bin 22 | mv bin $WORKSPACE/. 23 | -------------------------------------------------------------------------------- /photon/.gitignore: -------------------------------------------------------------------------------- 1 | /gen 2 | *.test 3 | -------------------------------------------------------------------------------- /photon/command/iohelpers_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package command 11 | 12 | import ( 13 | "regexp" 14 | "testing" 15 | ) 16 | 17 | func TestTimestampToString(t *testing.T) { 18 | 19 | timeString := timestampToString(-1) 20 | if timeString != "-" { 21 | t.Error("timestampToString didn't return '-'") 22 | } 23 | timeString = timestampToString(0) 24 | if timeString != "-" { 25 | t.Error("timestampToString didn't return '-'") 26 | } 27 | timeString = timestampToString(1) 28 | matched, err := regexp.MatchString(`^[\d]+-[\d]+-[\d]+ [\d]+:[\d]+:[\d]+\.[\d]+$`, timeString) 29 | if !matched || err != nil { 30 | t.Error("timestampToString didn't return a timestamp") 31 | //("2006-01-02 03:04:05.00") 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /photon/command/networks.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package command 11 | 12 | import ( 13 | "errors" 14 | 15 | "github.com/vmware/photon-controller-cli/photon/client" 16 | 17 | "github.com/urfave/cli" 18 | ) 19 | 20 | const ( 21 | PHYSICAL = "PHYSICAL" 22 | SOFTWARE_DEFINED = "SOFTWARE_DEFINED" 23 | NOT_AVAILABLE = "NOT_AVAILABLE" 24 | ) 25 | 26 | func isSoftwareDefinedNetwork(c *cli.Context) (sdnEnabled bool, err error) { 27 | client.Photonclient, err = client.GetClient(c) 28 | if err != nil { 29 | return 30 | } 31 | 32 | info, err := client.Photonclient.Info.Get() 33 | if err != nil { 34 | return 35 | } 36 | 37 | if info.NetworkType == NOT_AVAILABLE { 38 | err = errors.New("Network type is missing") 39 | } else { 40 | sdnEnabled = (info.NetworkType == SOFTWARE_DEFINED) 41 | } 42 | return 43 | } 44 | -------------------------------------------------------------------------------- /photon/command/srvcert.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package command 11 | 12 | import ( 13 | "crypto/tls" 14 | "crypto/x509" 15 | "fmt" 16 | 17 | cf "github.com/vmware/photon-controller-cli/photon/configuration" 18 | ) 19 | 20 | func isServerTrusted(server string) (bool, error) { 21 | bServerTrusted := false 22 | 23 | roots, err := cf.GetCertsFromLocalStore() 24 | 25 | if err != nil { 26 | return bServerTrusted, err 27 | } 28 | 29 | //Try connecting securely to the server 30 | config := tls.Config{RootCAs: roots, InsecureSkipVerify: false} 31 | conn, err := tls.Dial("tcp", server, &config) 32 | 33 | if err == nil { 34 | bServerTrusted = true 35 | _ = conn.Close() 36 | } else { 37 | switch err.(type) { 38 | case x509.UnknownAuthorityError: 39 | bServerTrusted = false 40 | err = nil 41 | } 42 | } 43 | 44 | return bServerTrusted, err 45 | } 46 | 47 | func getServerCert(server string) (*x509.Certificate, error) { 48 | config := tls.Config{InsecureSkipVerify: true} 49 | conn, err := tls.Dial("tcp", server, &config) 50 | 51 | //Ensure we can connect to the server 52 | if err == nil { 53 | cert := new(x509.Certificate) 54 | state := conn.ConnectionState() 55 | //return 1st in the cert list (leaf cert) 56 | if state.PeerCertificates != nil { 57 | cert = state.PeerCertificates[0] 58 | } 59 | _ = conn.Close() 60 | return cert, nil 61 | } 62 | fmt.Println(err) 63 | return nil, err 64 | } 65 | -------------------------------------------------------------------------------- /photon/command/test_helper.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package command 11 | 12 | // The root Url specifies the API version. It is used by the CLI tests. 13 | const rootUrl string = "/v1" 14 | -------------------------------------------------------------------------------- /photon/configuration/configuration_suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package configuration_test 11 | 12 | import ( 13 | . "github.com/onsi/ginkgo" 14 | . "github.com/onsi/gomega" 15 | 16 | "testing" 17 | ) 18 | 19 | func TestConfiguration(t *testing.T) { 20 | RegisterFailHandler(Fail) 21 | RunSpecs(t, "Configuration Suite") 22 | } 23 | -------------------------------------------------------------------------------- /photon/configuration/testhelpers.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package configuration 11 | 12 | import ( 13 | "os" 14 | ) 15 | 16 | func RemoveConfigFile() error { 17 | filepath, err := getConfigurationFilePath() 18 | if err != nil { 19 | return err 20 | } 21 | 22 | if isFileExist(filepath) { 23 | err = os.Remove(filepath) 24 | if err != nil { 25 | return err 26 | } 27 | } 28 | 29 | return nil 30 | } 31 | 32 | func ChangeConfigFileContents(content string) error { 33 | filepath, err := getConfigurationFilePath() 34 | if err != nil { 35 | return err 36 | } 37 | 38 | file, err := os.Create(filepath) 39 | if err != nil { 40 | return err 41 | } 42 | 43 | _, err = file.WriteString(content) 44 | if err != nil { 45 | return err 46 | } 47 | 48 | err = file.Sync() 49 | if err != nil { 50 | return err 51 | } 52 | 53 | return nil 54 | } 55 | -------------------------------------------------------------------------------- /photon/main.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package main 11 | 12 | import ( 13 | "fmt" 14 | "os" 15 | 16 | "github.com/urfave/cli" 17 | "github.com/vmware/photon-controller-cli/photon/client" 18 | "github.com/vmware/photon-controller-cli/photon/command" 19 | "github.com/vmware/photon-controller-cli/photon/utils" 20 | ) 21 | 22 | var commandName = "" 23 | var githash = "" 24 | var version = "" 25 | 26 | func main() { 27 | app := BuildApp() 28 | err := app.Run(os.Args) 29 | if err != nil { 30 | fmt.Println(err.Error()) 31 | os.Exit(1) 32 | } 33 | } 34 | 35 | func BuildApp() *cli.App { 36 | app := cli.NewApp() 37 | app.Name = commandName 38 | app.Usage = "Command line interface for Photon Controller" 39 | app.Version = version + " (Git commit hash: " + githash + ")" 40 | app.Flags = []cli.Flag{ 41 | cli.BoolFlag{ 42 | Name: "non-interactive, n", 43 | Usage: "trigger for non-interactive mode (scripting)", 44 | }, 45 | cli.StringFlag{ 46 | Name: "log-file, l", 47 | Usage: "write logging information into a logfile at the specified path", 48 | }, 49 | cli.StringFlag{ 50 | Name: "output, o", 51 | Usage: "select output format", 52 | }, 53 | cli.BoolFlag{ 54 | Name: "detail, d", 55 | Usage: "print the current target, user, tenant and project", 56 | }, 57 | } 58 | app.Commands = []cli.Command{ 59 | command.GetAuthCommand(), 60 | command.GetSystemCommand(), 61 | command.GetTargetCommand(), 62 | command.GetTenantsCommand(), 63 | command.GetHostsCommand(), 64 | command.GetDatastoresCommand(), 65 | command.GetImagesCommand(), 66 | command.GetTasksCommand(), 67 | command.GetFlavorsCommand(), 68 | command.GetProjectsCommand(), 69 | command.GetDiskCommand(), 70 | command.GetVMCommand(), 71 | command.GetServiceCommand(), 72 | command.GetRoutersCommand(), 73 | command.GetSubnetsCommand(), 74 | command.GetZonesCommand(), 75 | command.GetInfrastructureCommand(), 76 | } 77 | app.Before = func(c *cli.Context) error { 78 | logFile := c.GlobalString("log-file") 79 | if logFile != "" { 80 | return client.InitializeLogging(logFile) 81 | } 82 | return utils.ValidateArgs(c) 83 | } 84 | app.After = func(c *cli.Context) error { 85 | logFile := c.GlobalString("log-file") 86 | if logFile != "" { 87 | return client.CleanupLogging() 88 | } 89 | return nil 90 | } 91 | return app 92 | } 93 | -------------------------------------------------------------------------------- /photon/manifest/manifest_suite_test.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package manifest_test 11 | 12 | import ( 13 | . "github.com/onsi/ginkgo" 14 | . "github.com/onsi/gomega" 15 | 16 | "testing" 17 | ) 18 | 19 | func TestManifest(t *testing.T) { 20 | RegisterFailHandler(Fail) 21 | RunSpecs(t, "Manifest Suite") 22 | } 23 | -------------------------------------------------------------------------------- /photon/mocks/mocks.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package mocks 11 | 12 | import ( 13 | "fmt" 14 | "net/http" 15 | "net/http/httptest" 16 | ) 17 | 18 | // Start a new Server with status OK, caller should call Close when finished 19 | func NewTestServer() (server *httptest.Server) { 20 | return NewTestServerWithBody("") 21 | } 22 | 23 | func NewTestServerWithBody(body string) (server *httptest.Server) { 24 | statusCode := 200 25 | server = httptest.NewServer( 26 | http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 27 | w.WriteHeader(statusCode) 28 | w.Header().Set("Content-Type", "application/json") 29 | fmt.Fprintln(w, body) 30 | })) 31 | return 32 | } 33 | -------------------------------------------------------------------------------- /photon/mocks/responder.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package mocks 11 | 12 | import ( 13 | "bytes" 14 | "io/ioutil" 15 | "net/http" 16 | ) 17 | 18 | // Responders are callbacks that receive http request and return a mocked response. 19 | type Responder func(*http.Request) (*http.Response, error) 20 | 21 | // Create a responder with protocol version "HTTP/1.0" and a mocked response in JSON 22 | func CreateResponder(status int, response string) Responder { 23 | return Responder(func(req *http.Request) (*http.Response, error) { 24 | resp := &http.Response{ 25 | StatusCode: status, 26 | ProtoMajor: 1, 27 | ProtoMinor: 0, 28 | Body: ioutil.NopCloser(bytes.NewBufferString(response)), 29 | ContentLength: int64(len(response)), 30 | Request: req, 31 | } 32 | 33 | resp.Header = make(map[string][]string) 34 | resp.Header.Add("Content-Type", "application/json") 35 | 36 | return resp, nil 37 | }) 38 | } 39 | 40 | // Add a responder to `DefaultMockTransport`. 41 | func RegisterResponder(method, url string, responder Responder) { 42 | DefaultMockTransport.RegisterResponder(method, url, responder) 43 | } 44 | 45 | // Add a new responder, associated with a given HTTP method and URL. 46 | // When a request matches, the responder will be called and the response returned. 47 | func (m *MockTransport) RegisterResponder(method, url string, responder Responder) { 48 | if m.responders == nil { 49 | m.responders = make(map[string]Responder) 50 | } 51 | m.responders[method+" "+url] = responder 52 | } 53 | -------------------------------------------------------------------------------- /photon/mocks/transport.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package mocks 11 | 12 | import ( 13 | "errors" 14 | "net/http" 15 | ) 16 | 17 | // MockTransport implements http.RoundTripper. 18 | // The implementation doesn't make the call, instead defering to the registered list of responders. 19 | // Return Error if no responder is found when FailNoResponder = true 20 | type MockTransport struct { 21 | FailNoResponder bool 22 | responders map[string]Responder 23 | } 24 | 25 | // The global default RoundTripper for all http requests. 26 | var DefaultMockTransport = &MockTransport{} 27 | 28 | // RoundTrip is required to implement http.MockTransport. 29 | func (m *MockTransport) RoundTrip(req *http.Request) (*http.Response, error) { 30 | key := req.Method + " " + req.URL.String() 31 | 32 | // scan through the responders and find one that matches our key 33 | for k, r := range m.responders { 34 | if k != key { 35 | continue 36 | } 37 | return r(req) 38 | } 39 | 40 | if m.FailNoResponder { 41 | return nil, errors.New("no responder found") 42 | } 43 | 44 | // fallback to the default roundtripper 45 | return http.DefaultTransport.RoundTrip(req) 46 | } 47 | 48 | // Activate replaces the `Transport` on the `http.DefaultClient` with our `DefaultMockTransport`. 49 | func Activate(failNoResponder bool) { 50 | DefaultMockTransport.FailNoResponder = failNoResponder 51 | http.DefaultClient.Transport = DefaultMockTransport 52 | } 53 | 54 | // Deactivate replaces our `DefaultMockTransport` with the `http.DefaultTransport`. 55 | func Deactivate() { 56 | http.DefaultClient.Transport = http.DefaultTransport 57 | } 58 | -------------------------------------------------------------------------------- /photon/sample_scripts/image_cli.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | # Get path of executable binary file 6 | path=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 7 | cli="$path/../../../bin/esxcloud-cli" 8 | 9 | # Set target with hardcoded endpoint 10 | $cli -n target set "http://localhost:9080" 11 | 12 | # Save initial list of images 13 | initialImages=$($cli -n image list | awk '{print $1}') 14 | 15 | # Create a new image 16 | echo "Creating test image" 17 | id=$($cli -n image upload "../../testdata/tty_tiny.ova" -n "testname" -i "EAGER" | awk '{if (NR != 1) {print $1}}') 18 | 19 | # Retrieve image create state 20 | state=$($cli -n image show $id | awk '{if (NR != 1) {print $3}}') 21 | 22 | # Verify image state is ready 23 | if [ $state != "READY" ] 24 | then 25 | echo "Error: image created not ready" 26 | exit 1 27 | fi 28 | 29 | # Delete image by id 30 | echo "Deleting test image" 31 | $cli -n image delete $id > /dev/null 32 | 33 | # Verify images was deleted 34 | output=$($cli -n tenant list | awk '{if (NR!=1) {print $2}}') 35 | for line in $output 36 | do 37 | if [[ ${initialImages[*]} =~ $line ]] 38 | then 39 | echo "Error: Image $id should be deleted" 40 | exit 1 41 | fi 42 | done 43 | -------------------------------------------------------------------------------- /photon/sample_scripts/tenant_cli.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | path=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 6 | cli="$path/../../../bin/esxcloud-cli" 7 | 8 | # Store initial list of tenants 9 | initialTenants=$($cli -n tenant list | awk '{print $2}') 10 | 11 | # Create many tenants named by a letter in the alphabet 12 | for name in {a..z} 13 | do 14 | $cli -n tenant create $name 15 | done 16 | 17 | # Retrieve an id and check for CREATE_TENANT operationls 18 | id=$($cli -n tenant list | awk '{if (NR==3) {print $2}}') 19 | operation=$($cli -n tenant tasks $id | awk '{if (NR==3) {print $2}}') 20 | if [ "CREATE_TENANT" != $operation ] 21 | then 22 | exit 1 23 | fi 24 | 25 | # List out all the tenants and delete tenants not in the initial list 26 | output=$($cli -n tenant list | awk '{if (NR!=1) {print $2}}') 27 | for line in $output 28 | do 29 | if ! [[ ${initialTenants[*]} =~ $line ]] 30 | then 31 | $cli -n tenant delete $line 32 | fi 33 | done 34 | -------------------------------------------------------------------------------- /testdata/TestCA.crt: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIFmzCCA4OgAwIBAgIJAIAZmLcInJMeMA0GCSqGSIb3DQEBCwUAMGQxCzAJBgNV 3 | -----END CERTIFICATE----- 4 | -------------------------------------------------------------------------------- /testdata/TestKey.pub: -------------------------------------------------------------------------------- 1 | validSSH Part2 user@somewhere.com 2 | This line should not be read 3 | -------------------------------------------------------------------------------- /testdata/tty_tiny.ova: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware-archive/photon-controller-cli/500705b9c5339bc6a29d5adb7e9d5b4860d4cc4b/testdata/tty_tiny.ova -------------------------------------------------------------------------------- /testdata/ttylinux-pc_i486-16.1.iso: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vmware-archive/photon-controller-cli/500705b9c5339bc6a29d5adb7e9d5b4860d4cc4b/testdata/ttylinux-pc_i486-16.1.iso -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2014 Onsi Fakhouri 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/codelocation/code_location.go: -------------------------------------------------------------------------------- 1 | package codelocation 2 | 3 | import ( 4 | "regexp" 5 | "runtime" 6 | "runtime/debug" 7 | "strings" 8 | 9 | "github.com/onsi/ginkgo/types" 10 | ) 11 | 12 | func New(skip int) types.CodeLocation { 13 | _, file, line, _ := runtime.Caller(skip + 1) 14 | stackTrace := PruneStack(string(debug.Stack()), skip) 15 | return types.CodeLocation{FileName: file, LineNumber: line, FullStackTrace: stackTrace} 16 | } 17 | 18 | func PruneStack(fullStackTrace string, skip int) string { 19 | stack := strings.Split(fullStackTrace, "\n") 20 | if len(stack) > 2*(skip+1) { 21 | stack = stack[2*(skip+1):] 22 | } 23 | prunedStack := []string{} 24 | re := regexp.MustCompile(`\/ginkgo\/|\/pkg\/testing\/|\/pkg\/runtime\/`) 25 | for i := 0; i < len(stack)/2; i++ { 26 | if !re.Match([]byte(stack[i*2])) { 27 | prunedStack = append(prunedStack, stack[i*2]) 28 | prunedStack = append(prunedStack, stack[i*2+1]) 29 | } 30 | } 31 | return strings.Join(prunedStack, "\n") 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/failer/failer.go: -------------------------------------------------------------------------------- 1 | package failer 2 | 3 | import ( 4 | "fmt" 5 | "sync" 6 | 7 | "github.com/onsi/ginkgo/types" 8 | ) 9 | 10 | type Failer struct { 11 | lock *sync.Mutex 12 | failure types.SpecFailure 13 | state types.SpecState 14 | } 15 | 16 | func New() *Failer { 17 | return &Failer{ 18 | lock: &sync.Mutex{}, 19 | state: types.SpecStatePassed, 20 | } 21 | } 22 | 23 | func (f *Failer) Panic(location types.CodeLocation, forwardedPanic interface{}) { 24 | f.lock.Lock() 25 | defer f.lock.Unlock() 26 | 27 | if f.state == types.SpecStatePassed { 28 | f.state = types.SpecStatePanicked 29 | f.failure = types.SpecFailure{ 30 | Message: "Test Panicked", 31 | Location: location, 32 | ForwardedPanic: fmt.Sprintf("%v", forwardedPanic), 33 | } 34 | } 35 | } 36 | 37 | func (f *Failer) Timeout(location types.CodeLocation) { 38 | f.lock.Lock() 39 | defer f.lock.Unlock() 40 | 41 | if f.state == types.SpecStatePassed { 42 | f.state = types.SpecStateTimedOut 43 | f.failure = types.SpecFailure{ 44 | Message: "Timed out", 45 | Location: location, 46 | } 47 | } 48 | } 49 | 50 | func (f *Failer) Fail(message string, location types.CodeLocation) { 51 | f.lock.Lock() 52 | defer f.lock.Unlock() 53 | 54 | if f.state == types.SpecStatePassed { 55 | f.state = types.SpecStateFailed 56 | f.failure = types.SpecFailure{ 57 | Message: message, 58 | Location: location, 59 | } 60 | } 61 | } 62 | 63 | func (f *Failer) Drain(componentType types.SpecComponentType, componentIndex int, componentCodeLocation types.CodeLocation) (types.SpecFailure, types.SpecState) { 64 | f.lock.Lock() 65 | defer f.lock.Unlock() 66 | 67 | failure := f.failure 68 | outcome := f.state 69 | if outcome != types.SpecStatePassed { 70 | failure.ComponentType = componentType 71 | failure.ComponentIndex = componentIndex 72 | failure.ComponentCodeLocation = componentCodeLocation 73 | } 74 | 75 | f.state = types.SpecStatePassed 76 | f.failure = types.SpecFailure{} 77 | 78 | return failure, outcome 79 | } 80 | 81 | func (f *Failer) Skip(message string, location types.CodeLocation) { 82 | f.lock.Lock() 83 | defer f.lock.Unlock() 84 | 85 | if f.state == types.SpecStatePassed { 86 | f.state = types.SpecStateSkipped 87 | f.failure = types.SpecFailure{ 88 | Message: message, 89 | Location: location, 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/leafnodes/interfaces.go: -------------------------------------------------------------------------------- 1 | package leafnodes 2 | 3 | import ( 4 | "github.com/onsi/ginkgo/types" 5 | ) 6 | 7 | type BasicNode interface { 8 | Type() types.SpecComponentType 9 | Run() (types.SpecState, types.SpecFailure) 10 | CodeLocation() types.CodeLocation 11 | } 12 | 13 | type SubjectNode interface { 14 | BasicNode 15 | 16 | Text() string 17 | Flag() types.FlagType 18 | Samples() int 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/leafnodes/it_node.go: -------------------------------------------------------------------------------- 1 | package leafnodes 2 | 3 | import ( 4 | "github.com/onsi/ginkgo/internal/failer" 5 | "github.com/onsi/ginkgo/types" 6 | "time" 7 | ) 8 | 9 | type ItNode struct { 10 | runner *runner 11 | 12 | flag types.FlagType 13 | text string 14 | } 15 | 16 | func NewItNode(text string, body interface{}, flag types.FlagType, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer, componentIndex int) *ItNode { 17 | return &ItNode{ 18 | runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeIt, componentIndex), 19 | flag: flag, 20 | text: text, 21 | } 22 | } 23 | 24 | func (node *ItNode) Run() (outcome types.SpecState, failure types.SpecFailure) { 25 | return node.runner.run() 26 | } 27 | 28 | func (node *ItNode) Type() types.SpecComponentType { 29 | return types.SpecComponentTypeIt 30 | } 31 | 32 | func (node *ItNode) Text() string { 33 | return node.text 34 | } 35 | 36 | func (node *ItNode) Flag() types.FlagType { 37 | return node.flag 38 | } 39 | 40 | func (node *ItNode) CodeLocation() types.CodeLocation { 41 | return node.runner.codeLocation 42 | } 43 | 44 | func (node *ItNode) Samples() int { 45 | return 1 46 | } 47 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/leafnodes/measure_node.go: -------------------------------------------------------------------------------- 1 | package leafnodes 2 | 3 | import ( 4 | "github.com/onsi/ginkgo/internal/failer" 5 | "github.com/onsi/ginkgo/types" 6 | "reflect" 7 | ) 8 | 9 | type MeasureNode struct { 10 | runner *runner 11 | 12 | text string 13 | flag types.FlagType 14 | samples int 15 | benchmarker *benchmarker 16 | } 17 | 18 | func NewMeasureNode(text string, body interface{}, flag types.FlagType, codeLocation types.CodeLocation, samples int, failer *failer.Failer, componentIndex int) *MeasureNode { 19 | benchmarker := newBenchmarker() 20 | 21 | wrappedBody := func() { 22 | reflect.ValueOf(body).Call([]reflect.Value{reflect.ValueOf(benchmarker)}) 23 | } 24 | 25 | return &MeasureNode{ 26 | runner: newRunner(wrappedBody, codeLocation, 0, failer, types.SpecComponentTypeMeasure, componentIndex), 27 | 28 | text: text, 29 | flag: flag, 30 | samples: samples, 31 | benchmarker: benchmarker, 32 | } 33 | } 34 | 35 | func (node *MeasureNode) Run() (outcome types.SpecState, failure types.SpecFailure) { 36 | return node.runner.run() 37 | } 38 | 39 | func (node *MeasureNode) MeasurementsReport() map[string]*types.SpecMeasurement { 40 | return node.benchmarker.measurementsReport() 41 | } 42 | 43 | func (node *MeasureNode) Type() types.SpecComponentType { 44 | return types.SpecComponentTypeMeasure 45 | } 46 | 47 | func (node *MeasureNode) Text() string { 48 | return node.text 49 | } 50 | 51 | func (node *MeasureNode) Flag() types.FlagType { 52 | return node.flag 53 | } 54 | 55 | func (node *MeasureNode) CodeLocation() types.CodeLocation { 56 | return node.runner.codeLocation 57 | } 58 | 59 | func (node *MeasureNode) Samples() int { 60 | return node.samples 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/leafnodes/setup_nodes.go: -------------------------------------------------------------------------------- 1 | package leafnodes 2 | 3 | import ( 4 | "github.com/onsi/ginkgo/internal/failer" 5 | "github.com/onsi/ginkgo/types" 6 | "time" 7 | ) 8 | 9 | type SetupNode struct { 10 | runner *runner 11 | } 12 | 13 | func (node *SetupNode) Run() (outcome types.SpecState, failure types.SpecFailure) { 14 | return node.runner.run() 15 | } 16 | 17 | func (node *SetupNode) Type() types.SpecComponentType { 18 | return node.runner.nodeType 19 | } 20 | 21 | func (node *SetupNode) CodeLocation() types.CodeLocation { 22 | return node.runner.codeLocation 23 | } 24 | 25 | func NewBeforeEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer, componentIndex int) *SetupNode { 26 | return &SetupNode{ 27 | runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeBeforeEach, componentIndex), 28 | } 29 | } 30 | 31 | func NewAfterEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer, componentIndex int) *SetupNode { 32 | return &SetupNode{ 33 | runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeAfterEach, componentIndex), 34 | } 35 | } 36 | 37 | func NewJustBeforeEachNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer, componentIndex int) *SetupNode { 38 | return &SetupNode{ 39 | runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeJustBeforeEach, componentIndex), 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/leafnodes/suite_nodes.go: -------------------------------------------------------------------------------- 1 | package leafnodes 2 | 3 | import ( 4 | "github.com/onsi/ginkgo/internal/failer" 5 | "github.com/onsi/ginkgo/types" 6 | "time" 7 | ) 8 | 9 | type SuiteNode interface { 10 | Run(parallelNode int, parallelTotal int, syncHost string) bool 11 | Passed() bool 12 | Summary() *types.SetupSummary 13 | } 14 | 15 | type simpleSuiteNode struct { 16 | runner *runner 17 | outcome types.SpecState 18 | failure types.SpecFailure 19 | runTime time.Duration 20 | } 21 | 22 | func (node *simpleSuiteNode) Run(parallelNode int, parallelTotal int, syncHost string) bool { 23 | t := time.Now() 24 | node.outcome, node.failure = node.runner.run() 25 | node.runTime = time.Since(t) 26 | 27 | return node.outcome == types.SpecStatePassed 28 | } 29 | 30 | func (node *simpleSuiteNode) Passed() bool { 31 | return node.outcome == types.SpecStatePassed 32 | } 33 | 34 | func (node *simpleSuiteNode) Summary() *types.SetupSummary { 35 | return &types.SetupSummary{ 36 | ComponentType: node.runner.nodeType, 37 | CodeLocation: node.runner.codeLocation, 38 | State: node.outcome, 39 | RunTime: node.runTime, 40 | Failure: node.failure, 41 | } 42 | } 43 | 44 | func NewBeforeSuiteNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer) SuiteNode { 45 | return &simpleSuiteNode{ 46 | runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeBeforeSuite, 0), 47 | } 48 | } 49 | 50 | func NewAfterSuiteNode(body interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer) SuiteNode { 51 | return &simpleSuiteNode{ 52 | runner: newRunner(body, codeLocation, timeout, failer, types.SpecComponentTypeAfterSuite, 0), 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/leafnodes/synchronized_after_suite_node.go: -------------------------------------------------------------------------------- 1 | package leafnodes 2 | 3 | import ( 4 | "encoding/json" 5 | "github.com/onsi/ginkgo/internal/failer" 6 | "github.com/onsi/ginkgo/types" 7 | "io/ioutil" 8 | "net/http" 9 | "time" 10 | ) 11 | 12 | type synchronizedAfterSuiteNode struct { 13 | runnerA *runner 14 | runnerB *runner 15 | 16 | outcome types.SpecState 17 | failure types.SpecFailure 18 | runTime time.Duration 19 | } 20 | 21 | func NewSynchronizedAfterSuiteNode(bodyA interface{}, bodyB interface{}, codeLocation types.CodeLocation, timeout time.Duration, failer *failer.Failer) SuiteNode { 22 | return &synchronizedAfterSuiteNode{ 23 | runnerA: newRunner(bodyA, codeLocation, timeout, failer, types.SpecComponentTypeAfterSuite, 0), 24 | runnerB: newRunner(bodyB, codeLocation, timeout, failer, types.SpecComponentTypeAfterSuite, 0), 25 | } 26 | } 27 | 28 | func (node *synchronizedAfterSuiteNode) Run(parallelNode int, parallelTotal int, syncHost string) bool { 29 | node.outcome, node.failure = node.runnerA.run() 30 | 31 | if parallelNode == 1 { 32 | if parallelTotal > 1 { 33 | node.waitUntilOtherNodesAreDone(syncHost) 34 | } 35 | 36 | outcome, failure := node.runnerB.run() 37 | 38 | if node.outcome == types.SpecStatePassed { 39 | node.outcome, node.failure = outcome, failure 40 | } 41 | } 42 | 43 | return node.outcome == types.SpecStatePassed 44 | } 45 | 46 | func (node *synchronizedAfterSuiteNode) Passed() bool { 47 | return node.outcome == types.SpecStatePassed 48 | } 49 | 50 | func (node *synchronizedAfterSuiteNode) Summary() *types.SetupSummary { 51 | return &types.SetupSummary{ 52 | ComponentType: node.runnerA.nodeType, 53 | CodeLocation: node.runnerA.codeLocation, 54 | State: node.outcome, 55 | RunTime: node.runTime, 56 | Failure: node.failure, 57 | } 58 | } 59 | 60 | func (node *synchronizedAfterSuiteNode) waitUntilOtherNodesAreDone(syncHost string) { 61 | for { 62 | if node.canRun(syncHost) { 63 | return 64 | } 65 | 66 | time.Sleep(50 * time.Millisecond) 67 | } 68 | } 69 | 70 | func (node *synchronizedAfterSuiteNode) canRun(syncHost string) bool { 71 | resp, err := http.Get(syncHost + "/RemoteAfterSuiteData") 72 | if err != nil || resp.StatusCode != http.StatusOK { 73 | return false 74 | } 75 | 76 | body, err := ioutil.ReadAll(resp.Body) 77 | if err != nil { 78 | return false 79 | } 80 | resp.Body.Close() 81 | 82 | afterSuiteData := types.RemoteAfterSuiteData{} 83 | err = json.Unmarshal(body, &afterSuiteData) 84 | if err != nil { 85 | return false 86 | } 87 | 88 | return afterSuiteData.CanRun 89 | } 90 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor.go: -------------------------------------------------------------------------------- 1 | package remote 2 | 3 | /* 4 | The OutputInterceptor is used by the ForwardingReporter to 5 | intercept and capture all stdin and stderr output during a test run. 6 | */ 7 | type OutputInterceptor interface { 8 | StartInterceptingOutput() error 9 | StopInterceptingAndReturnOutput() (string, error) 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor_unix.go: -------------------------------------------------------------------------------- 1 | // +build freebsd openbsd netbsd dragonfly darwin linux solaris 2 | 3 | package remote 4 | 5 | import ( 6 | "errors" 7 | "io/ioutil" 8 | "os" 9 | ) 10 | 11 | func NewOutputInterceptor() OutputInterceptor { 12 | return &outputInterceptor{} 13 | } 14 | 15 | type outputInterceptor struct { 16 | redirectFile *os.File 17 | intercepting bool 18 | } 19 | 20 | func (interceptor *outputInterceptor) StartInterceptingOutput() error { 21 | if interceptor.intercepting { 22 | return errors.New("Already intercepting output!") 23 | } 24 | interceptor.intercepting = true 25 | 26 | var err error 27 | 28 | interceptor.redirectFile, err = ioutil.TempFile("", "ginkgo-output") 29 | if err != nil { 30 | return err 31 | } 32 | 33 | // Call a function in ./syscall_dup_*.go 34 | // If building for everything other than linux_arm64, 35 | // use a "normal" syscall.Dup2(oldfd, newfd) call. If building for linux_arm64 (which doesn't have syscall.Dup2) 36 | // call syscall.Dup3(oldfd, newfd, 0). They are nearly identical, see: http://linux.die.net/man/2/dup3 37 | syscallDup(int(interceptor.redirectFile.Fd()), 1) 38 | syscallDup(int(interceptor.redirectFile.Fd()), 2) 39 | 40 | return nil 41 | } 42 | 43 | func (interceptor *outputInterceptor) StopInterceptingAndReturnOutput() (string, error) { 44 | if !interceptor.intercepting { 45 | return "", errors.New("Not intercepting output!") 46 | } 47 | 48 | interceptor.redirectFile.Close() 49 | output, err := ioutil.ReadFile(interceptor.redirectFile.Name()) 50 | os.Remove(interceptor.redirectFile.Name()) 51 | 52 | interceptor.intercepting = false 53 | 54 | return string(output), err 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/remote/output_interceptor_win.go: -------------------------------------------------------------------------------- 1 | // +build windows 2 | 3 | package remote 4 | 5 | import ( 6 | "errors" 7 | ) 8 | 9 | func NewOutputInterceptor() OutputInterceptor { 10 | return &outputInterceptor{} 11 | } 12 | 13 | type outputInterceptor struct { 14 | intercepting bool 15 | } 16 | 17 | func (interceptor *outputInterceptor) StartInterceptingOutput() error { 18 | if interceptor.intercepting { 19 | return errors.New("Already intercepting output!") 20 | } 21 | interceptor.intercepting = true 22 | 23 | // not working on windows... 24 | 25 | return nil 26 | } 27 | 28 | func (interceptor *outputInterceptor) StopInterceptingAndReturnOutput() (string, error) { 29 | // not working on windows... 30 | interceptor.intercepting = false 31 | 32 | return "", nil 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_linux_arm64.go: -------------------------------------------------------------------------------- 1 | // +build linux,arm64 2 | 3 | package remote 4 | 5 | import "syscall" 6 | 7 | // linux_arm64 doesn't have syscall.Dup2 which ginkgo uses, so 8 | // use the nearly identical syscall.Dup3 instead 9 | func syscallDup(oldfd int, newfd int) (err error) { 10 | return syscall.Dup3(oldfd, newfd, 0) 11 | } -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_solaris.go: -------------------------------------------------------------------------------- 1 | // +build solaris 2 | 3 | package remote 4 | 5 | import "golang.org/x/sys/unix" 6 | 7 | func syscallDup(oldfd int, newfd int) (err error) { 8 | return unix.Dup2(oldfd, newfd) 9 | } -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/remote/syscall_dup_unix.go: -------------------------------------------------------------------------------- 1 | // +build !linux !arm64 2 | // +build !windows 3 | // +build !solaris 4 | 5 | package remote 6 | 7 | import "syscall" 8 | 9 | func syscallDup(oldfd int, newfd int) (err error) { 10 | return syscall.Dup2(oldfd, newfd) 11 | } -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/spec/index_computer.go: -------------------------------------------------------------------------------- 1 | package spec 2 | 3 | func ParallelizedIndexRange(length int, parallelTotal int, parallelNode int) (startIndex int, count int) { 4 | if length == 0 { 5 | return 0, 0 6 | } 7 | 8 | // We have more nodes than tests. Trivial case. 9 | if parallelTotal >= length { 10 | if parallelNode > length { 11 | return 0, 0 12 | } else { 13 | return parallelNode - 1, 1 14 | } 15 | } 16 | 17 | // This is the minimum amount of tests that a node will be required to run 18 | minTestsPerNode := length / parallelTotal 19 | 20 | // This is the maximum amount of tests that a node will be required to run 21 | // The algorithm guarantees that this would be equal to at least the minimum amount 22 | // and at most one more 23 | maxTestsPerNode := minTestsPerNode 24 | if length%parallelTotal != 0 { 25 | maxTestsPerNode++ 26 | } 27 | 28 | // Number of nodes that will have to run the maximum amount of tests per node 29 | numMaxLoadNodes := length % parallelTotal 30 | 31 | // Number of nodes that precede the current node and will have to run the maximum amount of tests per node 32 | var numPrecedingMaxLoadNodes int 33 | if parallelNode > numMaxLoadNodes { 34 | numPrecedingMaxLoadNodes = numMaxLoadNodes 35 | } else { 36 | numPrecedingMaxLoadNodes = parallelNode - 1 37 | } 38 | 39 | // Number of nodes that precede the current node and will have to run the minimum amount of tests per node 40 | var numPrecedingMinLoadNodes int 41 | if parallelNode <= numMaxLoadNodes { 42 | numPrecedingMinLoadNodes = 0 43 | } else { 44 | numPrecedingMinLoadNodes = parallelNode - numMaxLoadNodes - 1 45 | } 46 | 47 | // Evaluate the test start index and number of tests to run 48 | startIndex = numPrecedingMaxLoadNodes*maxTestsPerNode + numPrecedingMinLoadNodes*minTestsPerNode 49 | if parallelNode > numMaxLoadNodes { 50 | count = minTestsPerNode 51 | } else { 52 | count = maxTestsPerNode 53 | } 54 | return 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/specrunner/random_id.go: -------------------------------------------------------------------------------- 1 | package specrunner 2 | 3 | import ( 4 | "crypto/rand" 5 | "fmt" 6 | ) 7 | 8 | func randomID() string { 9 | b := make([]byte, 8) 10 | _, err := rand.Read(b) 11 | if err != nil { 12 | return "" 13 | } 14 | return fmt.Sprintf("%x-%x-%x-%x", b[0:2], b[2:4], b[4:6], b[6:8]) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/testingtproxy/testing_t_proxy.go: -------------------------------------------------------------------------------- 1 | package testingtproxy 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | type failFunc func(message string, callerSkip ...int) 9 | 10 | func New(writer io.Writer, fail failFunc, offset int) *ginkgoTestingTProxy { 11 | return &ginkgoTestingTProxy{ 12 | fail: fail, 13 | offset: offset, 14 | writer: writer, 15 | } 16 | } 17 | 18 | type ginkgoTestingTProxy struct { 19 | fail failFunc 20 | offset int 21 | writer io.Writer 22 | } 23 | 24 | func (t *ginkgoTestingTProxy) Error(args ...interface{}) { 25 | t.fail(fmt.Sprintln(args...), t.offset) 26 | } 27 | 28 | func (t *ginkgoTestingTProxy) Errorf(format string, args ...interface{}) { 29 | t.fail(fmt.Sprintf(format, args...), t.offset) 30 | } 31 | 32 | func (t *ginkgoTestingTProxy) Fail() { 33 | t.fail("failed", t.offset) 34 | } 35 | 36 | func (t *ginkgoTestingTProxy) FailNow() { 37 | t.fail("failed", t.offset) 38 | } 39 | 40 | func (t *ginkgoTestingTProxy) Fatal(args ...interface{}) { 41 | t.fail(fmt.Sprintln(args...), t.offset) 42 | } 43 | 44 | func (t *ginkgoTestingTProxy) Fatalf(format string, args ...interface{}) { 45 | t.fail(fmt.Sprintf(format, args...), t.offset) 46 | } 47 | 48 | func (t *ginkgoTestingTProxy) Log(args ...interface{}) { 49 | fmt.Fprintln(t.writer, args...) 50 | } 51 | 52 | func (t *ginkgoTestingTProxy) Logf(format string, args ...interface{}) { 53 | fmt.Fprintf(t.writer, format, args...) 54 | } 55 | 56 | func (t *ginkgoTestingTProxy) Failed() bool { 57 | return false 58 | } 59 | 60 | func (t *ginkgoTestingTProxy) Parallel() { 61 | } 62 | 63 | func (t *ginkgoTestingTProxy) Skip(args ...interface{}) { 64 | fmt.Println(args...) 65 | } 66 | 67 | func (t *ginkgoTestingTProxy) Skipf(format string, args ...interface{}) { 68 | fmt.Printf(format, args...) 69 | } 70 | 71 | func (t *ginkgoTestingTProxy) SkipNow() { 72 | } 73 | 74 | func (t *ginkgoTestingTProxy) Skipped() bool { 75 | return false 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/writer/fake_writer.go: -------------------------------------------------------------------------------- 1 | package writer 2 | 3 | type FakeGinkgoWriter struct { 4 | EventStream []string 5 | } 6 | 7 | func NewFake() *FakeGinkgoWriter { 8 | return &FakeGinkgoWriter{ 9 | EventStream: []string{}, 10 | } 11 | } 12 | 13 | func (writer *FakeGinkgoWriter) AddEvent(event string) { 14 | writer.EventStream = append(writer.EventStream, event) 15 | } 16 | 17 | func (writer *FakeGinkgoWriter) Truncate() { 18 | writer.EventStream = append(writer.EventStream, "TRUNCATE") 19 | } 20 | 21 | func (writer *FakeGinkgoWriter) DumpOut() { 22 | writer.EventStream = append(writer.EventStream, "DUMP") 23 | } 24 | 25 | func (writer *FakeGinkgoWriter) DumpOutWithHeader(header string) { 26 | writer.EventStream = append(writer.EventStream, "DUMP_WITH_HEADER: "+header) 27 | } 28 | 29 | func (writer *FakeGinkgoWriter) Write(data []byte) (n int, err error) { 30 | return 0, nil 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/internal/writer/writer.go: -------------------------------------------------------------------------------- 1 | package writer 2 | 3 | import ( 4 | "bytes" 5 | "io" 6 | "sync" 7 | ) 8 | 9 | type WriterInterface interface { 10 | io.Writer 11 | 12 | Truncate() 13 | DumpOut() 14 | DumpOutWithHeader(header string) 15 | } 16 | 17 | type Writer struct { 18 | buffer *bytes.Buffer 19 | outWriter io.Writer 20 | lock *sync.Mutex 21 | stream bool 22 | } 23 | 24 | func New(outWriter io.Writer) *Writer { 25 | return &Writer{ 26 | buffer: &bytes.Buffer{}, 27 | lock: &sync.Mutex{}, 28 | outWriter: outWriter, 29 | stream: true, 30 | } 31 | } 32 | 33 | func (w *Writer) SetStream(stream bool) { 34 | w.lock.Lock() 35 | defer w.lock.Unlock() 36 | w.stream = stream 37 | } 38 | 39 | func (w *Writer) Write(b []byte) (n int, err error) { 40 | w.lock.Lock() 41 | defer w.lock.Unlock() 42 | 43 | if w.stream { 44 | return w.outWriter.Write(b) 45 | } else { 46 | return w.buffer.Write(b) 47 | } 48 | } 49 | 50 | func (w *Writer) Truncate() { 51 | w.lock.Lock() 52 | defer w.lock.Unlock() 53 | w.buffer.Reset() 54 | } 55 | 56 | func (w *Writer) DumpOut() { 57 | w.lock.Lock() 58 | defer w.lock.Unlock() 59 | if !w.stream { 60 | w.buffer.WriteTo(w.outWriter) 61 | } 62 | } 63 | 64 | func (w *Writer) DumpOutWithHeader(header string) { 65 | w.lock.Lock() 66 | defer w.lock.Unlock() 67 | if !w.stream && w.buffer.Len() > 0 { 68 | w.outWriter.Write([]byte(header)) 69 | w.buffer.WriteTo(w.outWriter) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/reporters/fake_reporter.go: -------------------------------------------------------------------------------- 1 | package reporters 2 | 3 | import ( 4 | "github.com/onsi/ginkgo/config" 5 | "github.com/onsi/ginkgo/types" 6 | ) 7 | 8 | //FakeReporter is useful for testing purposes 9 | type FakeReporter struct { 10 | Config config.GinkgoConfigType 11 | 12 | BeginSummary *types.SuiteSummary 13 | BeforeSuiteSummary *types.SetupSummary 14 | SpecWillRunSummaries []*types.SpecSummary 15 | SpecSummaries []*types.SpecSummary 16 | AfterSuiteSummary *types.SetupSummary 17 | EndSummary *types.SuiteSummary 18 | 19 | SpecWillRunStub func(specSummary *types.SpecSummary) 20 | SpecDidCompleteStub func(specSummary *types.SpecSummary) 21 | } 22 | 23 | func NewFakeReporter() *FakeReporter { 24 | return &FakeReporter{ 25 | SpecWillRunSummaries: make([]*types.SpecSummary, 0), 26 | SpecSummaries: make([]*types.SpecSummary, 0), 27 | } 28 | } 29 | 30 | func (fakeR *FakeReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) { 31 | fakeR.Config = config 32 | fakeR.BeginSummary = summary 33 | } 34 | 35 | func (fakeR *FakeReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary) { 36 | fakeR.BeforeSuiteSummary = setupSummary 37 | } 38 | 39 | func (fakeR *FakeReporter) SpecWillRun(specSummary *types.SpecSummary) { 40 | if fakeR.SpecWillRunStub != nil { 41 | fakeR.SpecWillRunStub(specSummary) 42 | } 43 | fakeR.SpecWillRunSummaries = append(fakeR.SpecWillRunSummaries, specSummary) 44 | } 45 | 46 | func (fakeR *FakeReporter) SpecDidComplete(specSummary *types.SpecSummary) { 47 | if fakeR.SpecDidCompleteStub != nil { 48 | fakeR.SpecDidCompleteStub(specSummary) 49 | } 50 | fakeR.SpecSummaries = append(fakeR.SpecSummaries, specSummary) 51 | } 52 | 53 | func (fakeR *FakeReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary) { 54 | fakeR.AfterSuiteSummary = setupSummary 55 | } 56 | 57 | func (fakeR *FakeReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) { 58 | fakeR.EndSummary = summary 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/reporters/reporter.go: -------------------------------------------------------------------------------- 1 | package reporters 2 | 3 | import ( 4 | "github.com/onsi/ginkgo/config" 5 | "github.com/onsi/ginkgo/types" 6 | ) 7 | 8 | type Reporter interface { 9 | SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) 10 | BeforeSuiteDidRun(setupSummary *types.SetupSummary) 11 | SpecWillRun(specSummary *types.SpecSummary) 12 | SpecDidComplete(specSummary *types.SpecSummary) 13 | AfterSuiteDidRun(setupSummary *types.SetupSummary) 14 | SpecSuiteDidEnd(summary *types.SuiteSummary) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/reporters/stenographer/console_logging.go: -------------------------------------------------------------------------------- 1 | package stenographer 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | ) 7 | 8 | func (s *consoleStenographer) colorize(colorCode string, format string, args ...interface{}) string { 9 | var out string 10 | 11 | if len(args) > 0 { 12 | out = fmt.Sprintf(format, args...) 13 | } else { 14 | out = format 15 | } 16 | 17 | if s.color { 18 | return fmt.Sprintf("%s%s%s", colorCode, out, defaultStyle) 19 | } else { 20 | return out 21 | } 22 | } 23 | 24 | func (s *consoleStenographer) printBanner(text string, bannerCharacter string) { 25 | fmt.Println(text) 26 | fmt.Println(strings.Repeat(bannerCharacter, len(text))) 27 | } 28 | 29 | func (s *consoleStenographer) printNewLine() { 30 | fmt.Println("") 31 | } 32 | 33 | func (s *consoleStenographer) printDelimiter() { 34 | fmt.Println(s.colorize(grayColor, "%s", strings.Repeat("-", 30))) 35 | } 36 | 37 | func (s *consoleStenographer) print(indentation int, format string, args ...interface{}) { 38 | fmt.Print(s.indent(indentation, format, args...)) 39 | } 40 | 41 | func (s *consoleStenographer) println(indentation int, format string, args ...interface{}) { 42 | fmt.Println(s.indent(indentation, format, args...)) 43 | } 44 | 45 | func (s *consoleStenographer) indent(indentation int, format string, args ...interface{}) string { 46 | var text string 47 | 48 | if len(args) > 0 { 49 | text = fmt.Sprintf(format, args...) 50 | } else { 51 | text = format 52 | } 53 | 54 | stringArray := strings.Split(text, "\n") 55 | padding := "" 56 | if indentation >= 0 { 57 | padding = strings.Repeat(" ", indentation) 58 | } 59 | for i, s := range stringArray { 60 | stringArray[i] = fmt.Sprintf("%s%s", padding, s) 61 | } 62 | 63 | return strings.Join(stringArray, "\n") 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/types/code_location.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | type CodeLocation struct { 8 | FileName string 9 | LineNumber int 10 | FullStackTrace string 11 | } 12 | 13 | func (codeLocation CodeLocation) String() string { 14 | return fmt.Sprintf("%s:%d", codeLocation.FileName, codeLocation.LineNumber) 15 | } 16 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/ginkgo/types/synchronization.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | import ( 4 | "encoding/json" 5 | ) 6 | 7 | type RemoteBeforeSuiteState int 8 | 9 | const ( 10 | RemoteBeforeSuiteStateInvalid RemoteBeforeSuiteState = iota 11 | 12 | RemoteBeforeSuiteStatePending 13 | RemoteBeforeSuiteStatePassed 14 | RemoteBeforeSuiteStateFailed 15 | RemoteBeforeSuiteStateDisappeared 16 | ) 17 | 18 | type RemoteBeforeSuiteData struct { 19 | Data []byte 20 | State RemoteBeforeSuiteState 21 | } 22 | 23 | func (r RemoteBeforeSuiteData) ToJSON() []byte { 24 | data, _ := json.Marshal(r) 25 | return data 26 | } 27 | 28 | type RemoteAfterSuiteData struct { 29 | CanRun bool 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2014 Onsi Fakhouri 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/README.md: -------------------------------------------------------------------------------- 1 | ![Gomega: Ginkgo's Preferred Matcher Library](http://onsi.github.io/gomega/images/gomega.png) 2 | 3 | [![Build Status](https://travis-ci.org/onsi/gomega.png)](https://travis-ci.org/onsi/gomega) 4 | 5 | Jump straight to the [docs](http://onsi.github.io/gomega/) to learn about Gomega, including a list of [all available matchers](http://onsi.github.io/gomega/#provided-matchers). 6 | 7 | To discuss Gomega and get updates, join the [google group](https://groups.google.com/d/forum/ginkgo-and-gomega). 8 | 9 | ## [Ginkgo](http://github.com/onsi/ginkgo): a BDD Testing Framework for Golang 10 | 11 | Learn more about Ginkgo [here](http://onsi.github.io/ginkgo/) 12 | 13 | ## License 14 | 15 | Gomega is MIT-Licensed 16 | 17 | The `ConsistOf` matcher uses [goraph](https://github.com/amitkgupta/goraph) which is embedded in the source to simplify distribution. goraph has an MIT license. 18 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/internal/oraclematcher/oracle_matcher.go: -------------------------------------------------------------------------------- 1 | package oraclematcher 2 | 3 | import "github.com/onsi/gomega/types" 4 | 5 | /* 6 | GomegaMatchers that also match the OracleMatcher interface can convey information about 7 | whether or not their result will change upon future attempts. 8 | 9 | This allows `Eventually` and `Consistently` to short circuit if success becomes impossible. 10 | 11 | For example, a process' exit code can never change. So, gexec's Exit matcher returns `true` 12 | for `MatchMayChangeInTheFuture` until the process exits, at which point it returns `false` forevermore. 13 | */ 14 | type OracleMatcher interface { 15 | MatchMayChangeInTheFuture(actual interface{}) bool 16 | } 17 | 18 | func MatchMayChangeInTheFuture(matcher types.GomegaMatcher, value interface{}) bool { 19 | oracleMatcher, ok := matcher.(OracleMatcher) 20 | if !ok { 21 | return true 22 | } 23 | 24 | return oracleMatcher.MatchMayChangeInTheFuture(value) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/internal/testingtsupport/testing_t_support.go: -------------------------------------------------------------------------------- 1 | package testingtsupport 2 | 3 | import ( 4 | "regexp" 5 | "runtime/debug" 6 | "strings" 7 | 8 | "github.com/onsi/gomega/types" 9 | ) 10 | 11 | type gomegaTestingT interface { 12 | Errorf(format string, args ...interface{}) 13 | } 14 | 15 | func BuildTestingTGomegaFailHandler(t gomegaTestingT) types.GomegaFailHandler { 16 | return func(message string, callerSkip ...int) { 17 | skip := 1 18 | if len(callerSkip) > 0 { 19 | skip = callerSkip[0] 20 | } 21 | stackTrace := pruneStack(string(debug.Stack()), skip) 22 | t.Errorf("\n%s\n%s", stackTrace, message) 23 | } 24 | } 25 | 26 | func pruneStack(fullStackTrace string, skip int) string { 27 | stack := strings.Split(fullStackTrace, "\n") 28 | if len(stack) > 2*(skip+1) { 29 | stack = stack[2*(skip+1):] 30 | } 31 | prunedStack := []string{} 32 | re := regexp.MustCompile(`\/ginkgo\/|\/pkg\/testing\/|\/pkg\/runtime\/`) 33 | for i := 0; i < len(stack)/2; i++ { 34 | if !re.Match([]byte(stack[i*2])) { 35 | prunedStack = append(prunedStack, stack[i*2]) 36 | prunedStack = append(prunedStack, stack[i*2+1]) 37 | } 38 | } 39 | return strings.Join(prunedStack, "\n") 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/and.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/onsi/gomega/format" 7 | "github.com/onsi/gomega/internal/oraclematcher" 8 | "github.com/onsi/gomega/types" 9 | ) 10 | 11 | type AndMatcher struct { 12 | Matchers []types.GomegaMatcher 13 | 14 | // state 15 | firstFailedMatcher types.GomegaMatcher 16 | } 17 | 18 | func (m *AndMatcher) Match(actual interface{}) (success bool, err error) { 19 | m.firstFailedMatcher = nil 20 | for _, matcher := range m.Matchers { 21 | success, err := matcher.Match(actual) 22 | if !success || err != nil { 23 | m.firstFailedMatcher = matcher 24 | return false, err 25 | } 26 | } 27 | return true, nil 28 | } 29 | 30 | func (m *AndMatcher) FailureMessage(actual interface{}) (message string) { 31 | return m.firstFailedMatcher.FailureMessage(actual) 32 | } 33 | 34 | func (m *AndMatcher) NegatedFailureMessage(actual interface{}) (message string) { 35 | // not the most beautiful list of matchers, but not bad either... 36 | return format.Message(actual, fmt.Sprintf("To not satisfy all of these matchers: %s", m.Matchers)) 37 | } 38 | 39 | func (m *AndMatcher) MatchMayChangeInTheFuture(actual interface{}) bool { 40 | /* 41 | Example with 3 matchers: A, B, C 42 | 43 | Match evaluates them: T, F, => F 44 | So match is currently F, what should MatchMayChangeInTheFuture() return? 45 | Seems like it only depends on B, since currently B MUST change to allow the result to become T 46 | 47 | Match eval: T, T, T => T 48 | So match is currently T, what should MatchMayChangeInTheFuture() return? 49 | Seems to depend on ANY of them being able to change to F. 50 | */ 51 | 52 | if m.firstFailedMatcher == nil { 53 | // so all matchers succeeded.. Any one of them changing would change the result. 54 | for _, matcher := range m.Matchers { 55 | if oraclematcher.MatchMayChangeInTheFuture(matcher, actual) { 56 | return true 57 | } 58 | } 59 | return false // none of were going to change 60 | } else { 61 | // one of the matchers failed.. it must be able to change in order to affect the result 62 | return oraclematcher.MatchMayChangeInTheFuture(m.firstFailedMatcher, actual) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/assignable_to_type_of_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | 7 | "github.com/onsi/gomega/format" 8 | ) 9 | 10 | type AssignableToTypeOfMatcher struct { 11 | Expected interface{} 12 | } 13 | 14 | func (matcher *AssignableToTypeOfMatcher) Match(actual interface{}) (success bool, err error) { 15 | if actual == nil || matcher.Expected == nil { 16 | return false, fmt.Errorf("Refusing to compare to .\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.") 17 | } 18 | 19 | actualType := reflect.TypeOf(actual) 20 | expectedType := reflect.TypeOf(matcher.Expected) 21 | 22 | return actualType.AssignableTo(expectedType), nil 23 | } 24 | 25 | func (matcher *AssignableToTypeOfMatcher) FailureMessage(actual interface{}) string { 26 | return format.Message(actual, fmt.Sprintf("to be assignable to the type: %T", matcher.Expected)) 27 | } 28 | 29 | func (matcher *AssignableToTypeOfMatcher) NegatedFailureMessage(actual interface{}) string { 30 | return format.Message(actual, fmt.Sprintf("not to be assignable to the type: %T", matcher.Expected)) 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_a_directory.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/onsi/gomega/format" 8 | ) 9 | 10 | type notADirectoryError struct { 11 | os.FileInfo 12 | } 13 | 14 | func (t notADirectoryError) Error() string { 15 | fileInfo := os.FileInfo(t) 16 | switch { 17 | case fileInfo.Mode().IsRegular(): 18 | return "file is a regular file" 19 | default: 20 | return fmt.Sprintf("file mode is: %s", fileInfo.Mode().String()) 21 | } 22 | } 23 | 24 | type BeADirectoryMatcher struct { 25 | expected interface{} 26 | err error 27 | } 28 | 29 | func (matcher *BeADirectoryMatcher) Match(actual interface{}) (success bool, err error) { 30 | actualFilename, ok := actual.(string) 31 | if !ok { 32 | return false, fmt.Errorf("BeADirectoryMatcher matcher expects a file path") 33 | } 34 | 35 | fileInfo, err := os.Stat(actualFilename) 36 | if err != nil { 37 | matcher.err = err 38 | return false, nil 39 | } 40 | 41 | if !fileInfo.Mode().IsDir() { 42 | matcher.err = notADirectoryError{fileInfo} 43 | return false, nil 44 | } 45 | return true, nil 46 | } 47 | 48 | func (matcher *BeADirectoryMatcher) FailureMessage(actual interface{}) (message string) { 49 | return format.Message(actual, fmt.Sprintf("to be a directory: %s", matcher.err)) 50 | } 51 | 52 | func (matcher *BeADirectoryMatcher) NegatedFailureMessage(actual interface{}) (message string) { 53 | return format.Message(actual, fmt.Sprintf("not be a directory")) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_a_regular_file.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/onsi/gomega/format" 8 | ) 9 | 10 | type notARegularFileError struct { 11 | os.FileInfo 12 | } 13 | 14 | func (t notARegularFileError) Error() string { 15 | fileInfo := os.FileInfo(t) 16 | switch { 17 | case fileInfo.IsDir(): 18 | return "file is a directory" 19 | default: 20 | return fmt.Sprintf("file mode is: %s", fileInfo.Mode().String()) 21 | } 22 | } 23 | 24 | type BeARegularFileMatcher struct { 25 | expected interface{} 26 | err error 27 | } 28 | 29 | func (matcher *BeARegularFileMatcher) Match(actual interface{}) (success bool, err error) { 30 | actualFilename, ok := actual.(string) 31 | if !ok { 32 | return false, fmt.Errorf("BeARegularFileMatcher matcher expects a file path") 33 | } 34 | 35 | fileInfo, err := os.Stat(actualFilename) 36 | if err != nil { 37 | matcher.err = err 38 | return false, nil 39 | } 40 | 41 | if !fileInfo.Mode().IsRegular() { 42 | matcher.err = notARegularFileError{fileInfo} 43 | return false, nil 44 | } 45 | return true, nil 46 | } 47 | 48 | func (matcher *BeARegularFileMatcher) FailureMessage(actual interface{}) (message string) { 49 | return format.Message(actual, fmt.Sprintf("to be a regular file: %s", matcher.err)) 50 | } 51 | 52 | func (matcher *BeARegularFileMatcher) NegatedFailureMessage(actual interface{}) (message string) { 53 | return format.Message(actual, fmt.Sprintf("not be a regular file")) 54 | } 55 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_an_existing_file.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | 7 | "github.com/onsi/gomega/format" 8 | ) 9 | 10 | type BeAnExistingFileMatcher struct { 11 | expected interface{} 12 | } 13 | 14 | func (matcher *BeAnExistingFileMatcher) Match(actual interface{}) (success bool, err error) { 15 | actualFilename, ok := actual.(string) 16 | if !ok { 17 | return false, fmt.Errorf("BeAnExistingFileMatcher matcher expects a file path") 18 | } 19 | 20 | if _, err = os.Stat(actualFilename); err != nil { 21 | switch { 22 | case os.IsNotExist(err): 23 | return false, nil 24 | default: 25 | return false, err 26 | } 27 | } 28 | 29 | return true, nil 30 | } 31 | 32 | func (matcher *BeAnExistingFileMatcher) FailureMessage(actual interface{}) (message string) { 33 | return format.Message(actual, fmt.Sprintf("to exist")) 34 | } 35 | 36 | func (matcher *BeAnExistingFileMatcher) NegatedFailureMessage(actual interface{}) (message string) { 37 | return format.Message(actual, fmt.Sprintf("not to exist")) 38 | } 39 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_closed_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | "reflect" 7 | ) 8 | 9 | type BeClosedMatcher struct { 10 | } 11 | 12 | func (matcher *BeClosedMatcher) Match(actual interface{}) (success bool, err error) { 13 | if !isChan(actual) { 14 | return false, fmt.Errorf("BeClosed matcher expects a channel. Got:\n%s", format.Object(actual, 1)) 15 | } 16 | 17 | channelType := reflect.TypeOf(actual) 18 | channelValue := reflect.ValueOf(actual) 19 | 20 | if channelType.ChanDir() == reflect.SendDir { 21 | return false, fmt.Errorf("BeClosed matcher cannot determine if a send-only channel is closed or open. Got:\n%s", format.Object(actual, 1)) 22 | } 23 | 24 | winnerIndex, _, open := reflect.Select([]reflect.SelectCase{ 25 | reflect.SelectCase{Dir: reflect.SelectRecv, Chan: channelValue}, 26 | reflect.SelectCase{Dir: reflect.SelectDefault}, 27 | }) 28 | 29 | var closed bool 30 | if winnerIndex == 0 { 31 | closed = !open 32 | } else if winnerIndex == 1 { 33 | closed = false 34 | } 35 | 36 | return closed, nil 37 | } 38 | 39 | func (matcher *BeClosedMatcher) FailureMessage(actual interface{}) (message string) { 40 | return format.Message(actual, "to be closed") 41 | } 42 | 43 | func (matcher *BeClosedMatcher) NegatedFailureMessage(actual interface{}) (message string) { 44 | return format.Message(actual, "to be open") 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_empty_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | ) 7 | 8 | type BeEmptyMatcher struct { 9 | } 10 | 11 | func (matcher *BeEmptyMatcher) Match(actual interface{}) (success bool, err error) { 12 | length, ok := lengthOf(actual) 13 | if !ok { 14 | return false, fmt.Errorf("BeEmpty matcher expects a string/array/map/channel/slice. Got:\n%s", format.Object(actual, 1)) 15 | } 16 | 17 | return length == 0, nil 18 | } 19 | 20 | func (matcher *BeEmptyMatcher) FailureMessage(actual interface{}) (message string) { 21 | return format.Message(actual, "to be empty") 22 | } 23 | 24 | func (matcher *BeEmptyMatcher) NegatedFailureMessage(actual interface{}) (message string) { 25 | return format.Message(actual, "not to be empty") 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_equivalent_to_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | "reflect" 7 | ) 8 | 9 | type BeEquivalentToMatcher struct { 10 | Expected interface{} 11 | } 12 | 13 | func (matcher *BeEquivalentToMatcher) Match(actual interface{}) (success bool, err error) { 14 | if actual == nil && matcher.Expected == nil { 15 | return false, fmt.Errorf("Both actual and expected must not be nil.") 16 | } 17 | 18 | convertedActual := actual 19 | 20 | if actual != nil && matcher.Expected != nil && reflect.TypeOf(actual).ConvertibleTo(reflect.TypeOf(matcher.Expected)) { 21 | convertedActual = reflect.ValueOf(actual).Convert(reflect.TypeOf(matcher.Expected)).Interface() 22 | } 23 | 24 | return reflect.DeepEqual(convertedActual, matcher.Expected), nil 25 | } 26 | 27 | func (matcher *BeEquivalentToMatcher) FailureMessage(actual interface{}) (message string) { 28 | return format.Message(actual, "to be equivalent to", matcher.Expected) 29 | } 30 | 31 | func (matcher *BeEquivalentToMatcher) NegatedFailureMessage(actual interface{}) (message string) { 32 | return format.Message(actual, "not to be equivalent to", matcher.Expected) 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_false_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | ) 7 | 8 | type BeFalseMatcher struct { 9 | } 10 | 11 | func (matcher *BeFalseMatcher) Match(actual interface{}) (success bool, err error) { 12 | if !isBool(actual) { 13 | return false, fmt.Errorf("Expected a boolean. Got:\n%s", format.Object(actual, 1)) 14 | } 15 | 16 | return actual == false, nil 17 | } 18 | 19 | func (matcher *BeFalseMatcher) FailureMessage(actual interface{}) (message string) { 20 | return format.Message(actual, "to be false") 21 | } 22 | 23 | func (matcher *BeFalseMatcher) NegatedFailureMessage(actual interface{}) (message string) { 24 | return format.Message(actual, "not to be false") 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_identical_to.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "runtime" 6 | 7 | "github.com/onsi/gomega/format" 8 | ) 9 | 10 | type BeIdenticalToMatcher struct { 11 | Expected interface{} 12 | } 13 | 14 | func (matcher *BeIdenticalToMatcher) Match(actual interface{}) (success bool, matchErr error) { 15 | if actual == nil && matcher.Expected == nil { 16 | return false, fmt.Errorf("Refusing to compare to .\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.") 17 | } 18 | 19 | defer func() { 20 | if r := recover(); r != nil { 21 | if _, ok := r.(runtime.Error); ok { 22 | success = false 23 | matchErr = nil 24 | } 25 | } 26 | }() 27 | 28 | return actual == matcher.Expected, nil 29 | } 30 | 31 | func (matcher *BeIdenticalToMatcher) FailureMessage(actual interface{}) string { 32 | return format.Message(actual, "to be identical to", matcher.Expected) 33 | } 34 | 35 | func (matcher *BeIdenticalToMatcher) NegatedFailureMessage(actual interface{}) string { 36 | return format.Message(actual, "not to be identical to", matcher.Expected) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_nil_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import "github.com/onsi/gomega/format" 4 | 5 | type BeNilMatcher struct { 6 | } 7 | 8 | func (matcher *BeNilMatcher) Match(actual interface{}) (success bool, err error) { 9 | return isNil(actual), nil 10 | } 11 | 12 | func (matcher *BeNilMatcher) FailureMessage(actual interface{}) (message string) { 13 | return format.Message(actual, "to be nil") 14 | } 15 | 16 | func (matcher *BeNilMatcher) NegatedFailureMessage(actual interface{}) (message string) { 17 | return format.Message(actual, "not to be nil") 18 | } 19 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_sent_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | 7 | "github.com/onsi/gomega/format" 8 | ) 9 | 10 | type BeSentMatcher struct { 11 | Arg interface{} 12 | channelClosed bool 13 | } 14 | 15 | func (matcher *BeSentMatcher) Match(actual interface{}) (success bool, err error) { 16 | if !isChan(actual) { 17 | return false, fmt.Errorf("BeSent expects a channel. Got:\n%s", format.Object(actual, 1)) 18 | } 19 | 20 | channelType := reflect.TypeOf(actual) 21 | channelValue := reflect.ValueOf(actual) 22 | 23 | if channelType.ChanDir() == reflect.RecvDir { 24 | return false, fmt.Errorf("BeSent matcher cannot be passed a receive-only channel. Got:\n%s", format.Object(actual, 1)) 25 | } 26 | 27 | argType := reflect.TypeOf(matcher.Arg) 28 | assignable := argType.AssignableTo(channelType.Elem()) 29 | 30 | if !assignable { 31 | return false, fmt.Errorf("Cannot pass:\n%s to the channel:\n%s\nThe types don't match.", format.Object(matcher.Arg, 1), format.Object(actual, 1)) 32 | } 33 | 34 | argValue := reflect.ValueOf(matcher.Arg) 35 | 36 | defer func() { 37 | if e := recover(); e != nil { 38 | success = false 39 | err = fmt.Errorf("Cannot send to a closed channel") 40 | matcher.channelClosed = true 41 | } 42 | }() 43 | 44 | winnerIndex, _, _ := reflect.Select([]reflect.SelectCase{ 45 | reflect.SelectCase{Dir: reflect.SelectSend, Chan: channelValue, Send: argValue}, 46 | reflect.SelectCase{Dir: reflect.SelectDefault}, 47 | }) 48 | 49 | var didSend bool 50 | if winnerIndex == 0 { 51 | didSend = true 52 | } 53 | 54 | return didSend, nil 55 | } 56 | 57 | func (matcher *BeSentMatcher) FailureMessage(actual interface{}) (message string) { 58 | return format.Message(actual, "to send:", matcher.Arg) 59 | } 60 | 61 | func (matcher *BeSentMatcher) NegatedFailureMessage(actual interface{}) (message string) { 62 | return format.Message(actual, "not to send:", matcher.Arg) 63 | } 64 | 65 | func (matcher *BeSentMatcher) MatchMayChangeInTheFuture(actual interface{}) bool { 66 | if !isChan(actual) { 67 | return false 68 | } 69 | 70 | return !matcher.channelClosed 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_temporally_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | "time" 7 | ) 8 | 9 | type BeTemporallyMatcher struct { 10 | Comparator string 11 | CompareTo time.Time 12 | Threshold []time.Duration 13 | } 14 | 15 | func (matcher *BeTemporallyMatcher) FailureMessage(actual interface{}) (message string) { 16 | return format.Message(actual, fmt.Sprintf("to be %s", matcher.Comparator), matcher.CompareTo) 17 | } 18 | 19 | func (matcher *BeTemporallyMatcher) NegatedFailureMessage(actual interface{}) (message string) { 20 | return format.Message(actual, fmt.Sprintf("not to be %s", matcher.Comparator), matcher.CompareTo) 21 | } 22 | 23 | func (matcher *BeTemporallyMatcher) Match(actual interface{}) (bool, error) { 24 | // predicate to test for time.Time type 25 | isTime := func(t interface{}) bool { 26 | _, ok := t.(time.Time) 27 | return ok 28 | } 29 | 30 | if !isTime(actual) { 31 | return false, fmt.Errorf("Expected a time.Time. Got:\n%s", format.Object(actual, 1)) 32 | } 33 | 34 | switch matcher.Comparator { 35 | case "==", "~", ">", ">=", "<", "<=": 36 | default: 37 | return false, fmt.Errorf("Unknown comparator: %s", matcher.Comparator) 38 | } 39 | 40 | var threshold = time.Millisecond 41 | if len(matcher.Threshold) == 1 { 42 | threshold = matcher.Threshold[0] 43 | } 44 | 45 | return matcher.matchTimes(actual.(time.Time), matcher.CompareTo, threshold), nil 46 | } 47 | 48 | func (matcher *BeTemporallyMatcher) matchTimes(actual, compareTo time.Time, threshold time.Duration) (success bool) { 49 | switch matcher.Comparator { 50 | case "==": 51 | return actual.Equal(compareTo) 52 | case "~": 53 | diff := actual.Sub(compareTo) 54 | return -threshold <= diff && diff <= threshold 55 | case ">": 56 | return actual.After(compareTo) 57 | case ">=": 58 | return !actual.Before(compareTo) 59 | case "<": 60 | return actual.Before(compareTo) 61 | case "<=": 62 | return !actual.After(compareTo) 63 | } 64 | return false 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_true_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | ) 7 | 8 | type BeTrueMatcher struct { 9 | } 10 | 11 | func (matcher *BeTrueMatcher) Match(actual interface{}) (success bool, err error) { 12 | if !isBool(actual) { 13 | return false, fmt.Errorf("Expected a boolean. Got:\n%s", format.Object(actual, 1)) 14 | } 15 | 16 | return actual.(bool), nil 17 | } 18 | 19 | func (matcher *BeTrueMatcher) FailureMessage(actual interface{}) (message string) { 20 | return format.Message(actual, "to be true") 21 | } 22 | 23 | func (matcher *BeTrueMatcher) NegatedFailureMessage(actual interface{}) (message string) { 24 | return format.Message(actual, "not to be true") 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/be_zero_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "github.com/onsi/gomega/format" 5 | "reflect" 6 | ) 7 | 8 | type BeZeroMatcher struct { 9 | } 10 | 11 | func (matcher *BeZeroMatcher) Match(actual interface{}) (success bool, err error) { 12 | if actual == nil { 13 | return true, nil 14 | } 15 | zeroValue := reflect.Zero(reflect.TypeOf(actual)).Interface() 16 | 17 | return reflect.DeepEqual(zeroValue, actual), nil 18 | 19 | } 20 | 21 | func (matcher *BeZeroMatcher) FailureMessage(actual interface{}) (message string) { 22 | return format.Message(actual, "to be zero-valued") 23 | } 24 | 25 | func (matcher *BeZeroMatcher) NegatedFailureMessage(actual interface{}) (message string) { 26 | return format.Message(actual, "not to be zero-valued") 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/consist_of.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | 7 | "github.com/onsi/gomega/format" 8 | "github.com/onsi/gomega/matchers/support/goraph/bipartitegraph" 9 | ) 10 | 11 | type ConsistOfMatcher struct { 12 | Elements []interface{} 13 | } 14 | 15 | func (matcher *ConsistOfMatcher) Match(actual interface{}) (success bool, err error) { 16 | if !isArrayOrSlice(actual) && !isMap(actual) { 17 | return false, fmt.Errorf("ConsistOf matcher expects an array/slice/map. Got:\n%s", format.Object(actual, 1)) 18 | } 19 | 20 | elements := matcher.Elements 21 | if len(matcher.Elements) == 1 && isArrayOrSlice(matcher.Elements[0]) { 22 | elements = []interface{}{} 23 | value := reflect.ValueOf(matcher.Elements[0]) 24 | for i := 0; i < value.Len(); i++ { 25 | elements = append(elements, value.Index(i).Interface()) 26 | } 27 | } 28 | 29 | matchers := []interface{}{} 30 | for _, element := range elements { 31 | matcher, isMatcher := element.(omegaMatcher) 32 | if !isMatcher { 33 | matcher = &EqualMatcher{Expected: element} 34 | } 35 | matchers = append(matchers, matcher) 36 | } 37 | 38 | values := matcher.valuesOf(actual) 39 | 40 | if len(values) != len(matchers) { 41 | return false, nil 42 | } 43 | 44 | neighbours := func(v, m interface{}) (bool, error) { 45 | match, err := m.(omegaMatcher).Match(v) 46 | return match && err == nil, nil 47 | } 48 | 49 | bipartiteGraph, err := bipartitegraph.NewBipartiteGraph(values, matchers, neighbours) 50 | if err != nil { 51 | return false, err 52 | } 53 | 54 | return len(bipartiteGraph.LargestMatching()) == len(values), nil 55 | } 56 | 57 | func (matcher *ConsistOfMatcher) valuesOf(actual interface{}) []interface{} { 58 | value := reflect.ValueOf(actual) 59 | values := []interface{}{} 60 | if isMap(actual) { 61 | keys := value.MapKeys() 62 | for i := 0; i < value.Len(); i++ { 63 | values = append(values, value.MapIndex(keys[i]).Interface()) 64 | } 65 | } else { 66 | for i := 0; i < value.Len(); i++ { 67 | values = append(values, value.Index(i).Interface()) 68 | } 69 | } 70 | 71 | return values 72 | } 73 | 74 | func (matcher *ConsistOfMatcher) FailureMessage(actual interface{}) (message string) { 75 | return format.Message(actual, "to consist of", matcher.Elements) 76 | } 77 | 78 | func (matcher *ConsistOfMatcher) NegatedFailureMessage(actual interface{}) (message string) { 79 | return format.Message(actual, "not to consist of", matcher.Elements) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/contain_element_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | 7 | "github.com/onsi/gomega/format" 8 | ) 9 | 10 | type ContainElementMatcher struct { 11 | Element interface{} 12 | } 13 | 14 | func (matcher *ContainElementMatcher) Match(actual interface{}) (success bool, err error) { 15 | if !isArrayOrSlice(actual) && !isMap(actual) { 16 | return false, fmt.Errorf("ContainElement matcher expects an array/slice/map. Got:\n%s", format.Object(actual, 1)) 17 | } 18 | 19 | elemMatcher, elementIsMatcher := matcher.Element.(omegaMatcher) 20 | if !elementIsMatcher { 21 | elemMatcher = &EqualMatcher{Expected: matcher.Element} 22 | } 23 | 24 | value := reflect.ValueOf(actual) 25 | var keys []reflect.Value 26 | if isMap(actual) { 27 | keys = value.MapKeys() 28 | } 29 | var lastError error 30 | for i := 0; i < value.Len(); i++ { 31 | var success bool 32 | var err error 33 | if isMap(actual) { 34 | success, err = elemMatcher.Match(value.MapIndex(keys[i]).Interface()) 35 | } else { 36 | success, err = elemMatcher.Match(value.Index(i).Interface()) 37 | } 38 | if err != nil { 39 | lastError = err 40 | continue 41 | } 42 | if success { 43 | return true, nil 44 | } 45 | } 46 | 47 | return false, lastError 48 | } 49 | 50 | func (matcher *ContainElementMatcher) FailureMessage(actual interface{}) (message string) { 51 | return format.Message(actual, "to contain element matching", matcher.Element) 52 | } 53 | 54 | func (matcher *ContainElementMatcher) NegatedFailureMessage(actual interface{}) (message string) { 55 | return format.Message(actual, "not to contain element matching", matcher.Element) 56 | } 57 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/contain_substring_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | "strings" 7 | ) 8 | 9 | type ContainSubstringMatcher struct { 10 | Substr string 11 | Args []interface{} 12 | } 13 | 14 | func (matcher *ContainSubstringMatcher) Match(actual interface{}) (success bool, err error) { 15 | actualString, ok := toString(actual) 16 | if !ok { 17 | return false, fmt.Errorf("ContainSubstring matcher requires a string or stringer. Got:\n%s", format.Object(actual, 1)) 18 | } 19 | 20 | return strings.Contains(actualString, matcher.stringToMatch()), nil 21 | } 22 | 23 | func (matcher *ContainSubstringMatcher) stringToMatch() string { 24 | stringToMatch := matcher.Substr 25 | if len(matcher.Args) > 0 { 26 | stringToMatch = fmt.Sprintf(matcher.Substr, matcher.Args...) 27 | } 28 | return stringToMatch 29 | } 30 | 31 | func (matcher *ContainSubstringMatcher) FailureMessage(actual interface{}) (message string) { 32 | return format.Message(actual, "to contain substring", matcher.stringToMatch()) 33 | } 34 | 35 | func (matcher *ContainSubstringMatcher) NegatedFailureMessage(actual interface{}) (message string) { 36 | return format.Message(actual, "not to contain substring", matcher.stringToMatch()) 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/equal_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | 7 | "github.com/onsi/gomega/format" 8 | ) 9 | 10 | type EqualMatcher struct { 11 | Expected interface{} 12 | } 13 | 14 | func (matcher *EqualMatcher) Match(actual interface{}) (success bool, err error) { 15 | if actual == nil && matcher.Expected == nil { 16 | return false, fmt.Errorf("Refusing to compare to .\nBe explicit and use BeNil() instead. This is to avoid mistakes where both sides of an assertion are erroneously uninitialized.") 17 | } 18 | return reflect.DeepEqual(actual, matcher.Expected), nil 19 | } 20 | 21 | func (matcher *EqualMatcher) FailureMessage(actual interface{}) (message string) { 22 | return format.Message(actual, "to equal", matcher.Expected) 23 | } 24 | 25 | func (matcher *EqualMatcher) NegatedFailureMessage(actual interface{}) (message string) { 26 | return format.Message(actual, "not to equal", matcher.Expected) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/have_cap_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/onsi/gomega/format" 7 | ) 8 | 9 | type HaveCapMatcher struct { 10 | Count int 11 | } 12 | 13 | func (matcher *HaveCapMatcher) Match(actual interface{}) (success bool, err error) { 14 | length, ok := capOf(actual) 15 | if !ok { 16 | return false, fmt.Errorf("HaveCap matcher expects a array/channel/slice. Got:\n%s", format.Object(actual, 1)) 17 | } 18 | 19 | return length == matcher.Count, nil 20 | } 21 | 22 | func (matcher *HaveCapMatcher) FailureMessage(actual interface{}) (message string) { 23 | return fmt.Sprintf("Expected\n%s\nto have capacity %d", format.Object(actual, 1), matcher.Count) 24 | } 25 | 26 | func (matcher *HaveCapMatcher) NegatedFailureMessage(actual interface{}) (message string) { 27 | return fmt.Sprintf("Expected\n%s\nnot to have capacity %d", format.Object(actual, 1), matcher.Count) 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/have_key_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | "reflect" 7 | ) 8 | 9 | type HaveKeyMatcher struct { 10 | Key interface{} 11 | } 12 | 13 | func (matcher *HaveKeyMatcher) Match(actual interface{}) (success bool, err error) { 14 | if !isMap(actual) { 15 | return false, fmt.Errorf("HaveKey matcher expects a map. Got:%s", format.Object(actual, 1)) 16 | } 17 | 18 | keyMatcher, keyIsMatcher := matcher.Key.(omegaMatcher) 19 | if !keyIsMatcher { 20 | keyMatcher = &EqualMatcher{Expected: matcher.Key} 21 | } 22 | 23 | keys := reflect.ValueOf(actual).MapKeys() 24 | for i := 0; i < len(keys); i++ { 25 | success, err := keyMatcher.Match(keys[i].Interface()) 26 | if err != nil { 27 | return false, fmt.Errorf("HaveKey's key matcher failed with:\n%s%s", format.Indent, err.Error()) 28 | } 29 | if success { 30 | return true, nil 31 | } 32 | } 33 | 34 | return false, nil 35 | } 36 | 37 | func (matcher *HaveKeyMatcher) FailureMessage(actual interface{}) (message string) { 38 | switch matcher.Key.(type) { 39 | case omegaMatcher: 40 | return format.Message(actual, "to have key matching", matcher.Key) 41 | default: 42 | return format.Message(actual, "to have key", matcher.Key) 43 | } 44 | } 45 | 46 | func (matcher *HaveKeyMatcher) NegatedFailureMessage(actual interface{}) (message string) { 47 | switch matcher.Key.(type) { 48 | case omegaMatcher: 49 | return format.Message(actual, "not to have key matching", matcher.Key) 50 | default: 51 | return format.Message(actual, "not to have key", matcher.Key) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/have_key_with_value_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | "reflect" 7 | ) 8 | 9 | type HaveKeyWithValueMatcher struct { 10 | Key interface{} 11 | Value interface{} 12 | } 13 | 14 | func (matcher *HaveKeyWithValueMatcher) Match(actual interface{}) (success bool, err error) { 15 | if !isMap(actual) { 16 | return false, fmt.Errorf("HaveKeyWithValue matcher expects a map. Got:%s", format.Object(actual, 1)) 17 | } 18 | 19 | keyMatcher, keyIsMatcher := matcher.Key.(omegaMatcher) 20 | if !keyIsMatcher { 21 | keyMatcher = &EqualMatcher{Expected: matcher.Key} 22 | } 23 | 24 | valueMatcher, valueIsMatcher := matcher.Value.(omegaMatcher) 25 | if !valueIsMatcher { 26 | valueMatcher = &EqualMatcher{Expected: matcher.Value} 27 | } 28 | 29 | keys := reflect.ValueOf(actual).MapKeys() 30 | for i := 0; i < len(keys); i++ { 31 | success, err := keyMatcher.Match(keys[i].Interface()) 32 | if err != nil { 33 | return false, fmt.Errorf("HaveKeyWithValue's key matcher failed with:\n%s%s", format.Indent, err.Error()) 34 | } 35 | if success { 36 | actualValue := reflect.ValueOf(actual).MapIndex(keys[i]) 37 | success, err := valueMatcher.Match(actualValue.Interface()) 38 | if err != nil { 39 | return false, fmt.Errorf("HaveKeyWithValue's value matcher failed with:\n%s%s", format.Indent, err.Error()) 40 | } 41 | return success, nil 42 | } 43 | } 44 | 45 | return false, nil 46 | } 47 | 48 | func (matcher *HaveKeyWithValueMatcher) FailureMessage(actual interface{}) (message string) { 49 | str := "to have {key: value}" 50 | if _, ok := matcher.Key.(omegaMatcher); ok { 51 | str += " matching" 52 | } else if _, ok := matcher.Value.(omegaMatcher); ok { 53 | str += " matching" 54 | } 55 | 56 | expect := make(map[interface{}]interface{}, 1) 57 | expect[matcher.Key] = matcher.Value 58 | return format.Message(actual, str, expect) 59 | } 60 | 61 | func (matcher *HaveKeyWithValueMatcher) NegatedFailureMessage(actual interface{}) (message string) { 62 | kStr := "not to have key" 63 | if _, ok := matcher.Key.(omegaMatcher); ok { 64 | kStr = "not to have key matching" 65 | } 66 | 67 | vStr := "or that key's value not be" 68 | if _, ok := matcher.Value.(omegaMatcher); ok { 69 | vStr = "or to have that key's value not matching" 70 | } 71 | 72 | return format.Message(actual, kStr, matcher.Key, vStr, matcher.Value) 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/have_len_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | ) 7 | 8 | type HaveLenMatcher struct { 9 | Count int 10 | } 11 | 12 | func (matcher *HaveLenMatcher) Match(actual interface{}) (success bool, err error) { 13 | length, ok := lengthOf(actual) 14 | if !ok { 15 | return false, fmt.Errorf("HaveLen matcher expects a string/array/map/channel/slice. Got:\n%s", format.Object(actual, 1)) 16 | } 17 | 18 | return length == matcher.Count, nil 19 | } 20 | 21 | func (matcher *HaveLenMatcher) FailureMessage(actual interface{}) (message string) { 22 | return fmt.Sprintf("Expected\n%s\nto have length %d", format.Object(actual, 1), matcher.Count) 23 | } 24 | 25 | func (matcher *HaveLenMatcher) NegatedFailureMessage(actual interface{}) (message string) { 26 | return fmt.Sprintf("Expected\n%s\nnot to have length %d", format.Object(actual, 1), matcher.Count) 27 | } 28 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/have_occurred_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/onsi/gomega/format" 7 | ) 8 | 9 | type HaveOccurredMatcher struct { 10 | } 11 | 12 | func (matcher *HaveOccurredMatcher) Match(actual interface{}) (success bool, err error) { 13 | // is purely nil? 14 | if actual == nil { 15 | return false, nil 16 | } 17 | 18 | // must be an 'error' type 19 | if !isError(actual) { 20 | return false, fmt.Errorf("Expected an error-type. Got:\n%s", format.Object(actual, 1)) 21 | } 22 | 23 | // must be non-nil (or a pointer to a non-nil) 24 | return !isNil(actual), nil 25 | } 26 | 27 | func (matcher *HaveOccurredMatcher) FailureMessage(actual interface{}) (message string) { 28 | return fmt.Sprintf("Expected an error to have occurred. Got:\n%s", format.Object(actual, 1)) 29 | } 30 | 31 | func (matcher *HaveOccurredMatcher) NegatedFailureMessage(actual interface{}) (message string) { 32 | return fmt.Sprintf("Expected error:\n%s\n%s\n%s", format.Object(actual, 1), format.IndentString(actual.(error).Error(), 1), "not to have occurred") 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/have_prefix_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | ) 7 | 8 | type HavePrefixMatcher struct { 9 | Prefix string 10 | Args []interface{} 11 | } 12 | 13 | func (matcher *HavePrefixMatcher) Match(actual interface{}) (success bool, err error) { 14 | actualString, ok := toString(actual) 15 | if !ok { 16 | return false, fmt.Errorf("HavePrefix matcher requires a string or stringer. Got:\n%s", format.Object(actual, 1)) 17 | } 18 | prefix := matcher.prefix() 19 | return len(actualString) >= len(prefix) && actualString[0:len(prefix)] == prefix, nil 20 | } 21 | 22 | func (matcher *HavePrefixMatcher) prefix() string { 23 | if len(matcher.Args) > 0 { 24 | return fmt.Sprintf(matcher.Prefix, matcher.Args...) 25 | } 26 | return matcher.Prefix 27 | } 28 | 29 | func (matcher *HavePrefixMatcher) FailureMessage(actual interface{}) (message string) { 30 | return format.Message(actual, "to have prefix", matcher.prefix()) 31 | } 32 | 33 | func (matcher *HavePrefixMatcher) NegatedFailureMessage(actual interface{}) (message string) { 34 | return format.Message(actual, "not to have prefix", matcher.prefix()) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/have_suffix_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | ) 7 | 8 | type HaveSuffixMatcher struct { 9 | Suffix string 10 | Args []interface{} 11 | } 12 | 13 | func (matcher *HaveSuffixMatcher) Match(actual interface{}) (success bool, err error) { 14 | actualString, ok := toString(actual) 15 | if !ok { 16 | return false, fmt.Errorf("HaveSuffix matcher requires a string or stringer. Got:\n%s", format.Object(actual, 1)) 17 | } 18 | suffix := matcher.suffix() 19 | return len(actualString) >= len(suffix) && actualString[len(actualString)-len(suffix):] == suffix, nil 20 | } 21 | 22 | func (matcher *HaveSuffixMatcher) suffix() string { 23 | if len(matcher.Args) > 0 { 24 | return fmt.Sprintf(matcher.Suffix, matcher.Args...) 25 | } 26 | return matcher.Suffix 27 | } 28 | 29 | func (matcher *HaveSuffixMatcher) FailureMessage(actual interface{}) (message string) { 30 | return format.Message(actual, "to have suffix", matcher.suffix()) 31 | } 32 | 33 | func (matcher *HaveSuffixMatcher) NegatedFailureMessage(actual interface{}) (message string) { 34 | return format.Message(actual, "not to have suffix", matcher.suffix()) 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/match_error_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | "reflect" 7 | ) 8 | 9 | type MatchErrorMatcher struct { 10 | Expected interface{} 11 | } 12 | 13 | func (matcher *MatchErrorMatcher) Match(actual interface{}) (success bool, err error) { 14 | if isNil(actual) { 15 | return false, fmt.Errorf("Expected an error, got nil") 16 | } 17 | 18 | if !isError(actual) { 19 | return false, fmt.Errorf("Expected an error. Got:\n%s", format.Object(actual, 1)) 20 | } 21 | 22 | actualErr := actual.(error) 23 | 24 | if isString(matcher.Expected) { 25 | return reflect.DeepEqual(actualErr.Error(), matcher.Expected), nil 26 | } 27 | 28 | if isError(matcher.Expected) { 29 | return reflect.DeepEqual(actualErr, matcher.Expected), nil 30 | } 31 | 32 | var subMatcher omegaMatcher 33 | var hasSubMatcher bool 34 | if matcher.Expected != nil { 35 | subMatcher, hasSubMatcher = (matcher.Expected).(omegaMatcher) 36 | if hasSubMatcher { 37 | return subMatcher.Match(actualErr.Error()) 38 | } 39 | } 40 | 41 | return false, fmt.Errorf("MatchError must be passed an error, string, or Matcher that can match on strings. Got:\n%s", format.Object(matcher.Expected, 1)) 42 | } 43 | 44 | func (matcher *MatchErrorMatcher) FailureMessage(actual interface{}) (message string) { 45 | return format.Message(actual, "to match error", matcher.Expected) 46 | } 47 | 48 | func (matcher *MatchErrorMatcher) NegatedFailureMessage(actual interface{}) (message string) { 49 | return format.Message(actual, "not to match error", matcher.Expected) 50 | } 51 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/match_json_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "fmt" 7 | "reflect" 8 | 9 | "github.com/onsi/gomega/format" 10 | ) 11 | 12 | type MatchJSONMatcher struct { 13 | JSONToMatch interface{} 14 | } 15 | 16 | func (matcher *MatchJSONMatcher) Match(actual interface{}) (success bool, err error) { 17 | actualString, expectedString, err := matcher.prettyPrint(actual) 18 | if err != nil { 19 | return false, err 20 | } 21 | 22 | var aval interface{} 23 | var eval interface{} 24 | 25 | // this is guarded by prettyPrint 26 | json.Unmarshal([]byte(actualString), &aval) 27 | json.Unmarshal([]byte(expectedString), &eval) 28 | 29 | return reflect.DeepEqual(aval, eval), nil 30 | } 31 | 32 | func (matcher *MatchJSONMatcher) FailureMessage(actual interface{}) (message string) { 33 | actualString, expectedString, _ := matcher.prettyPrint(actual) 34 | return format.Message(actualString, "to match JSON of", expectedString) 35 | } 36 | 37 | func (matcher *MatchJSONMatcher) NegatedFailureMessage(actual interface{}) (message string) { 38 | actualString, expectedString, _ := matcher.prettyPrint(actual) 39 | return format.Message(actualString, "not to match JSON of", expectedString) 40 | } 41 | 42 | func (matcher *MatchJSONMatcher) prettyPrint(actual interface{}) (actualFormatted, expectedFormatted string, err error) { 43 | actualString, ok := toString(actual) 44 | if !ok { 45 | return "", "", fmt.Errorf("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got actual:\n%s", format.Object(actual, 1)) 46 | } 47 | expectedString, ok := toString(matcher.JSONToMatch) 48 | if !ok { 49 | return "", "", fmt.Errorf("MatchJSONMatcher matcher requires a string, stringer, or []byte. Got expected:\n%s", format.Object(matcher.JSONToMatch, 1)) 50 | } 51 | 52 | abuf := new(bytes.Buffer) 53 | ebuf := new(bytes.Buffer) 54 | 55 | if err := json.Indent(abuf, []byte(actualString), "", " "); err != nil { 56 | return "", "", fmt.Errorf("Actual '%s' should be valid JSON, but it is not.\nUnderlying error:%s", actualString, err) 57 | } 58 | 59 | if err := json.Indent(ebuf, []byte(expectedString), "", " "); err != nil { 60 | return "", "", fmt.Errorf("Expected '%s' should be valid JSON, but it is not.\nUnderlying error:%s", expectedString, err) 61 | } 62 | 63 | return abuf.String(), ebuf.String(), nil 64 | } 65 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/match_regexp_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | "regexp" 7 | ) 8 | 9 | type MatchRegexpMatcher struct { 10 | Regexp string 11 | Args []interface{} 12 | } 13 | 14 | func (matcher *MatchRegexpMatcher) Match(actual interface{}) (success bool, err error) { 15 | actualString, ok := toString(actual) 16 | if !ok { 17 | return false, fmt.Errorf("RegExp matcher requires a string or stringer.\nGot:%s", format.Object(actual, 1)) 18 | } 19 | 20 | match, err := regexp.Match(matcher.regexp(), []byte(actualString)) 21 | if err != nil { 22 | return false, fmt.Errorf("RegExp match failed to compile with error:\n\t%s", err.Error()) 23 | } 24 | 25 | return match, nil 26 | } 27 | 28 | func (matcher *MatchRegexpMatcher) FailureMessage(actual interface{}) (message string) { 29 | return format.Message(actual, "to match regular expression", matcher.regexp()) 30 | } 31 | 32 | func (matcher *MatchRegexpMatcher) NegatedFailureMessage(actual interface{}) (message string) { 33 | return format.Message(actual, "not to match regular expression", matcher.regexp()) 34 | } 35 | 36 | func (matcher *MatchRegexpMatcher) regexp() string { 37 | re := matcher.Regexp 38 | if len(matcher.Args) > 0 { 39 | re = fmt.Sprintf(matcher.Regexp, matcher.Args...) 40 | } 41 | return re 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/match_yaml_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "strings" 7 | 8 | "github.com/onsi/gomega/format" 9 | "gopkg.in/yaml.v2" 10 | ) 11 | 12 | type MatchYAMLMatcher struct { 13 | YAMLToMatch interface{} 14 | } 15 | 16 | func (matcher *MatchYAMLMatcher) Match(actual interface{}) (success bool, err error) { 17 | actualString, expectedString, err := matcher.toStrings(actual) 18 | if err != nil { 19 | return false, err 20 | } 21 | 22 | var aval interface{} 23 | var eval interface{} 24 | 25 | if err := yaml.Unmarshal([]byte(actualString), &aval); err != nil { 26 | return false, fmt.Errorf("Actual '%s' should be valid YAML, but it is not.\nUnderlying error:%s", actualString, err) 27 | } 28 | if err := yaml.Unmarshal([]byte(expectedString), &eval); err != nil { 29 | return false, fmt.Errorf("Expected '%s' should be valid YAML, but it is not.\nUnderlying error:%s", expectedString, err) 30 | } 31 | 32 | return reflect.DeepEqual(aval, eval), nil 33 | } 34 | 35 | func (matcher *MatchYAMLMatcher) FailureMessage(actual interface{}) (message string) { 36 | actualString, expectedString, _ := matcher.toNormalisedStrings(actual) 37 | return format.Message(actualString, "to match YAML of", expectedString) 38 | } 39 | 40 | func (matcher *MatchYAMLMatcher) NegatedFailureMessage(actual interface{}) (message string) { 41 | actualString, expectedString, _ := matcher.toNormalisedStrings(actual) 42 | return format.Message(actualString, "not to match YAML of", expectedString) 43 | } 44 | 45 | func (matcher *MatchYAMLMatcher) toNormalisedStrings(actual interface{}) (actualFormatted, expectedFormatted string, err error) { 46 | actualString, expectedString, err := matcher.toStrings(actual) 47 | return normalise(actualString), normalise(expectedString), err 48 | } 49 | 50 | func normalise(input string) string { 51 | var val interface{} 52 | err := yaml.Unmarshal([]byte(input), &val) 53 | if err != nil { 54 | panic(err) // guarded by Match 55 | } 56 | output, err := yaml.Marshal(val) 57 | if err != nil { 58 | panic(err) // guarded by Unmarshal 59 | } 60 | return strings.TrimSpace(string(output)) 61 | } 62 | 63 | func (matcher *MatchYAMLMatcher) toStrings(actual interface{}) (actualFormatted, expectedFormatted string, err error) { 64 | actualString, ok := toString(actual) 65 | if !ok { 66 | return "", "", fmt.Errorf("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got actual:\n%s", format.Object(actual, 1)) 67 | } 68 | expectedString, ok := toString(matcher.YAMLToMatch) 69 | if !ok { 70 | return "", "", fmt.Errorf("MatchYAMLMatcher matcher requires a string, stringer, or []byte. Got expected:\n%s", format.Object(matcher.YAMLToMatch, 1)) 71 | } 72 | 73 | return actualString, expectedString, nil 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/not.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "github.com/onsi/gomega/internal/oraclematcher" 5 | "github.com/onsi/gomega/types" 6 | ) 7 | 8 | type NotMatcher struct { 9 | Matcher types.GomegaMatcher 10 | } 11 | 12 | func (m *NotMatcher) Match(actual interface{}) (bool, error) { 13 | success, err := m.Matcher.Match(actual) 14 | if err != nil { 15 | return false, err 16 | } 17 | return !success, nil 18 | } 19 | 20 | func (m *NotMatcher) FailureMessage(actual interface{}) (message string) { 21 | return m.Matcher.NegatedFailureMessage(actual) // works beautifully 22 | } 23 | 24 | func (m *NotMatcher) NegatedFailureMessage(actual interface{}) (message string) { 25 | return m.Matcher.FailureMessage(actual) // works beautifully 26 | } 27 | 28 | func (m *NotMatcher) MatchMayChangeInTheFuture(actual interface{}) bool { 29 | return oraclematcher.MatchMayChangeInTheFuture(m.Matcher, actual) // just return m.Matcher's value 30 | } 31 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/or.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/onsi/gomega/format" 7 | "github.com/onsi/gomega/internal/oraclematcher" 8 | "github.com/onsi/gomega/types" 9 | ) 10 | 11 | type OrMatcher struct { 12 | Matchers []types.GomegaMatcher 13 | 14 | // state 15 | firstSuccessfulMatcher types.GomegaMatcher 16 | } 17 | 18 | func (m *OrMatcher) Match(actual interface{}) (success bool, err error) { 19 | m.firstSuccessfulMatcher = nil 20 | for _, matcher := range m.Matchers { 21 | success, err := matcher.Match(actual) 22 | if err != nil { 23 | return false, err 24 | } 25 | if success { 26 | m.firstSuccessfulMatcher = matcher 27 | return true, nil 28 | } 29 | } 30 | return false, nil 31 | } 32 | 33 | func (m *OrMatcher) FailureMessage(actual interface{}) (message string) { 34 | // not the most beautiful list of matchers, but not bad either... 35 | return format.Message(actual, fmt.Sprintf("To satisfy at least one of these matchers: %s", m.Matchers)) 36 | } 37 | 38 | func (m *OrMatcher) NegatedFailureMessage(actual interface{}) (message string) { 39 | return m.firstSuccessfulMatcher.NegatedFailureMessage(actual) 40 | } 41 | 42 | func (m *OrMatcher) MatchMayChangeInTheFuture(actual interface{}) bool { 43 | /* 44 | Example with 3 matchers: A, B, C 45 | 46 | Match evaluates them: F, T, => T 47 | So match is currently T, what should MatchMayChangeInTheFuture() return? 48 | Seems like it only depends on B, since currently B MUST change to allow the result to become F 49 | 50 | Match eval: F, F, F => F 51 | So match is currently F, what should MatchMayChangeInTheFuture() return? 52 | Seems to depend on ANY of them being able to change to T. 53 | */ 54 | 55 | if m.firstSuccessfulMatcher != nil { 56 | // one of the matchers succeeded.. it must be able to change in order to affect the result 57 | return oraclematcher.MatchMayChangeInTheFuture(m.firstSuccessfulMatcher, actual) 58 | } else { 59 | // so all matchers failed.. Any one of them changing would change the result. 60 | for _, matcher := range m.Matchers { 61 | if oraclematcher.MatchMayChangeInTheFuture(matcher, actual) { 62 | return true 63 | } 64 | } 65 | return false // none of were going to change 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/panic_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "github.com/onsi/gomega/format" 6 | "reflect" 7 | ) 8 | 9 | type PanicMatcher struct{} 10 | 11 | func (matcher *PanicMatcher) Match(actual interface{}) (success bool, err error) { 12 | if actual == nil { 13 | return false, fmt.Errorf("PanicMatcher expects a non-nil actual.") 14 | } 15 | 16 | actualType := reflect.TypeOf(actual) 17 | if actualType.Kind() != reflect.Func { 18 | return false, fmt.Errorf("PanicMatcher expects a function. Got:\n%s", format.Object(actual, 1)) 19 | } 20 | if !(actualType.NumIn() == 0 && actualType.NumOut() == 0) { 21 | return false, fmt.Errorf("PanicMatcher expects a function with no arguments and no return value. Got:\n%s", format.Object(actual, 1)) 22 | } 23 | 24 | success = false 25 | defer func() { 26 | if e := recover(); e != nil { 27 | success = true 28 | } 29 | }() 30 | 31 | reflect.ValueOf(actual).Call([]reflect.Value{}) 32 | 33 | return 34 | } 35 | 36 | func (matcher *PanicMatcher) FailureMessage(actual interface{}) (message string) { 37 | return format.Message(actual, "to panic") 38 | } 39 | 40 | func (matcher *PanicMatcher) NegatedFailureMessage(actual interface{}) (message string) { 41 | return format.Message(actual, "not to panic") 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/succeed_matcher.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | 6 | "github.com/onsi/gomega/format" 7 | ) 8 | 9 | type SucceedMatcher struct { 10 | } 11 | 12 | func (matcher *SucceedMatcher) Match(actual interface{}) (success bool, err error) { 13 | // is purely nil? 14 | if actual == nil { 15 | return true, nil 16 | } 17 | 18 | // must be an 'error' type 19 | if !isError(actual) { 20 | return false, fmt.Errorf("Expected an error-type. Got:\n%s", format.Object(actual, 1)) 21 | } 22 | 23 | // must be nil (or a pointer to a nil) 24 | return isNil(actual), nil 25 | } 26 | 27 | func (matcher *SucceedMatcher) FailureMessage(actual interface{}) (message string) { 28 | return fmt.Sprintf("Expected success, but got an error:\n%s\n%s", format.Object(actual, 1), format.IndentString(actual.(error).Error(), 1)) 29 | } 30 | 31 | func (matcher *SucceedMatcher) NegatedFailureMessage(actual interface{}) (message string) { 32 | return "Expected failure, but got no error." 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/support/goraph/bipartitegraph/bipartitegraph.go: -------------------------------------------------------------------------------- 1 | package bipartitegraph 2 | 3 | import "errors" 4 | import "fmt" 5 | 6 | import . "github.com/onsi/gomega/matchers/support/goraph/node" 7 | import . "github.com/onsi/gomega/matchers/support/goraph/edge" 8 | 9 | type BipartiteGraph struct { 10 | Left NodeOrderedSet 11 | Right NodeOrderedSet 12 | Edges EdgeSet 13 | } 14 | 15 | func NewBipartiteGraph(leftValues, rightValues []interface{}, neighbours func(interface{}, interface{}) (bool, error)) (*BipartiteGraph, error) { 16 | left := NodeOrderedSet{} 17 | for i, _ := range leftValues { 18 | left = append(left, Node{i}) 19 | } 20 | 21 | right := NodeOrderedSet{} 22 | for j, _ := range rightValues { 23 | right = append(right, Node{j + len(left)}) 24 | } 25 | 26 | edges := EdgeSet{} 27 | for i, leftValue := range leftValues { 28 | for j, rightValue := range rightValues { 29 | neighbours, err := neighbours(leftValue, rightValue) 30 | if err != nil { 31 | return nil, errors.New(fmt.Sprintf("error determining adjacency for %v and %v: %s", leftValue, rightValue, err.Error())) 32 | } 33 | 34 | if neighbours { 35 | edges = append(edges, Edge{left[i], right[j]}) 36 | } 37 | } 38 | } 39 | 40 | return &BipartiteGraph{left, right, edges}, nil 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/support/goraph/edge/edge.go: -------------------------------------------------------------------------------- 1 | package edge 2 | 3 | import . "github.com/onsi/gomega/matchers/support/goraph/node" 4 | 5 | type Edge struct { 6 | Node1 Node 7 | Node2 Node 8 | } 9 | 10 | type EdgeSet []Edge 11 | 12 | func (ec EdgeSet) Free(node Node) bool { 13 | for _, e := range ec { 14 | if e.Node1 == node || e.Node2 == node { 15 | return false 16 | } 17 | } 18 | 19 | return true 20 | } 21 | 22 | func (ec EdgeSet) Contains(edge Edge) bool { 23 | for _, e := range ec { 24 | if e == edge { 25 | return true 26 | } 27 | } 28 | 29 | return false 30 | } 31 | 32 | func (ec EdgeSet) FindByNodes(node1, node2 Node) (Edge, bool) { 33 | for _, e := range ec { 34 | if (e.Node1 == node1 && e.Node2 == node2) || (e.Node1 == node2 && e.Node2 == node1) { 35 | return e, true 36 | } 37 | } 38 | 39 | return Edge{}, false 40 | } 41 | 42 | func (ec EdgeSet) SymmetricDifference(ec2 EdgeSet) EdgeSet { 43 | edgesToInclude := make(map[Edge]bool) 44 | 45 | for _, e := range ec { 46 | edgesToInclude[e] = true 47 | } 48 | 49 | for _, e := range ec2 { 50 | edgesToInclude[e] = !edgesToInclude[e] 51 | } 52 | 53 | result := EdgeSet{} 54 | for e, include := range edgesToInclude { 55 | if include { 56 | result = append(result, e) 57 | } 58 | } 59 | 60 | return result 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/support/goraph/node/node.go: -------------------------------------------------------------------------------- 1 | package node 2 | 3 | type Node struct { 4 | Id int 5 | } 6 | 7 | type NodeOrderedSet []Node 8 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/support/goraph/util/util.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import "math" 4 | 5 | func Odd(n int) bool { 6 | return math.Mod(float64(n), 2.0) == 1.0 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/matchers/with_transform.go: -------------------------------------------------------------------------------- 1 | package matchers 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | 7 | "github.com/onsi/gomega/internal/oraclematcher" 8 | "github.com/onsi/gomega/types" 9 | ) 10 | 11 | type WithTransformMatcher struct { 12 | // input 13 | Transform interface{} // must be a function of one parameter that returns one value 14 | Matcher types.GomegaMatcher 15 | 16 | // cached value 17 | transformArgType reflect.Type 18 | 19 | // state 20 | transformedValue interface{} 21 | } 22 | 23 | func NewWithTransformMatcher(transform interface{}, matcher types.GomegaMatcher) *WithTransformMatcher { 24 | if transform == nil { 25 | panic("transform function cannot be nil") 26 | } 27 | txType := reflect.TypeOf(transform) 28 | if txType.NumIn() != 1 { 29 | panic("transform function must have 1 argument") 30 | } 31 | if txType.NumOut() != 1 { 32 | panic("transform function must have 1 return value") 33 | } 34 | 35 | return &WithTransformMatcher{ 36 | Transform: transform, 37 | Matcher: matcher, 38 | transformArgType: reflect.TypeOf(transform).In(0), 39 | } 40 | } 41 | 42 | func (m *WithTransformMatcher) Match(actual interface{}) (bool, error) { 43 | // return error if actual's type is incompatible with Transform function's argument type 44 | actualType := reflect.TypeOf(actual) 45 | if !actualType.AssignableTo(m.transformArgType) { 46 | return false, fmt.Errorf("Transform function expects '%s' but we have '%s'", m.transformArgType, actualType) 47 | } 48 | 49 | // call the Transform function with `actual` 50 | fn := reflect.ValueOf(m.Transform) 51 | result := fn.Call([]reflect.Value{reflect.ValueOf(actual)}) 52 | m.transformedValue = result[0].Interface() // expect exactly one value 53 | 54 | return m.Matcher.Match(m.transformedValue) 55 | } 56 | 57 | func (m *WithTransformMatcher) FailureMessage(_ interface{}) (message string) { 58 | return m.Matcher.FailureMessage(m.transformedValue) 59 | } 60 | 61 | func (m *WithTransformMatcher) NegatedFailureMessage(_ interface{}) (message string) { 62 | return m.Matcher.NegatedFailureMessage(m.transformedValue) 63 | } 64 | 65 | func (m *WithTransformMatcher) MatchMayChangeInTheFuture(_ interface{}) bool { 66 | // TODO: Maybe this should always just return true? (Only an issue for non-deterministic transformers.) 67 | // 68 | // Querying the next matcher is fine if the transformer always will return the same value. 69 | // But if the transformer is non-deterministic and returns a different value each time, then there 70 | // is no point in querying the next matcher, since it can only comment on the last transformed value. 71 | return oraclematcher.MatchMayChangeInTheFuture(m.Matcher, m.transformedValue) 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/onsi/gomega/types/types.go: -------------------------------------------------------------------------------- 1 | package types 2 | 3 | type GomegaFailHandler func(message string, callerSkip ...int) 4 | 5 | //A simple *testing.T interface wrapper 6 | type GomegaTestingT interface { 7 | Errorf(format string, args ...interface{}) 8 | } 9 | 10 | //All Gomega matchers must implement the GomegaMatcher interface 11 | // 12 | //For details on writing custom matchers, check out: http://onsi.github.io/gomega/#adding_your_own_matchers 13 | type GomegaMatcher interface { 14 | Match(actual interface{}) (success bool, err error) 15 | FailureMessage(actual interface{}) (message string) 16 | NegatedFailureMessage(actual interface{}) (message string) 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Jeremy Saenz & Contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | 3 | os: Windows Server 2012 R2 4 | 5 | clone_folder: c:\gopath\src\github.com\urfave\cli 6 | 7 | environment: 8 | GOPATH: C:\gopath 9 | GOVERSION: 1.6 10 | PYTHON: C:\Python27-x64 11 | PYTHON_VERSION: 2.7.x 12 | PYTHON_ARCH: 64 13 | 14 | install: 15 | - set PATH=%GOPATH%\bin;C:\go\bin;%PATH% 16 | - go version 17 | - go env 18 | - go get github.com/urfave/gfmrun/... 19 | - go get -v -t ./... 20 | 21 | build_script: 22 | - python runtests vet 23 | - python runtests test 24 | - python runtests gfmrun 25 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/category.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // CommandCategories is a slice of *CommandCategory. 4 | type CommandCategories []*CommandCategory 5 | 6 | // CommandCategory is a category containing commands. 7 | type CommandCategory struct { 8 | Name string 9 | Commands Commands 10 | } 11 | 12 | func (c CommandCategories) Less(i, j int) bool { 13 | return c[i].Name < c[j].Name 14 | } 15 | 16 | func (c CommandCategories) Len() int { 17 | return len(c) 18 | } 19 | 20 | func (c CommandCategories) Swap(i, j int) { 21 | c[i], c[j] = c[j], c[i] 22 | } 23 | 24 | // AddCommand adds a command to a category. 25 | func (c CommandCategories) AddCommand(category string, command Command) CommandCategories { 26 | for _, commandCategory := range c { 27 | if commandCategory.Name == category { 28 | commandCategory.Commands = append(commandCategory.Commands, command) 29 | return c 30 | } 31 | } 32 | return append(c, &CommandCategory{Name: category, Commands: []Command{command}}) 33 | } 34 | 35 | // VisibleCommands returns a slice of the Commands with Hidden=false 36 | func (c *CommandCategory) VisibleCommands() []Command { 37 | ret := []Command{} 38 | for _, command := range c.Commands { 39 | if !command.Hidden { 40 | ret = append(ret, command) 41 | } 42 | } 43 | return ret 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/cli.go: -------------------------------------------------------------------------------- 1 | // Package cli provides a minimal framework for creating and organizing command line 2 | // Go applications. cli is designed to be easy to understand and write, the most simple 3 | // cli application can be written as follows: 4 | // func main() { 5 | // cli.NewApp().Run(os.Args) 6 | // } 7 | // 8 | // Of course this application does not do much, so let's make this an actual application: 9 | // func main() { 10 | // app := cli.NewApp() 11 | // app.Name = "greet" 12 | // app.Usage = "say a greeting" 13 | // app.Action = func(c *cli.Context) error { 14 | // println("Greetings") 15 | // } 16 | // 17 | // app.Run(os.Args) 18 | // } 19 | package cli 20 | 21 | //go:generate python ./generate-flag-types cli -i flag-types.json -o flag_generated.go 22 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/flag-types.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "Bool", 4 | "type": "bool", 5 | "value": false, 6 | "context_default": "false", 7 | "parser": "strconv.ParseBool(f.Value.String())" 8 | }, 9 | { 10 | "name": "BoolT", 11 | "type": "bool", 12 | "value": false, 13 | "doctail": " that is true by default", 14 | "context_default": "false", 15 | "parser": "strconv.ParseBool(f.Value.String())" 16 | }, 17 | { 18 | "name": "Duration", 19 | "type": "time.Duration", 20 | "doctail": " (see https://golang.org/pkg/time/#ParseDuration)", 21 | "context_default": "0", 22 | "parser": "time.ParseDuration(f.Value.String())" 23 | }, 24 | { 25 | "name": "Float64", 26 | "type": "float64", 27 | "context_default": "0", 28 | "parser": "strconv.ParseFloat(f.Value.String(), 64)" 29 | }, 30 | { 31 | "name": "Generic", 32 | "type": "Generic", 33 | "dest": false, 34 | "context_default": "nil", 35 | "context_type": "interface{}" 36 | }, 37 | { 38 | "name": "Int64", 39 | "type": "int64", 40 | "context_default": "0", 41 | "parser": "strconv.ParseInt(f.Value.String(), 0, 64)" 42 | }, 43 | { 44 | "name": "Int", 45 | "type": "int", 46 | "context_default": "0", 47 | "parser": "strconv.ParseInt(f.Value.String(), 0, 64)", 48 | "parser_cast": "int(parsed)" 49 | }, 50 | { 51 | "name": "IntSlice", 52 | "type": "*IntSlice", 53 | "dest": false, 54 | "context_default": "nil", 55 | "context_type": "[]int", 56 | "parser": "(f.Value.(*IntSlice)).Value(), error(nil)" 57 | }, 58 | { 59 | "name": "Int64Slice", 60 | "type": "*Int64Slice", 61 | "dest": false, 62 | "context_default": "nil", 63 | "context_type": "[]int64", 64 | "parser": "(f.Value.(*Int64Slice)).Value(), error(nil)" 65 | }, 66 | { 67 | "name": "String", 68 | "type": "string", 69 | "context_default": "\"\"", 70 | "parser": "f.Value.String(), error(nil)" 71 | }, 72 | { 73 | "name": "StringSlice", 74 | "type": "*StringSlice", 75 | "dest": false, 76 | "context_default": "nil", 77 | "context_type": "[]string", 78 | "parser": "(f.Value.(*StringSlice)).Value(), error(nil)" 79 | }, 80 | { 81 | "name": "Uint64", 82 | "type": "uint64", 83 | "context_default": "0", 84 | "parser": "strconv.ParseUint(f.Value.String(), 0, 64)" 85 | }, 86 | { 87 | "name": "Uint", 88 | "type": "uint", 89 | "context_default": "0", 90 | "parser": "strconv.ParseUint(f.Value.String(), 0, 64)", 91 | "parser_cast": "uint(parsed)" 92 | } 93 | ] 94 | -------------------------------------------------------------------------------- /vendor/github.com/urfave/cli/funcs.go: -------------------------------------------------------------------------------- 1 | package cli 2 | 3 | // BashCompleteFunc is an action to execute when the bash-completion flag is set 4 | type BashCompleteFunc func(*Context) 5 | 6 | // BeforeFunc is an action to execute before any subcommands are run, but after 7 | // the context is ready if a non-nil error is returned, no subcommands are run 8 | type BeforeFunc func(*Context) error 9 | 10 | // AfterFunc is an action to execute after any subcommands are run, but after the 11 | // subcommand has finished it is run even if Action() panics 12 | type AfterFunc func(*Context) error 13 | 14 | // ActionFunc is the action to execute when no subcommands are specified 15 | type ActionFunc func(*Context) error 16 | 17 | // CommandNotFoundFunc is executed if the proper command cannot be found 18 | type CommandNotFoundFunc func(*Context, string) 19 | 20 | // OnUsageErrorFunc is executed if an usage error occurs. This is useful for displaying 21 | // customized usage error messages. This function is able to replace the 22 | // original error messages. If this function is not set, the "Incorrect usage" 23 | // is displayed and the execution is interrupted. 24 | type OnUsageErrorFunc func(context *Context, err error, isSubcommand bool) error 25 | 26 | // FlagStringFunc is used by the help generation to display a flag, which is 27 | // expected to be a single line. 28 | type FlagStringFunc func(Flag) string 29 | -------------------------------------------------------------------------------- /vendor/github.com/vmware/photon-controller-go-sdk/SSPI/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /vendor/github.com/vmware/photon-controller-go-sdk/SSPI/README.md: -------------------------------------------------------------------------------- 1 | SSPI implementation in this directory is taken from https://github.com/WillHipschman/sspi-prototype (git commit: 4feee8f2e75857bb51345fdfc8e3c091edc959b4) 2 | Implementation is modified to make sure that it only compiles on Windows. 3 | For non-Windows platforms, please look at sspi_unspported.go 4 | -------------------------------------------------------------------------------- /vendor/github.com/vmware/photon-controller-go-sdk/SSPI/sspi_unsupported.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | // +build !windows 11 | 12 | package SSPI 13 | -------------------------------------------------------------------------------- /vendor/github.com/vmware/photon-controller-go-sdk/photon/datastores.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package photon 11 | 12 | import ( 13 | "encoding/json" 14 | ) 15 | 16 | // DatastoresAPI is used by the client 17 | type DatastoresAPI struct { 18 | client *Client 19 | } 20 | 21 | var datastoresURL = rootUrl + "/infrastructure/datastores" 22 | 23 | // GetAll returns all datastores; requires system administrator privileges 24 | func (api *DatastoresAPI) GetAll() (result *Datastores, err error) { 25 | res, err := api.client.restClient.Get(api.client.Endpoint+datastoresURL, api.client.options.TokenOptions) 26 | if err != nil { 27 | return 28 | } 29 | defer res.Body.Close() 30 | res, err = getError(res) 31 | if err != nil { 32 | return 33 | } 34 | result = &Datastores{} 35 | err = json.NewDecoder(res.Body).Decode(result) 36 | return result, err 37 | } 38 | 39 | // Get returns a single datastore with the specified ID; requires system administrator privileges 40 | func (api *DatastoresAPI) Get(id string) (datastore *Datastore, err error) { 41 | res, err := api.client.restClient.Get(api.client.Endpoint+datastoresURL+"/"+id, api.client.options.TokenOptions) 42 | if err != nil { 43 | return 44 | } 45 | defer res.Body.Close() 46 | res, err = getError(res) 47 | if err != nil { 48 | return 49 | } 50 | var result Datastore 51 | err = json.NewDecoder(res.Body).Decode(&result) 52 | return &result, err 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/vmware/photon-controller-go-sdk/photon/disks.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package photon 11 | 12 | import ( 13 | "encoding/json" 14 | ) 15 | 16 | // Contains functionality for disks API. 17 | type DisksAPI struct { 18 | client *Client 19 | } 20 | 21 | var diskUrl string = rootUrl + "/disks/" 22 | 23 | // Gets a PersistentDisk for the disk with specified ID. 24 | func (api *DisksAPI) Get(diskID string) (disk *PersistentDisk, err error) { 25 | res, err := api.client.restClient.Get(api.client.Endpoint+diskUrl+diskID, api.client.options.TokenOptions) 26 | if err != nil { 27 | return 28 | } 29 | defer res.Body.Close() 30 | res, err = getError(res) 31 | if err != nil { 32 | return 33 | } 34 | disk = &PersistentDisk{} 35 | err = json.NewDecoder(res.Body).Decode(disk) 36 | return 37 | } 38 | 39 | // Deletes a disk with the specified ID. 40 | func (api *DisksAPI) Delete(diskID string) (task *Task, err error) { 41 | res, err := api.client.restClient.Delete(api.client.Endpoint+diskUrl+diskID, api.client.options.TokenOptions) 42 | if err != nil { 43 | return 44 | } 45 | defer res.Body.Close() 46 | task, err = getTask(getError(res)) 47 | return 48 | } 49 | 50 | // Gets all tasks with the specified disk ID, using options to filter the results. 51 | // If options is nil, no filtering will occur. 52 | func (api *DisksAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) { 53 | uri := api.client.Endpoint + diskUrl + id + "/tasks" 54 | if options != nil { 55 | uri += getQueryString(options) 56 | } 57 | res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) 58 | if err != nil { 59 | return 60 | } 61 | 62 | result = &TaskList{} 63 | err = json.Unmarshal(res, result) 64 | return 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/vmware/photon-controller-go-sdk/photon/hosts.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package photon 11 | 12 | import ( 13 | "bytes" 14 | "encoding/json" 15 | ) 16 | 17 | // Contains functionality for hosts API. 18 | type HostsAPI struct { 19 | client *Client 20 | } 21 | 22 | var hostUrl string = rootUrl + "/infrastructure/hosts" 23 | 24 | // Sets host's availability zone. 25 | func (api *HostsAPI) SetAvailabilityZone(id string, availabilityZone *HostSetAvailabilityZoneOperation) (task *Task, err error) { 26 | body, err := json.Marshal(availabilityZone) 27 | if err != nil { 28 | return 29 | } 30 | 31 | res, err := api.client.restClient.Post( 32 | api.client.Endpoint+hostUrl+"/"+id+"/set_availability_zone", 33 | "application/json", 34 | bytes.NewReader(body), 35 | api.client.options.TokenOptions) 36 | 37 | if err != nil { 38 | return 39 | } 40 | 41 | defer res.Body.Close() 42 | task, err = getTask(getError(res)) 43 | return 44 | } 45 | 46 | // Gets all tasks with the specified host ID, using options to filter the results. 47 | // If options is nil, no filtering will occur. 48 | func (api *HostsAPI) GetTasks(id string, options *TaskGetOptions) (result *TaskList, err error) { 49 | uri := api.client.Endpoint + hostUrl + "/" + id + "/tasks" 50 | if options != nil { 51 | uri += getQueryString(options) 52 | } 53 | res, err := api.client.restClient.GetList(api.client.Endpoint, uri, api.client.options.TokenOptions) 54 | if err != nil { 55 | return 56 | } 57 | 58 | result = &TaskList{} 59 | err = json.Unmarshal(res, result) 60 | return 61 | } 62 | 63 | // provision the host with the specified id 64 | func (api *HostsAPI) Provision(id string) (task *Task, err error) { 65 | body := []byte{} 66 | res, err := api.client.restClient.Post( 67 | api.client.Endpoint+hostUrl+"/"+id+"/provision", 68 | "application/json", 69 | bytes.NewReader(body), 70 | api.client.options.TokenOptions) 71 | if err != nil { 72 | return 73 | } 74 | defer res.Body.Close() 75 | task, err = getTask(getError(res)) 76 | return 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/vmware/photon-controller-go-sdk/photon/info.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package photon 11 | 12 | import ( 13 | "encoding/json" 14 | ) 15 | 16 | type InfoAPI struct { 17 | client *Client 18 | } 19 | 20 | var infoUrl = rootUrl + "/info" 21 | 22 | // Get info 23 | func (api *InfoAPI) Get() (info *Info, err error) { 24 | res, err := api.client.restClient.Get(api.client.Endpoint+infoUrl, api.client.options.TokenOptions) 25 | if err != nil { 26 | return 27 | } 28 | 29 | defer res.Body.Close() 30 | 31 | res, err = getError(res) 32 | if err != nil { 33 | return 34 | } 35 | 36 | info = new(Info) 37 | err = json.NewDecoder(res.Body).Decode(info) 38 | return 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/vmware/photon-controller-go-sdk/photon/infrastructure.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | package photon 11 | 12 | import ( 13 | "bytes" 14 | "encoding/json" 15 | ) 16 | 17 | // Contains functionality for Infrastructure API. 18 | type InfraAPI struct { 19 | client *Client 20 | } 21 | 22 | var infraUrl string = rootUrl + "/infrastructure" 23 | 24 | // Synchronizes hosts configurations 25 | func (api *InfraAPI) SyncHostsConfig() (task *Task, err error) { 26 | res, err := api.client.restClient.Post( 27 | api.client.Endpoint+infraUrl+"/sync-hosts-config", 28 | "application/json", 29 | bytes.NewReader([]byte("")), 30 | api.client.options.TokenOptions) 31 | if err != nil { 32 | return 33 | } 34 | defer res.Body.Close() 35 | 36 | task, err = getTask(getError(res)) 37 | return 38 | } 39 | 40 | // Set image datastores. 41 | func (api *InfraAPI) SetImageDatastores(imageDatastores *ImageDatastores) (task *Task, err error) { 42 | body, err := json.Marshal(imageDatastores) 43 | if err != nil { 44 | return 45 | } 46 | 47 | res, err := api.client.restClient.Post( 48 | api.client.Endpoint+infraUrl+"/image-datastores", 49 | "application/json", 50 | bytes.NewReader(body), 51 | api.client.options.TokenOptions) 52 | if err != nil { 53 | return 54 | } 55 | defer res.Body.Close() 56 | 57 | task, err = getTask(getError(res)) 58 | return 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/jwttoken.go: -------------------------------------------------------------------------------- 1 | package lightwave 2 | 3 | import ( 4 | "encoding/base64" 5 | "encoding/json" 6 | "strings" 7 | ) 8 | 9 | type JWTToken struct { 10 | TokenId string `json:"jti"` 11 | Algorithm string `json:"alg"` 12 | Subject string `json:"sub"` 13 | Audience []string `json:"aud"` 14 | Groups []string `json:"groups"` 15 | Issuer string `json:"iss"` 16 | IssuedAt int64 `json:"iat"` 17 | Expires int64 `json:"exp"` 18 | Scope string `json:"scope"` 19 | TokenType string `json:"token_type"` 20 | TokenClass string `json:"token_class"` 21 | Tenant string `json:"tenant"` 22 | // It's possible to have more fields depending on how Lightwave defines the token. 23 | // This covers all the fields we currently have. 24 | } 25 | 26 | // A JSON web token is a set of Base64 encoded strings separated by a period (.) 27 | // When decoded, it will either be JSON text or a signature 28 | // Here we decode the strings into a single token structure. We do not parse the signature. 29 | func ParseTokenDetails(token string) (jwtToken *JWTToken) { 30 | jwtToken = &JWTToken{} 31 | 32 | chunks := strings.Split(token, ".") 33 | for _, chunk := range chunks { 34 | json_string, err := base64.RawURLEncoding.DecodeString(chunk) 35 | if err == nil { 36 | // Ignore errors. We expect that the signature is not JSON, 37 | // so unmarshalling it will fail. That's fine. We'll extract 38 | // all the data we can. 39 | _ = json.Unmarshal(json_string, &jwtToken) 40 | } 41 | } 42 | 43 | return jwtToken 44 | } 45 | 46 | // A JSON web token is a set of Base64 encoded strings separated by a period (.) 47 | // When decoded, it will either be JSON text or a signature 48 | // Here we parse the full JSON text. We do not parse the signature. 49 | func ParseRawTokenDetails(token string) (jwtToken []string, err error) { 50 | chunks := strings.Split(token, ".") 51 | for _, chunk := range chunks { 52 | jsonString, err := base64.RawURLEncoding.DecodeString(chunk) 53 | if err == nil { 54 | jwtToken = append(jwtToken, string(jsonString)) 55 | } 56 | } 57 | 58 | return jwtToken, err 59 | } 60 | -------------------------------------------------------------------------------- /vendor/github.com/vmware/photon-controller-go-sdk/photon/lightwave/oidcclient_sspi_unsupported.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2017 VMware, Inc. All Rights Reserved. 2 | // 3 | // This product is licensed to you under the Apache License, Version 2.0 (the "License"). 4 | // You may not use this product except in compliance with the License. 5 | // 6 | // This product may include a number of subcomponents with separate copyright notices and 7 | // license terms. Your use of these subcomponents is subject to the terms and conditions 8 | // of the subcomponent's license, as noted in the LICENSE file. 9 | 10 | // +build !windows 11 | 12 | package lightwave 13 | 14 | import "errors" 15 | 16 | func (client *OIDCClient) GetTokensFromWindowsLogInContext() (tokens *OIDCTokenResponse, err error) { 17 | return nil, errors.New("Not supported on this OS") 18 | } 19 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_bsd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd netbsd openbsd 6 | 7 | package terminal 8 | 9 | import "syscall" 10 | 11 | const ioctlReadTermios = syscall.TIOCGETA 12 | const ioctlWriteTermios = syscall.TIOCSETA 13 | -------------------------------------------------------------------------------- /vendor/golang.org/x/crypto/ssh/terminal/util_linux.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package terminal 6 | 7 | // These constants are declared here, rather than importing 8 | // them from the syscall package as some syscall packages, even 9 | // on linux, for example gccgo, do not declare them. 10 | const ioctlReadTermios = 0x5401 // syscall.TCGETS 11 | const ioctlWriteTermios = 0x5402 // syscall.TCSETS 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2009 The Go Authors. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | * Neither the name of Google Inc. nor the names of its 14 | contributors may be used to endorse or promote products derived from 15 | this software without specific prior written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/PATENTS: -------------------------------------------------------------------------------- 1 | Additional IP Rights Grant (Patents) 2 | 3 | "This implementation" means the copyrightable works distributed by 4 | Google as part of the Go project. 5 | 6 | Google hereby grants to You a perpetual, worldwide, non-exclusive, 7 | no-charge, royalty-free, irrevocable (except as stated in this section) 8 | patent license to make, have made, use, offer to sell, sell, import, 9 | transfer and otherwise run, modify and propagate the contents of this 10 | implementation of Go, where such license applies only to those patent 11 | claims, both currently owned or controlled by Google and acquired in 12 | the future, licensable by Google that are necessarily infringed by this 13 | implementation of Go. This grant does not include claims that would be 14 | infringed only as a consequence of further modification of this 15 | implementation. If you or your agent or exclusive licensee institute or 16 | order or agree to the institution of patent litigation against any 17 | entity (including a cross-claim or counterclaim in a lawsuit) alleging 18 | that this implementation of Go or any code incorporated within this 19 | implementation of Go constitutes direct or contributory patent 20 | infringement, or inducement of patent infringement, then any patent 21 | rights granted to you under this License for this implementation of Go 22 | shall terminate as of the date such litigation is filed. 23 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | TEXT ·use(SB),NOSPLIT,$0 10 | RET 11 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, Darwin 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for ARM, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-28 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_darwin_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | // +build arm64,darwin 7 | 8 | #include "textflag.h" 9 | 10 | // 11 | // System call support for AMD64, Darwin 12 | // 13 | 14 | // Just jump to package syscall's implementation for all these functions. 15 | // The runtime may know about them. 16 | 17 | TEXT ·Syscall(SB),NOSPLIT,$0-56 18 | B syscall·Syscall(SB) 19 | 20 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 21 | B syscall·Syscall6(SB) 22 | 23 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 24 | B syscall·Syscall9(SB) 25 | 26 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 27 | B syscall·RawSyscall(SB) 28 | 29 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 30 | B syscall·RawSyscall6(SB) 31 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-32 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-44 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-56 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-32 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-44 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_dragonfly_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, DragonFly 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-64 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-88 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-112 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-64 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-88 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_freebsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, FreeBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for 386, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·socketcall(SB),NOSPLIT,$0-36 29 | JMP syscall·socketcall(SB) 30 | 31 | TEXT ·rawsocketcall(SB),NOSPLIT,$0-36 32 | JMP syscall·rawsocketcall(SB) 33 | 34 | TEXT ·seek(SB),NOSPLIT,$0-28 35 | JMP syscall·seek(SB) 36 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for AMD64, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 23 | JMP syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 26 | JMP syscall·RawSyscall6(SB) 27 | 28 | TEXT ·gettimeofday(SB),NOSPLIT,$0-16 29 | JMP syscall·gettimeofday(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for arm, Linux 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 23 | B syscall·RawSyscall(SB) 24 | 25 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 26 | B syscall·RawSyscall6(SB) 27 | 28 | TEXT ·seek(SB),NOSPLIT,$0-32 29 | B syscall·seek(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_arm64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build arm64 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // Just jump to package syscall's implementation for all these functions. 12 | // The runtime may know about them. 13 | 14 | TEXT ·Syscall(SB),NOSPLIT,$0-56 15 | B syscall·Syscall(SB) 16 | 17 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 18 | B syscall·Syscall6(SB) 19 | 20 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 21 | B syscall·RawSyscall(SB) 22 | 23 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 24 | B syscall·RawSyscall6(SB) 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_linux_ppc64x.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build linux 6 | // +build ppc64 ppc64le 7 | // +build !gccgo 8 | 9 | #include "textflag.h" 10 | 11 | // 12 | // System calls for ppc64, Linux 13 | // 14 | 15 | // Just jump to package syscall's implementation for all these functions. 16 | // The runtime may know about them. 17 | 18 | TEXT ·Syscall(SB),NOSPLIT,$0-56 19 | BR syscall·Syscall(SB) 20 | 21 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 22 | BR syscall·Syscall6(SB) 23 | 24 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 25 | BR syscall·RawSyscall(SB) 26 | 27 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 28 | BR syscall·RawSyscall6(SB) 29 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_netbsd_arm.s: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for ARM, NetBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | B syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | B syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | B syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | B syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | B syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_386.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for 386, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-28 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-40 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-52 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-28 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-40 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_openbsd_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System call support for AMD64, OpenBSD 11 | // 12 | 13 | // Just jump to package syscall's implementation for all these functions. 14 | // The runtime may know about them. 15 | 16 | TEXT ·Syscall(SB),NOSPLIT,$0-56 17 | JMP syscall·Syscall(SB) 18 | 19 | TEXT ·Syscall6(SB),NOSPLIT,$0-80 20 | JMP syscall·Syscall6(SB) 21 | 22 | TEXT ·Syscall9(SB),NOSPLIT,$0-104 23 | JMP syscall·Syscall9(SB) 24 | 25 | TEXT ·RawSyscall(SB),NOSPLIT,$0-56 26 | JMP syscall·RawSyscall(SB) 27 | 28 | TEXT ·RawSyscall6(SB),NOSPLIT,$0-80 29 | JMP syscall·RawSyscall6(SB) 30 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/asm_solaris_amd64.s: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build !gccgo 6 | 7 | #include "textflag.h" 8 | 9 | // 10 | // System calls for amd64, Solaris are implemented in runtime/syscall_solaris.go 11 | // 12 | 13 | TEXT ·sysvicall6(SB),NOSPLIT,$0-64 14 | JMP syscall·sysvicall6(SB) 15 | 16 | TEXT ·rawSysvicall6(SB),NOSPLIT,$0-64 17 | JMP syscall·rawSysvicall6(SB) 18 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/constants.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | package unix 8 | 9 | const ( 10 | R_OK = 0x4 11 | W_OK = 0x2 12 | X_OK = 0x1 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unix.go: -------------------------------------------------------------------------------- 1 | // Copyright 2010 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Unix environment variables. 8 | 9 | package unix 10 | 11 | import "syscall" 12 | 13 | func Getenv(key string) (value string, found bool) { 14 | return syscall.Getenv(key) 15 | } 16 | 17 | func Setenv(key, value string) error { 18 | return syscall.Setenv(key, value) 19 | } 20 | 21 | func Clearenv() { 22 | syscall.Clearenv() 23 | } 24 | 25 | func Environ() []string { 26 | return syscall.Environ() 27 | } 28 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/env_unset.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build go1.4 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | func Unsetenv(key string) error { 12 | // This was added in Go 1.4. 13 | return syscall.Unsetenv(key) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock.go: -------------------------------------------------------------------------------- 1 | // +build linux darwin freebsd openbsd netbsd dragonfly 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | // +build darwin dragonfly freebsd linux netbsd openbsd 8 | 9 | package unix 10 | 11 | import "unsafe" 12 | 13 | // fcntl64Syscall is usually SYS_FCNTL, but is overridden on 32-bit Linux 14 | // systems by flock_linux_32bit.go to be SYS_FCNTL64. 15 | var fcntl64Syscall uintptr = SYS_FCNTL 16 | 17 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. 18 | func FcntlFlock(fd uintptr, cmd int, lk *Flock_t) error { 19 | _, _, errno := Syscall(fcntl64Syscall, fd, uintptr(cmd), uintptr(unsafe.Pointer(lk))) 20 | if errno == 0 { 21 | return nil 22 | } 23 | return errno 24 | } 25 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/flock_linux_32bit.go: -------------------------------------------------------------------------------- 1 | // +build linux,386 linux,arm 2 | 3 | // Copyright 2014 The Go Authors. All rights reserved. 4 | // Use of this source code is governed by a BSD-style 5 | // license that can be found in the LICENSE file. 6 | 7 | package unix 8 | 9 | func init() { 10 | // On 32-bit Linux systems, the fcntl syscall that matches Go's 11 | // Flock_t type is SYS_FCNTL64, not SYS_FCNTL. 12 | fcntl64Syscall = SYS_FCNTL64 13 | } 14 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | // We can't use the gc-syntax .s files for gccgo. On the plus side 12 | // much of the functionality can be written directly in Go. 13 | 14 | //extern gccgoRealSyscall 15 | func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) 16 | 17 | func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 18 | syscall.Entersyscall() 19 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 20 | syscall.Exitsyscall() 21 | return r, 0, syscall.Errno(errno) 22 | } 23 | 24 | func Syscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 25 | syscall.Entersyscall() 26 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 27 | syscall.Exitsyscall() 28 | return r, 0, syscall.Errno(errno) 29 | } 30 | 31 | func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) { 32 | syscall.Entersyscall() 33 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9) 34 | syscall.Exitsyscall() 35 | return r, 0, syscall.Errno(errno) 36 | } 37 | 38 | func RawSyscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err syscall.Errno) { 39 | r, errno := realSyscall(trap, a1, a2, a3, 0, 0, 0, 0, 0, 0) 40 | return r, 0, syscall.Errno(errno) 41 | } 42 | 43 | func RawSyscall6(trap, a1, a2, a3, a4, a5, a6 uintptr) (r1, r2 uintptr, err syscall.Errno) { 44 | r, errno := realSyscall(trap, a1, a2, a3, a4, a5, a6, 0, 0, 0) 45 | return r, 0, syscall.Errno(errno) 46 | } 47 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_c.c: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | #define _STRINGIFY2_(x) #x 12 | #define _STRINGIFY_(x) _STRINGIFY2_(x) 13 | #define GOSYM_PREFIX _STRINGIFY_(__USER_LABEL_PREFIX__) 14 | 15 | // Call syscall from C code because the gccgo support for calling from 16 | // Go to C does not support varargs functions. 17 | 18 | struct ret { 19 | uintptr_t r; 20 | uintptr_t err; 21 | }; 22 | 23 | struct ret 24 | gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) 25 | { 26 | struct ret r; 27 | 28 | errno = 0; 29 | r.r = syscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9); 30 | r.err = errno; 31 | return r; 32 | } 33 | 34 | // Define the use function in C so that it is not inlined. 35 | 36 | extern void use(void *) __asm__ (GOSYM_PREFIX GOPKGPATH ".use") __attribute__((noinline)); 37 | 38 | void 39 | use(void *p __attribute__ ((unused))) 40 | { 41 | } 42 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/gccgo_linux_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build gccgo,linux,amd64 6 | 7 | package unix 8 | 9 | import "syscall" 10 | 11 | //extern gettimeofday 12 | func realGettimeofday(*Timeval, *byte) int32 13 | 14 | func gettimeofday(tv *Timeval) (err syscall.Errno) { 15 | r := realGettimeofday(tv, nil) 16 | if r < 0 { 17 | return syscall.GetErrno() 18 | } 19 | return 0 20 | } 21 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/mksysnum_darwin.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # Copyright 2009 The Go Authors. All rights reserved. 3 | # Use of this source code is governed by a BSD-style 4 | # license that can be found in the LICENSE file. 5 | # 6 | # Generate system call table for Darwin from sys/syscall.h 7 | 8 | use strict; 9 | 10 | if($ENV{'GOARCH'} eq "" || $ENV{'GOOS'} eq "") { 11 | print STDERR "GOARCH or GOOS not defined in environment\n"; 12 | exit 1; 13 | } 14 | 15 | my $command = "mksysnum_darwin.pl " . join(' ', @ARGV); 16 | 17 | print <){ 29 | if(/^#define\s+SYS_(\w+)\s+([0-9]+)/){ 30 | my $name = $1; 31 | my $num = $2; 32 | $name =~ y/a-z/A-Z/; 33 | print " SYS_$name = $num;" 34 | } 35 | } 36 | 37 | print <){ 30 | if(/^([0-9]+)\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <){ 30 | if(/^([0-9]+)\s+\S+\s+STD\s+({ \S+\s+(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $2; 33 | my $name = "SYS_$3"; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | if($name =~ /^SYS_CAP_+/ || $name =~ /^SYS___CAP_+/){ 44 | next 45 | } 46 | 47 | print " $name = $num; // $proto\n"; 48 | 49 | # We keep Capsicum syscall numbers for FreeBSD 50 | # 9-STABLE here because we are not sure whether they 51 | # are mature and stable. 52 | if($num == 513){ 53 | print " SYS_CAP_NEW = 514 // { int cap_new(int fd, uint64_t rights); }\n"; 54 | print " SYS_CAP_GETRIGHTS = 515 // { int cap_getrights(int fd, \\\n"; 55 | print " SYS_CAP_ENTER = 516 // { int cap_enter(void); }\n"; 56 | print " SYS_CAP_GETMODE = 517 // { int cap_getmode(u_int *modep); }\n"; 57 | } 58 | } 59 | } 60 | 61 | print < 999){ 29 | # ignore deprecated syscalls that are no longer implemented 30 | # https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/uapi/asm-generic/unistd.h?id=refs/heads/master#n716 31 | return; 32 | } 33 | $name =~ y/a-z/A-Z/; 34 | print " SYS_$name = $num;\n"; 35 | } 36 | 37 | my $prev; 38 | open(GCC, "gcc -E -dD $ARGV[0] |") || die "can't run gcc"; 39 | while(){ 40 | if(/^#define __NR_syscalls\s+/) { 41 | # ignore redefinitions of __NR_syscalls 42 | } 43 | elsif(/^#define __NR_(\w+)\s+([0-9]+)/){ 44 | $prev = $2; 45 | fmt($1, $2); 46 | } 47 | elsif(/^#define __NR3264_(\w+)\s+([0-9]+)/){ 48 | $prev = $2; 49 | fmt($1, $2); 50 | } 51 | elsif(/^#define __NR_(\w+)\s+\(\w+\+\s*([0-9]+)\)/){ 52 | fmt($1, $prev+$2) 53 | } 54 | } 55 | 56 | print <){ 31 | if($line =~ /^(.*)\\$/) { 32 | # Handle continuation 33 | $line = $1; 34 | $_ =~ s/^\s+//; 35 | $line .= $_; 36 | } else { 37 | # New line 38 | $line = $_; 39 | } 40 | next if $line =~ /\\$/; 41 | if($line =~ /^([0-9]+)\s+((STD)|(NOERR))\s+(RUMP\s+)?({\s+\S+\s*\*?\s*\|(\S+)\|(\S*)\|(\w+).*\s+})(\s+(\S+))?$/) { 42 | my $num = $1; 43 | my $proto = $6; 44 | my $compat = $8; 45 | my $name = "$7_$9"; 46 | 47 | $name = "$7_$11" if $11 ne ''; 48 | $name =~ y/a-z/A-Z/; 49 | 50 | if($compat eq '' || $compat eq '30' || $compat eq '50') { 51 | print " $name = $num; // $proto\n"; 52 | } 53 | } 54 | } 55 | 56 | print <){ 30 | if(/^([0-9]+)\s+STD\s+(NOLOCK\s+)?({ \S+\s+\*?(\w+).*)$/){ 31 | my $num = $1; 32 | my $proto = $3; 33 | my $name = $4; 34 | $name =~ y/a-z/A-Z/; 35 | 36 | # There are multiple entries for enosys and nosys, so comment them out. 37 | if($name =~ /^SYS_E?NOSYS$/){ 38 | $name = "// $name"; 39 | } 40 | if($name eq 'SYS_SYS_EXIT'){ 41 | $name = 'SYS_EXIT'; 42 | } 43 | 44 | print " $name = $num; // $proto\n"; 45 | } 46 | } 47 | 48 | print <= 10 { 20 | buf[i] = byte(val%10 + '0') 21 | i-- 22 | val /= 10 23 | } 24 | buf[i] = byte(val + '0') 25 | return string(buf[i:]) 26 | } 27 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build darwin dragonfly freebsd linux netbsd openbsd solaris 6 | 7 | // Package unix contains an interface to the low-level operating system 8 | // primitives. OS details vary depending on the underlying system, and 9 | // by default, godoc will display OS-specific documentation for the current 10 | // system. If you want godoc to display OS documentation for another 11 | // system, set $GOOS and $GOARCH to the desired system. For example, if 12 | // you want to view documentation for freebsd/arm on linux/amd64, set $GOOS 13 | // to freebsd and $GOARCH to arm. 14 | // The primary use of this package is inside other packages that provide a more 15 | // portable interface to the system, such as "os", "time" and "net". Use 16 | // those packages rather than this one if you can. 17 | // For details of the functions and data types in this package consult 18 | // the manuals for the appropriate operating system. 19 | // These calls return err == nil to indicate success; otherwise 20 | // err represents an operating system error describing the failure and 21 | // holds a value of type syscall.Errno. 22 | package unix // import "golang.org/x/sys/unix" 23 | 24 | import "unsafe" 25 | 26 | // ByteSliceFromString returns a NUL-terminated slice of bytes 27 | // containing the text of s. If s contains a NUL byte at any 28 | // location, it returns (nil, EINVAL). 29 | func ByteSliceFromString(s string) ([]byte, error) { 30 | for i := 0; i < len(s); i++ { 31 | if s[i] == 0 { 32 | return nil, EINVAL 33 | } 34 | } 35 | a := make([]byte, len(s)+1) 36 | copy(a, s) 37 | return a, nil 38 | } 39 | 40 | // BytePtrFromString returns a pointer to a NUL-terminated array of 41 | // bytes containing the text of s. If s contains a NUL byte at any 42 | // location, it returns (nil, EINVAL). 43 | func BytePtrFromString(s string) (*byte, error) { 44 | a, err := ByteSliceFromString(s) 45 | if err != nil { 46 | return nil, err 47 | } 48 | return &a[0], nil 49 | } 50 | 51 | // Single-word zero for use when we need a valid pointer to 0 bytes. 52 | // See mkunix.pl. 53 | var _zero uintptr 54 | 55 | func (ts *Timespec) Unix() (sec int64, nsec int64) { 56 | return int64(ts.Sec), int64(ts.Nsec) 57 | } 58 | 59 | func (tv *Timeval) Unix() (sec int64, nsec int64) { 60 | return int64(tv.Sec), int64(tv.Usec) * 1000 61 | } 62 | 63 | func (ts *Timespec) Nano() int64 { 64 | return int64(ts.Sec)*1e9 + int64(ts.Nsec) 65 | } 66 | 67 | func (tv *Timeval) Nano() int64 { 68 | return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000 69 | } 70 | 71 | // use is a no-op, but the compiler cannot see that it is. 72 | // Calling use(p) ensures that p is kept live until that point. 73 | //go:noescape 74 | func use(p unsafe.Pointer) 75 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int32(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = int32(sec) 40 | tv.Usec = int32(usec) 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint32(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint32(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/386 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 15 | 16 | func Getpagesize() int { return 4096 } 17 | 18 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 19 | 20 | func NsecToTimespec(nsec int64) (ts Timespec) { 21 | ts.Sec = nsec / 1e9 22 | ts.Nsec = nsec % 1e9 23 | return 24 | } 25 | 26 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 27 | 28 | func NsecToTimeval(nsec int64) (tv Timeval) { 29 | nsec += 999 // round up to microsecond 30 | tv.Usec = int32(nsec % 1e9 / 1e3) 31 | tv.Sec = int64(nsec / 1e9) 32 | return 33 | } 34 | 35 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 36 | func Gettimeofday(tv *Timeval) (err error) { 37 | // The tv passed to gettimeofday must be non-nil 38 | // but is otherwise unused. The answers come back 39 | // in the two registers. 40 | sec, usec, err := gettimeofday(tv) 41 | tv.Sec = sec 42 | tv.Usec = usec 43 | return err 44 | } 45 | 46 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 47 | k.Ident = uint64(fd) 48 | k.Filter = int16(mode) 49 | k.Flags = uint16(flags) 50 | } 51 | 52 | func (iov *Iovec) SetLen(length int) { 53 | iov.Len = uint64(length) 54 | } 55 | 56 | func (msghdr *Msghdr) SetControllen(length int) { 57 | msghdr.Controllen = uint32(length) 58 | } 59 | 60 | func (cmsg *Cmsghdr) SetLen(length int) { 61 | cmsg.Len = uint32(length) 62 | } 63 | 64 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 65 | var length = uint64(count) 66 | 67 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 68 | 69 | written = int(length) 70 | 71 | if e1 != 0 { 72 | err = e1 73 | } 74 | return 75 | } 76 | 77 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 78 | 79 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 80 | // of darwin/amd64 the syscall is called sysctl instead of __sysctl. 81 | const SYS___SYSCTL = SYS_SYSCTL 82 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | package unix 6 | 7 | import ( 8 | "syscall" 9 | "unsafe" 10 | ) 11 | 12 | func Getpagesize() int { return 4096 } 13 | 14 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 15 | 16 | func NsecToTimespec(nsec int64) (ts Timespec) { 17 | ts.Sec = int32(nsec / 1e9) 18 | ts.Nsec = int32(nsec % 1e9) 19 | return 20 | } 21 | 22 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 23 | 24 | func NsecToTimeval(nsec int64) (tv Timeval) { 25 | nsec += 999 // round up to microsecond 26 | tv.Usec = int32(nsec % 1e9 / 1e3) 27 | tv.Sec = int32(nsec / 1e9) 28 | return 29 | } 30 | 31 | //sysnb gettimeofday(tp *Timeval) (sec int32, usec int32, err error) 32 | func Gettimeofday(tv *Timeval) (err error) { 33 | // The tv passed to gettimeofday must be non-nil 34 | // but is otherwise unused. The answers come back 35 | // in the two registers. 36 | sec, usec, err := gettimeofday(tv) 37 | tv.Sec = int32(sec) 38 | tv.Usec = int32(usec) 39 | return err 40 | } 41 | 42 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 43 | k.Ident = uint32(fd) 44 | k.Filter = int16(mode) 45 | k.Flags = uint16(flags) 46 | } 47 | 48 | func (iov *Iovec) SetLen(length int) { 49 | iov.Len = uint32(length) 50 | } 51 | 52 | func (msghdr *Msghdr) SetControllen(length int) { 53 | msghdr.Controllen = uint32(length) 54 | } 55 | 56 | func (cmsg *Cmsghdr) SetLen(length int) { 57 | cmsg.Len = uint32(length) 58 | } 59 | 60 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 61 | var length = uint64(count) 62 | 63 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(*offset>>32), uintptr(unsafe.Pointer(&length)), 0, 0, 0, 0) 64 | 65 | written = int(length) 66 | 67 | if e1 != 0 { 68 | err = e1 69 | } 70 | return 71 | } 72 | 73 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 74 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_darwin_arm64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2015 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm64,darwin 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 16384 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | //sysnb gettimeofday(tp *Timeval) (sec int64, usec int32, err error) 34 | func Gettimeofday(tv *Timeval) (err error) { 35 | // The tv passed to gettimeofday must be non-nil 36 | // but is otherwise unused. The answers come back 37 | // in the two registers. 38 | sec, usec, err := gettimeofday(tv) 39 | tv.Sec = sec 40 | tv.Usec = usec 41 | return err 42 | } 43 | 44 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 45 | k.Ident = uint64(fd) 46 | k.Filter = int16(mode) 47 | k.Flags = uint16(flags) 48 | } 49 | 50 | func (iov *Iovec) SetLen(length int) { 51 | iov.Len = uint64(length) 52 | } 53 | 54 | func (msghdr *Msghdr) SetControllen(length int) { 55 | msghdr.Controllen = uint32(length) 56 | } 57 | 58 | func (cmsg *Cmsghdr) SetLen(length int) { 59 | cmsg.Len = uint32(length) 60 | } 61 | 62 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 63 | var length = uint64(count) 64 | 65 | _, _, e1 := Syscall6(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(unsafe.Pointer(&length)), 0, 0) 66 | 67 | written = int(length) 68 | 69 | if e1 != 0 { 70 | err = e1 71 | } 72 | return 73 | } 74 | 75 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) // sic 76 | 77 | // SYS___SYSCTL is used by syscall_bsd.go for all BSDs, but in modern versions 78 | // of darwin/arm64 the syscall is called sysctl instead of __sysctl. 79 | const SYS___SYSCTL = SYS_SYSCTL 80 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int32(nsec / 1e9) 30 | return 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint32(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint32(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_dragonfly_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,dragonfly 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = nsec % 1e9 / 1e3 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = int32(nsec / 1e9) 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = int32(nsec / 1e9) 30 | return 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint32(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint32(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = nsec % 1e9 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = nsec % 1e9 / 1e3 29 | tv.Sec = int64(nsec / 1e9) 30 | return 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint64(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint64(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_freebsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,freebsd 6 | 7 | package unix 8 | 9 | import ( 10 | "syscall" 11 | "unsafe" 12 | ) 13 | 14 | func Getpagesize() int { return 4096 } 15 | 16 | func TimespecToNsec(ts Timespec) int64 { return ts.Sec*1e9 + int64(ts.Nsec) } 17 | 18 | func NsecToTimespec(nsec int64) (ts Timespec) { 19 | ts.Sec = nsec / 1e9 20 | ts.Nsec = int32(nsec % 1e9) 21 | return 22 | } 23 | 24 | func TimevalToNsec(tv Timeval) int64 { return tv.Sec*1e9 + int64(tv.Usec)*1e3 } 25 | 26 | func NsecToTimeval(nsec int64) (tv Timeval) { 27 | nsec += 999 // round up to microsecond 28 | tv.Usec = int32(nsec % 1e9 / 1e3) 29 | tv.Sec = nsec / 1e9 30 | return 31 | } 32 | 33 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 34 | k.Ident = uint32(fd) 35 | k.Filter = int16(mode) 36 | k.Flags = uint16(flags) 37 | } 38 | 39 | func (iov *Iovec) SetLen(length int) { 40 | iov.Len = uint32(length) 41 | } 42 | 43 | func (msghdr *Msghdr) SetControllen(length int) { 44 | msghdr.Controllen = uint32(length) 45 | } 46 | 47 | func (cmsg *Cmsghdr) SetLen(length int) { 48 | cmsg.Len = uint32(length) 49 | } 50 | 51 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 52 | var writtenOut uint64 = 0 53 | _, _, e1 := Syscall9(SYS_SENDFILE, uintptr(infd), uintptr(outfd), uintptr(*offset), uintptr((*offset)>>32), uintptr(count), 0, uintptr(unsafe.Pointer(&writtenOut)), 0, 0) 54 | 55 | written = int(writtenOut) 56 | 57 | if e1 != 0 { 58 | err = e1 59 | } 60 | return 61 | } 62 | 63 | func Syscall9(num, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) 64 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint32(fd) 30 | k.Filter = uint32(mode) 31 | k.Flags = uint32(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint32(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int64(nsec % 1e9) 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint64(fd) 30 | k.Filter = uint32(mode) 31 | k.Flags = uint32(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint64(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_netbsd_arm.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build arm,netbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint32(fd) 30 | k.Filter = uint32(mode) 31 | k.Flags = uint32(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint32(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_no_getwd.go: -------------------------------------------------------------------------------- 1 | // Copyright 2013 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build dragonfly freebsd netbsd openbsd 6 | 7 | package unix 8 | 9 | const ImplementsGetwd = false 10 | 11 | func Getwd() (string, error) { return "", ENOTSUP } 12 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_386.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build 386,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = int64(nsec / 1e9) 15 | ts.Nsec = int32(nsec % 1e9) 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = int32(nsec % 1e9 / 1e3) 24 | tv.Sec = int64(nsec / 1e9) 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint32(fd) 30 | k.Filter = int16(mode) 31 | k.Flags = uint16(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint32(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_openbsd_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,openbsd 6 | 7 | package unix 8 | 9 | func Getpagesize() int { return 4096 } 10 | 11 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 12 | 13 | func NsecToTimespec(nsec int64) (ts Timespec) { 14 | ts.Sec = nsec / 1e9 15 | ts.Nsec = nsec % 1e9 16 | return 17 | } 18 | 19 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 20 | 21 | func NsecToTimeval(nsec int64) (tv Timeval) { 22 | nsec += 999 // round up to microsecond 23 | tv.Usec = nsec % 1e9 / 1e3 24 | tv.Sec = nsec / 1e9 25 | return 26 | } 27 | 28 | func SetKevent(k *Kevent_t, fd, mode, flags int) { 29 | k.Ident = uint64(fd) 30 | k.Filter = int16(mode) 31 | k.Flags = uint16(flags) 32 | } 33 | 34 | func (iov *Iovec) SetLen(length int) { 35 | iov.Len = uint64(length) 36 | } 37 | 38 | func (msghdr *Msghdr) SetControllen(length int) { 39 | msghdr.Controllen = uint32(length) 40 | } 41 | 42 | func (cmsg *Cmsghdr) SetLen(length int) { 43 | cmsg.Len = uint32(length) 44 | } 45 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/syscall_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2009 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) } 10 | 11 | func NsecToTimespec(nsec int64) (ts Timespec) { 12 | ts.Sec = nsec / 1e9 13 | ts.Nsec = nsec % 1e9 14 | return 15 | } 16 | 17 | func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 } 18 | 19 | func NsecToTimeval(nsec int64) (tv Timeval) { 20 | nsec += 999 // round up to microsecond 21 | tv.Usec = nsec % 1e9 / 1e3 22 | tv.Sec = int64(nsec / 1e9) 23 | return 24 | } 25 | 26 | func (iov *Iovec) SetLen(length int) { 27 | iov.Len = uint64(length) 28 | } 29 | 30 | func (cmsg *Cmsghdr) SetLen(length int) { 31 | cmsg.Len = uint32(length) 32 | } 33 | 34 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 35 | // TODO(aram): implement this, see issue 5847. 36 | panic("unimplemented") 37 | } 38 | -------------------------------------------------------------------------------- /vendor/golang.org/x/sys/unix/zsysnum_solaris_amd64.go: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Go Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style 3 | // license that can be found in the LICENSE file. 4 | 5 | // +build amd64,solaris 6 | 7 | package unix 8 | 9 | // TODO(aram): remove these before Go 1.3. 10 | const ( 11 | SYS_EXECVE = 59 12 | SYS_FCNTL = 62 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2011-2016 Canonical Ltd. 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/LICENSE.libyaml: -------------------------------------------------------------------------------- 1 | The following files were ported to Go from C files of libyaml, and thus 2 | are still covered by their original copyright and license: 3 | 4 | apic.go 5 | emitterc.go 6 | parserc.go 7 | readerc.go 8 | scannerc.go 9 | writerc.go 10 | yamlh.go 11 | yamlprivateh.go 12 | 13 | Copyright (c) 2006 Kirill Simonov 14 | 15 | Permission is hereby granted, free of charge, to any person obtaining a copy of 16 | this software and associated documentation files (the "Software"), to deal in 17 | the Software without restriction, including without limitation the rights to 18 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 19 | of the Software, and to permit persons to whom the Software is furnished to do 20 | so, subject to the following conditions: 21 | 22 | The above copyright notice and this permission notice shall be included in all 23 | copies or substantial portions of the Software. 24 | 25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 | SOFTWARE. 32 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v2/writerc.go: -------------------------------------------------------------------------------- 1 | package yaml 2 | 3 | // Set the writer error and return false. 4 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { 5 | emitter.error = yaml_WRITER_ERROR 6 | emitter.problem = problem 7 | return false 8 | } 9 | 10 | // Flush the output buffer. 11 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool { 12 | if emitter.write_handler == nil { 13 | panic("write handler not set") 14 | } 15 | 16 | // Check if the buffer is empty. 17 | if emitter.buffer_pos == 0 { 18 | return true 19 | } 20 | 21 | // If the output encoding is UTF-8, we don't need to recode the buffer. 22 | if emitter.encoding == yaml_UTF8_ENCODING { 23 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { 24 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 25 | } 26 | emitter.buffer_pos = 0 27 | return true 28 | } 29 | 30 | // Recode the buffer into the raw buffer. 31 | var low, high int 32 | if emitter.encoding == yaml_UTF16LE_ENCODING { 33 | low, high = 0, 1 34 | } else { 35 | high, low = 1, 0 36 | } 37 | 38 | pos := 0 39 | for pos < emitter.buffer_pos { 40 | // See the "reader.c" code for more details on UTF-8 encoding. Note 41 | // that we assume that the buffer contains a valid UTF-8 sequence. 42 | 43 | // Read the next UTF-8 character. 44 | octet := emitter.buffer[pos] 45 | 46 | var w int 47 | var value rune 48 | switch { 49 | case octet&0x80 == 0x00: 50 | w, value = 1, rune(octet&0x7F) 51 | case octet&0xE0 == 0xC0: 52 | w, value = 2, rune(octet&0x1F) 53 | case octet&0xF0 == 0xE0: 54 | w, value = 3, rune(octet&0x0F) 55 | case octet&0xF8 == 0xF0: 56 | w, value = 4, rune(octet&0x07) 57 | } 58 | for k := 1; k < w; k++ { 59 | octet = emitter.buffer[pos+k] 60 | value = (value << 6) + (rune(octet) & 0x3F) 61 | } 62 | pos += w 63 | 64 | // Write the character. 65 | if value < 0x10000 { 66 | var b [2]byte 67 | b[high] = byte(value >> 8) 68 | b[low] = byte(value & 0xFF) 69 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1]) 70 | } else { 71 | // Write the character using a surrogate pair (check "reader.c"). 72 | var b [4]byte 73 | value -= 0x10000 74 | b[high] = byte(0xD8 + (value >> 18)) 75 | b[low] = byte((value >> 10) & 0xFF) 76 | b[high+2] = byte(0xDC + ((value >> 8) & 0xFF)) 77 | b[low+2] = byte(value & 0xFF) 78 | emitter.raw_buffer = append(emitter.raw_buffer, b[0], b[1], b[2], b[3]) 79 | } 80 | } 81 | 82 | // Write the raw buffer. 83 | if err := emitter.write_handler(emitter, emitter.raw_buffer); err != nil { 84 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 85 | } 86 | emitter.buffer_pos = 0 87 | emitter.raw_buffer = emitter.raw_buffer[:0] 88 | return true 89 | } 90 | --------------------------------------------------------------------------------