├── .gitignore ├── vendor ├── github.com │ ├── hashicorp │ │ ├── go-version │ │ │ ├── go.mod │ │ │ ├── version_collection.go │ │ │ ├── CHANGELOG.md │ │ │ ├── README.md │ │ │ └── constraint.go │ │ ├── go-retryablehttp │ │ │ ├── .gitignore │ │ │ ├── go.mod │ │ │ ├── Makefile │ │ │ ├── go.sum │ │ │ ├── roundtripper.go │ │ │ └── README.md │ │ └── go-cleanhttp │ │ │ ├── go.mod │ │ │ ├── doc.go │ │ │ ├── handlers.go │ │ │ ├── README.md │ │ │ └── cleanhttp.go │ ├── stretchr │ │ ├── objx │ │ │ ├── go.mod │ │ │ ├── .gitignore │ │ │ ├── security.go │ │ │ ├── .codeclimate.yml │ │ │ ├── tests.go │ │ │ ├── Taskfile.yml │ │ │ ├── LICENSE │ │ │ ├── go.sum │ │ │ ├── doc.go │ │ │ ├── mutations.go │ │ │ ├── README.md │ │ │ ├── value.go │ │ │ └── accessors.go │ │ └── testify │ │ │ ├── require │ │ │ ├── require_forward.go.tmpl │ │ │ ├── require.go.tmpl │ │ │ ├── forward_requirements.go │ │ │ ├── doc.go │ │ │ └── requirements.go │ │ │ ├── assert │ │ │ ├── assertion_format.go.tmpl │ │ │ ├── assertion_forward.go.tmpl │ │ │ ├── errors.go │ │ │ ├── assertion_compare_legacy.go │ │ │ ├── assertion_compare_can_convert.go │ │ │ ├── forward_assertions.go │ │ │ ├── doc.go │ │ │ ├── assertion_order.go │ │ │ └── http_assertions.go │ │ │ ├── LICENSE │ │ │ └── mock │ │ │ └── doc.go │ ├── kballard │ │ └── go-shellquote │ │ │ ├── doc.go │ │ │ ├── LICENSE │ │ │ ├── README │ │ │ ├── quote.go │ │ │ └── unquote.go │ ├── bitrise-io │ │ ├── go-utils │ │ │ ├── log │ │ │ │ ├── logger.go │ │ │ │ ├── json_logger.go │ │ │ │ ├── raw_logger.go │ │ │ │ ├── log.go │ │ │ │ ├── dummylogger.go │ │ │ │ ├── severity.go │ │ │ │ ├── defaultlogger.go │ │ │ │ ├── internal_logger.go │ │ │ │ └── print.go │ │ │ ├── v2 │ │ │ │ ├── exitcode │ │ │ │ │ ├── exitcode.go │ │ │ │ │ └── exitcode_string.go │ │ │ │ ├── log │ │ │ │ │ ├── severity.go │ │ │ │ │ ├── colorstring │ │ │ │ │ │ └── colorstring.go │ │ │ │ │ └── log.go │ │ │ │ ├── LICENSE │ │ │ │ ├── env │ │ │ │ │ └── env.go │ │ │ │ ├── errorutil │ │ │ │ │ └── formatted_error.go │ │ │ │ └── command │ │ │ │ │ └── command.go │ │ │ ├── retry │ │ │ │ ├── retryhttp.go │ │ │ │ └── retry.go │ │ │ ├── LICENSE │ │ │ ├── sliceutil │ │ │ │ └── sliceutil.go │ │ │ ├── command │ │ │ │ ├── file.go │ │ │ │ └── zip.go │ │ │ ├── pointers │ │ │ │ └── pointers.go │ │ │ ├── parseutil │ │ │ │ └── parseutil.go │ │ │ ├── colorstring │ │ │ │ └── colorstring.go │ │ │ ├── pathutil │ │ │ │ ├── sortable_path.go │ │ │ │ ├── path_filter.go │ │ │ │ └── pathutil.go │ │ │ └── fileutil │ │ │ │ └── fileutil.go │ │ ├── go-steputils │ │ │ └── tools │ │ │ │ └── tools.go │ │ └── go-android │ │ │ ├── sdkmanager │ │ │ └── sdkmanager.go │ │ │ └── sdk │ │ │ └── sdk.go │ ├── davecgh │ │ └── go-spew │ │ │ ├── LICENSE │ │ │ └── spew │ │ │ ├── bypasssafe.go │ │ │ ├── bypass.go │ │ │ └── spew.go │ └── pmezard │ │ └── go-difflib │ │ └── LICENSE ├── gopkg.in │ └── yaml.v3 │ │ ├── go.mod │ │ ├── NOTICE │ │ ├── writerc.go │ │ ├── LICENSE │ │ ├── sorter.go │ │ └── README.md └── modules.txt ├── renovate.json ├── go.mod ├── LICENSE ├── mocks ├── Factory.go ├── Command.go └── Logger.go ├── bitrise.yml ├── androidcomponents ├── errors.go └── androidcomponents_test.go ├── .github └── workflows │ └── stale-issues-workflow.yml ├── CHANGELOG.md ├── step.yml ├── main_test.go └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .bitrise* 2 | go/bin/ 3 | go/pkg/ 4 | .gows* 5 | _tmp/ 6 | .idea/ -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-version/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/hashicorp/go-version 2 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-retryablehttp/.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | *.iml 3 | *.test 4 | .vscode/ -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-cleanhttp/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/hashicorp/go-cleanhttp 2 | 3 | go 1.13 4 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/stretchr/objx 2 | 3 | go 1.12 4 | 5 | require github.com/stretchr/testify v1.8.0 6 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/go.mod: -------------------------------------------------------------------------------- 1 | module "gopkg.in/yaml.v3" 2 | 3 | require ( 4 | "gopkg.in/check.v1" v0.0.0-20161208181325-20d25e280405 5 | ) 6 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "local>bitrise-steplib/.github:renovate-config" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /vendor/github.com/kballard/go-shellquote/doc.go: -------------------------------------------------------------------------------- 1 | // Shellquote provides utilities for joining/splitting strings using sh's 2 | // word-splitting rules. 3 | package shellquote 4 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-retryablehttp/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/hashicorp/go-retryablehttp 2 | 3 | require ( 4 | github.com/hashicorp/go-cleanhttp v0.5.1 5 | github.com/hashicorp/go-hclog v0.9.2 6 | ) 7 | 8 | go 1.13 9 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-retryablehttp/Makefile: -------------------------------------------------------------------------------- 1 | default: test 2 | 3 | test: 4 | go vet ./... 5 | go test -race ./... 6 | 7 | updatedeps: 8 | go get -f -t -u ./... 9 | go get -f -u ./... 10 | 11 | .PHONY: default test updatedeps 12 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) { 3 | if h, ok := a.t.(tHelper); ok { h.Helper() } 4 | {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/log/logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | // Logger ... 4 | type Logger interface { 5 | Print(f Formatable) 6 | } 7 | 8 | // Formatable ... 9 | type Formatable interface { 10 | String() string 11 | JSON() string 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentFormat}} 2 | func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool { 3 | if h, ok := t.(tHelper); ok { h.Helper() } 4 | return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.CommentWithoutT "a"}} 2 | func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { 3 | if h, ok := a.t.(tHelper); ok { h.Helper() } 4 | return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) 5 | } 6 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/require.go.tmpl: -------------------------------------------------------------------------------- 1 | {{.Comment}} 2 | func {{.DocInfo.Name}}(t TestingT, {{.Params}}) { 3 | if h, ok := t.(tHelper); ok { h.Helper() } 4 | if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return } 5 | t.FailNow() 6 | } 7 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.dll 4 | *.so 5 | *.dylib 6 | 7 | # Test binary, build with `go test -c` 8 | *.test 9 | 10 | # Output of the go coverage tool, specifically when used with LiteIDE 11 | *.out 12 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/security.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "crypto/sha1" 5 | "encoding/hex" 6 | ) 7 | 8 | // HashWithKey hashes the specified string using the security key 9 | func HashWithKey(data, key string) string { 10 | d := sha1.Sum([]byte(data + ":" + key)) 11 | return hex.EncodeToString(d[:]) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-steputils/tools/tools.go: -------------------------------------------------------------------------------- 1 | package tools 2 | 3 | import ( 4 | "strings" 5 | 6 | "github.com/bitrise-io/go-utils/command" 7 | ) 8 | 9 | // ExportEnvironmentWithEnvman ... 10 | func ExportEnvironmentWithEnvman(key, value string) error { 11 | cmd := command.New("envman", "add", "--key", key) 12 | cmd.SetStdin(strings.NewReader(value)) 13 | return cmd.Run() 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/errors.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "errors" 5 | ) 6 | 7 | // AnError is an error instance useful for testing. If the code does not care 8 | // about error specifics, and only needs to return the error for example, this 9 | // error should be used to make the test code more readable. 10 | var AnError = errors.New("assert.AnError general error for testing") 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/.codeclimate.yml: -------------------------------------------------------------------------------- 1 | engines: 2 | gofmt: 3 | enabled: true 4 | golint: 5 | enabled: true 6 | govet: 7 | enabled: true 8 | 9 | exclude_patterns: 10 | - ".github/" 11 | - "vendor/" 12 | - "codegen/" 13 | - "*.yml" 14 | - ".*.yml" 15 | - "*.md" 16 | - "Gopkg.*" 17 | - "doc.go" 18 | - "type_specific_codegen_test.go" 19 | - "type_specific_codegen.go" 20 | - ".gitignore" 21 | - "LICENSE" 22 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-version/version_collection.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | // Collection is a type that implements the sort.Interface interface 4 | // so that versions can be sorted. 5 | type Collection []*Version 6 | 7 | func (v Collection) Len() int { 8 | return len(v) 9 | } 10 | 11 | func (v Collection) Less(i, j int) bool { 12 | return v[i].LessThan(v[j]) 13 | } 14 | 15 | func (v Collection) Swap(i, j int) { 16 | v[i], v[j] = v[j], v[i] 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/tests.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | // Has gets whether there is something at the specified selector 4 | // or not. 5 | // 6 | // If m is nil, Has will always return false. 7 | func (m Map) Has(selector string) bool { 8 | if m == nil { 9 | return false 10 | } 11 | return !m.Get(selector).IsNil() 12 | } 13 | 14 | // IsNil gets whether the data is nil or not. 15 | func (v *Value) IsNil() bool { 16 | return v == nil || v.data == nil 17 | } 18 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/bitrise-steplib/steps-install-missing-android-tools 2 | 3 | go 1.16 4 | 5 | require ( 6 | github.com/bitrise-io/go-android v1.0.0 7 | github.com/bitrise-io/go-steputils v1.0.1 8 | github.com/bitrise-io/go-utils v1.0.1 9 | github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.14.0.20221208123037-ab31edd851e5 10 | github.com/hashicorp/go-version v1.3.0 11 | github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 12 | github.com/stretchr/testify v1.8.4 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/v2/exitcode/exitcode.go: -------------------------------------------------------------------------------- 1 | //go:generate stringer -type=ExitCode 2 | 3 | package exitcode 4 | 5 | // ExitCode is a simple integer type that represents an exit code. 6 | // It can be used to provide a more semantically meaningful exit code than a simple integer. 7 | type ExitCode int 8 | 9 | const ( 10 | // Success indicates that the program exited successfully. 11 | Success ExitCode = 0 12 | 13 | // Failure indicates that the program exited unsuccessfully. 14 | Failure ExitCode = 1 15 | ) 16 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go: -------------------------------------------------------------------------------- 1 | //go:build !go1.17 2 | // +build !go1.17 3 | 4 | // TODO: once support for Go 1.16 is dropped, this file can be 5 | // merged/removed with assertion_compare_go1.17_test.go and 6 | // assertion_compare_can_convert.go 7 | 8 | package assert 9 | 10 | import "reflect" 11 | 12 | // Older versions of Go does not have the reflect.Value.CanConvert 13 | // method. 14 | func canConvert(value reflect.Value, to reflect.Type) bool { 15 | return false 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go: -------------------------------------------------------------------------------- 1 | //go:build go1.17 2 | // +build go1.17 3 | 4 | // TODO: once support for Go 1.16 is dropped, this file can be 5 | // merged/removed with assertion_compare_go1.17_test.go and 6 | // assertion_compare_legacy.go 7 | 8 | package assert 9 | 10 | import "reflect" 11 | 12 | // Wrapper around reflect.Value.CanConvert, for compatibility 13 | // reasons. 14 | func canConvert(value reflect.Value, to reflect.Type) bool { 15 | return value.CanConvert(to) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/forward_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs" 17 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/forward_requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // Assertions provides assertion methods around the 4 | // TestingT interface. 5 | type Assertions struct { 6 | t TestingT 7 | } 8 | 9 | // New makes a new Assertions object for the specified TestingT. 10 | func New(t TestingT) *Assertions { 11 | return &Assertions{ 12 | t: t, 13 | } 14 | } 15 | 16 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require_forward.go.tmpl -include-format-funcs" 17 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/NOTICE: -------------------------------------------------------------------------------- 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/github.com/stretchr/objx/Taskfile.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | 3 | env: 4 | GOFLAGS: -mod=vendor 5 | 6 | tasks: 7 | default: 8 | deps: [test] 9 | 10 | lint: 11 | desc: Checks code style 12 | cmds: 13 | - gofmt -d -s *.go 14 | - go vet ./... 15 | silent: true 16 | 17 | lint-fix: 18 | desc: Fixes code style 19 | cmds: 20 | - gofmt -w -s *.go 21 | 22 | test: 23 | desc: Runs go tests 24 | cmds: 25 | - go test -race ./... 26 | 27 | test-coverage: 28 | desc: Runs go tests and calculates test coverage 29 | cmds: 30 | - go test -race -coverprofile=c.out ./... 31 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/log/json_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | ) 8 | 9 | // JSONLoger ... 10 | type JSONLoger struct { 11 | writer io.Writer 12 | } 13 | 14 | // NewJSONLoger ... 15 | func NewJSONLoger(writer io.Writer) *JSONLoger { 16 | return &JSONLoger{ 17 | writer: writer, 18 | } 19 | } 20 | 21 | // NewDefaultJSONLoger ... 22 | func NewDefaultJSONLoger() JSONLoger { 23 | return JSONLoger{ 24 | writer: os.Stdout, 25 | } 26 | } 27 | 28 | // Print ... 29 | func (l JSONLoger) Print(f Formatable) { 30 | if _, err := fmt.Fprint(l.writer, f.JSON()); err != nil { 31 | fmt.Printf("failed to print message: %s, error: %s\n", f.JSON(), err) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/log/raw_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | ) 8 | 9 | // RawLogger ... 10 | type RawLogger struct { 11 | writer io.Writer 12 | } 13 | 14 | // NewRawLogger ... 15 | func NewRawLogger(writer io.Writer) *RawLogger { 16 | return &RawLogger{ 17 | writer: writer, 18 | } 19 | } 20 | 21 | // NewDefaultRawLogger ... 22 | func NewDefaultRawLogger() RawLogger { 23 | return RawLogger{ 24 | writer: os.Stdout, 25 | } 26 | } 27 | 28 | // Print ... 29 | func (l RawLogger) Print(f Formatable) { 30 | if _, err := fmt.Fprintln(l.writer, f.String()); err != nil { 31 | fmt.Printf("failed to print message: %s, error: %s\n", f.String(), err) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/log/log.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "time" 8 | ) 9 | 10 | var outWriter io.Writer = os.Stdout 11 | 12 | // SetOutWriter ... 13 | func SetOutWriter(writer io.Writer) { 14 | outWriter = writer 15 | } 16 | 17 | var enableDebugLog = false 18 | 19 | // SetEnableDebugLog ... 20 | func SetEnableDebugLog(enable bool) { 21 | enableDebugLog = enable 22 | } 23 | 24 | var timestampLayout = "15:04:05" 25 | 26 | // SetTimestampLayout ... 27 | func SetTimestampLayout(layout string) { 28 | timestampLayout = layout 29 | } 30 | 31 | func timestampField() string { 32 | currentTime := time.Now() 33 | return fmt.Sprintf("[%s]", currentTime.Format(timestampLayout)) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/retry/retryhttp.go: -------------------------------------------------------------------------------- 1 | package retry 2 | 3 | import ( 4 | "github.com/bitrise-io/go-utils/log" 5 | retryablehttp "github.com/hashicorp/go-retryablehttp" 6 | ) 7 | 8 | // HTTPLogAdaptor adapts the retryablehttp.Logger interface to the go-utils logger. 9 | type HTTPLogAdaptor struct{} 10 | 11 | // Printf implements the retryablehttp.Logger interface 12 | func (*HTTPLogAdaptor) Printf(fmtStr string, vars ...interface{}) { 13 | log.Debugf(fmtStr, vars...) 14 | } 15 | 16 | // NewHTTPClient returns a retryable HTTP client 17 | func NewHTTPClient() *retryablehttp.Client { 18 | client := retryablehttp.NewClient() 19 | client.Logger = &HTTPLogAdaptor{} 20 | client.ErrorHandler = retryablehttp.PassthroughErrorHandler 21 | 22 | return client 23 | } 24 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/v2/exitcode/exitcode_string.go: -------------------------------------------------------------------------------- 1 | // Code generated by "stringer -type=ExitCode"; DO NOT EDIT. 2 | 3 | package exitcode 4 | 5 | import "strconv" 6 | 7 | func _() { 8 | // An "invalid array index" compiler error signifies that the constant values have changed. 9 | // Re-run the stringer command to generate them again. 10 | var x [1]struct{} 11 | _ = x[Success-0] 12 | _ = x[Failure-1] 13 | } 14 | 15 | const _ExitCode_name = "SuccessFailure" 16 | 17 | var _ExitCode_index = [...]uint8{0, 7, 14} 18 | 19 | func (i ExitCode) String() string { 20 | if i < 0 || i >= ExitCode(len(_ExitCode_index)-1) { 21 | return "ExitCode(" + strconv.FormatInt(int64(i), 10) + ")" 22 | } 23 | return _ExitCode_name[_ExitCode_index[i]:_ExitCode_index[i+1]] 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2012-2016 Dave Collins 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 | WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 | ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/log/dummylogger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | // DummyLogger ... 4 | type DummyLogger struct{} 5 | 6 | // NewDummyLogger ... 7 | func NewDummyLogger() DummyLogger { 8 | return DummyLogger{} 9 | } 10 | 11 | // Donef ... 12 | func (dl DummyLogger) Donef(format string, v ...interface{}) {} 13 | 14 | // Successf ... 15 | func (dl DummyLogger) Successf(format string, v ...interface{}) {} 16 | 17 | // Infof ... 18 | func (dl DummyLogger) Infof(format string, v ...interface{}) {} 19 | 20 | // Printf ... 21 | func (dl DummyLogger) Printf(format string, v ...interface{}) {} 22 | 23 | // Debugf ... 24 | func (dl DummyLogger) Debugf(format string, v ...interface{}) {} 25 | 26 | // Warnf ... 27 | func (dl DummyLogger) Warnf(format string, v ...interface{}) {} 28 | 29 | // Errorf ... 30 | func (dl DummyLogger) Errorf(format string, v ...interface{}) {} 31 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-version/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 1.3.0 (March 31, 2021) 2 | 3 | Please note that CHANGELOG.md does not exist in the source code prior to this release. 4 | 5 | FEATURES: 6 | - Add `Core` function to return a version without prerelease or metadata ([#85](https://github.com/hashicorp/go-version/pull/85)) 7 | 8 | # 1.2.1 (June 17, 2020) 9 | 10 | BUG FIXES: 11 | - Prevent `Version.Equal` method from panicking on `nil` encounter ([#73](https://github.com/hashicorp/go-version/pull/73)) 12 | 13 | # 1.2.0 (April 23, 2019) 14 | 15 | FEATURES: 16 | - Add `GreaterThanOrEqual` and `LessThanOrEqual` helper methods ([#53](https://github.com/hashicorp/go-version/pull/53)) 17 | 18 | # 1.1.0 (Jan 07, 2019) 19 | 20 | FEATURES: 21 | - Add `NewSemver` constructor ([#45](https://github.com/hashicorp/go-version/pull/45)) 22 | 23 | # 1.0.0 (August 24, 2018) 24 | 25 | Initial release. 26 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-retryablehttp/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 2 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 3 | github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= 4 | github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= 5 | github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= 6 | github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= 7 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 8 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 9 | github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= 10 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 11 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/doc.go: -------------------------------------------------------------------------------- 1 | // Package require implements the same assertions as the `assert` package but 2 | // stops test execution when a test fails. 3 | // 4 | // # Example Usage 5 | // 6 | // The following is a complete example using require in a standard test function: 7 | // 8 | // import ( 9 | // "testing" 10 | // "github.com/stretchr/testify/require" 11 | // ) 12 | // 13 | // func TestSomething(t *testing.T) { 14 | // 15 | // var a string = "Hello" 16 | // var b string = "Hello" 17 | // 18 | // require.Equal(t, a, b, "The two words should be the same.") 19 | // 20 | // } 21 | // 22 | // # Assertions 23 | // 24 | // The `require` package have same global functions as in the `assert` package, 25 | // but instead of returning a boolean result they call `t.FailNow()`. 26 | // 27 | // Every assertion function also takes an optional string message as the final argument, 28 | // allowing custom error messages to be appended to the message the assertion method outputs. 29 | package require 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 bitrise-steplib 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 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/kballard/go-shellquote/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2014 Kevin Ballard 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the "Software"), 5 | to deal in the Software without restriction, including without limitation 6 | the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | and/or sell copies of the Software, and to permit persons to whom the 8 | Software is furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included 11 | in all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 14 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 15 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 16 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 17 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 18 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE 19 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/v2/log/severity.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import "github.com/bitrise-io/go-utils/v2/log/colorstring" 4 | 5 | // Severity ... 6 | type Severity uint8 7 | 8 | const ( 9 | errorSeverity Severity = iota 10 | warnSeverity 11 | normalSeverity 12 | infoSeverity 13 | doneSeverity 14 | debugSeverity 15 | ) 16 | 17 | type severityColorFunc colorstring.ColorfFunc 18 | 19 | var ( 20 | doneSeverityColorFunc severityColorFunc = colorstring.Greenf 21 | infoSeverityColorFunc severityColorFunc = colorstring.Bluef 22 | normalSeverityColorFunc severityColorFunc = colorstring.NoColorf 23 | debugSeverityColorFunc severityColorFunc = colorstring.Magentaf 24 | warnSeverityColorFunc severityColorFunc = colorstring.Yellowf 25 | errorSeverityColorFunc severityColorFunc = colorstring.Redf 26 | ) 27 | 28 | var severityColorFuncMap = map[Severity]severityColorFunc{ 29 | doneSeverity: doneSeverityColorFunc, 30 | infoSeverity: infoSeverityColorFunc, 31 | normalSeverity: normalSeverityColorFunc, 32 | debugSeverity: debugSeverityColorFunc, 33 | warnSeverity: warnSeverityColorFunc, 34 | errorSeverity: errorSeverityColorFunc, 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/log/severity.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import "github.com/bitrise-io/go-utils/colorstring" 4 | 5 | // Severity ... 6 | type Severity uint8 7 | 8 | const ( 9 | errorSeverity Severity = iota 10 | warnSeverity 11 | normalSeverity 12 | infoSeverity 13 | successSeverity 14 | debugSeverity 15 | ) 16 | 17 | type severityColorFunc colorstring.ColorfFunc 18 | 19 | var ( 20 | successSeverityColorFunc severityColorFunc = colorstring.Greenf 21 | infoSeverityColorFunc severityColorFunc = colorstring.Bluef 22 | normalSeverityColorFunc severityColorFunc = colorstring.NoColorf 23 | debugSeverityColorFunc severityColorFunc = colorstring.Magentaf 24 | warnSeverityColorFunc severityColorFunc = colorstring.Yellowf 25 | errorSeverityColorFunc severityColorFunc = colorstring.Redf 26 | ) 27 | 28 | var severityColorFuncMap = map[Severity]severityColorFunc{ 29 | successSeverity: successSeverityColorFunc, 30 | infoSeverity: infoSeverityColorFunc, 31 | normalSeverity: normalSeverityColorFunc, 32 | debugSeverity: debugSeverityColorFunc, 33 | warnSeverity: warnSeverityColorFunc, 34 | errorSeverity: errorSeverityColorFunc, 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Bitrise 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 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/v2/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Bitrise 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 | 23 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2012-2020 Mat Ryer, Tyler Bunnell and 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/hashicorp/go-cleanhttp/doc.go: -------------------------------------------------------------------------------- 1 | // Package cleanhttp offers convenience utilities for acquiring "clean" 2 | // http.Transport and http.Client structs. 3 | // 4 | // Values set on http.DefaultClient and http.DefaultTransport affect all 5 | // callers. This can have detrimental effects, esepcially in TLS contexts, 6 | // where client or root certificates set to talk to multiple endpoints can end 7 | // up displacing each other, leading to hard-to-debug issues. This package 8 | // provides non-shared http.Client and http.Transport structs to ensure that 9 | // the configuration will not be overwritten by other parts of the application 10 | // or dependencies. 11 | // 12 | // The DefaultClient and DefaultTransport functions disable idle connections 13 | // and keepalives. Without ensuring that idle connections are closed before 14 | // garbage collection, short-term clients/transports can leak file descriptors, 15 | // eventually leading to "too many open files" errors. If you will be 16 | // connecting to the same hosts repeatedly from the same client, you can use 17 | // DefaultPooledClient to receive a client that has connection pooling 18 | // semantics similar to http.DefaultClient. 19 | // 20 | package cleanhttp 21 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2014 Stretchr, Inc. 4 | Copyright (c) 2017-2018 objx contributors 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-cleanhttp/handlers.go: -------------------------------------------------------------------------------- 1 | package cleanhttp 2 | 3 | import ( 4 | "net/http" 5 | "strings" 6 | "unicode" 7 | ) 8 | 9 | // HandlerInput provides input options to cleanhttp's handlers 10 | type HandlerInput struct { 11 | ErrStatus int 12 | } 13 | 14 | // PrintablePathCheckHandler is a middleware that ensures the request path 15 | // contains only printable runes. 16 | func PrintablePathCheckHandler(next http.Handler, input *HandlerInput) http.Handler { 17 | // Nil-check on input to make it optional 18 | if input == nil { 19 | input = &HandlerInput{ 20 | ErrStatus: http.StatusBadRequest, 21 | } 22 | } 23 | 24 | // Default to http.StatusBadRequest on error 25 | if input.ErrStatus == 0 { 26 | input.ErrStatus = http.StatusBadRequest 27 | } 28 | 29 | return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { 30 | if r != nil { 31 | // Check URL path for non-printable characters 32 | idx := strings.IndexFunc(r.URL.Path, func(c rune) bool { 33 | return !unicode.IsPrint(c) 34 | }) 35 | 36 | if idx != -1 { 37 | w.WriteHeader(input.ErrStatus) 38 | return 39 | } 40 | 41 | if next != nil { 42 | next.ServeHTTP(w, r) 43 | } 44 | } 45 | 46 | return 47 | }) 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/v2/env/env.go: -------------------------------------------------------------------------------- 1 | package env 2 | 3 | import ( 4 | "os" 5 | "os/exec" 6 | ) 7 | 8 | // CommandLocator ... 9 | type CommandLocator interface { 10 | LookPath(file string) (string, error) 11 | } 12 | 13 | type commandLocator struct{} 14 | 15 | // NewCommandLocator ... 16 | func NewCommandLocator() CommandLocator { 17 | return commandLocator{} 18 | } 19 | 20 | // LookPath ... 21 | func (l commandLocator) LookPath(file string) (string, error) { 22 | return exec.LookPath(file) 23 | } 24 | 25 | // Repository ... 26 | type Repository interface { 27 | List() []string 28 | Unset(key string) error 29 | Get(key string) string 30 | Set(key, value string) error 31 | } 32 | 33 | // NewRepository ... 34 | func NewRepository() Repository { 35 | return repository{} 36 | } 37 | 38 | type repository struct{} 39 | 40 | // Get ... 41 | func (d repository) Get(key string) string { 42 | return os.Getenv(key) 43 | } 44 | 45 | // Set ... 46 | func (d repository) Set(key, value string) error { 47 | return os.Setenv(key, value) 48 | } 49 | 50 | // Unset ... 51 | func (d repository) Unset(key string) error { 52 | return os.Unsetenv(key) 53 | } 54 | 55 | // List ... 56 | func (d repository) List() []string { 57 | return os.Environ() 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/require/requirements.go: -------------------------------------------------------------------------------- 1 | package require 2 | 3 | // TestingT is an interface wrapper around *testing.T 4 | type TestingT interface { 5 | Errorf(format string, args ...interface{}) 6 | FailNow() 7 | } 8 | 9 | type tHelper interface { 10 | Helper() 11 | } 12 | 13 | // ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful 14 | // for table driven tests. 15 | type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) 16 | 17 | // ValueAssertionFunc is a common function prototype when validating a single value. Can be useful 18 | // for table driven tests. 19 | type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) 20 | 21 | // BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful 22 | // for table driven tests. 23 | type BoolAssertionFunc func(TestingT, bool, ...interface{}) 24 | 25 | // ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful 26 | // for table driven tests. 27 | type ErrorAssertionFunc func(TestingT, error, ...interface{}) 28 | 29 | //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=require -template=require.go.tmpl -include-format-funcs" 30 | -------------------------------------------------------------------------------- /mocks/Factory.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery v2.20.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import ( 6 | command "github.com/bitrise-io/go-utils/v2/command" 7 | mock "github.com/stretchr/testify/mock" 8 | ) 9 | 10 | // Factory is an autogenerated mock type for the Factory type 11 | type Factory struct { 12 | mock.Mock 13 | } 14 | 15 | // Create provides a mock function with given fields: name, args, opts 16 | func (_m *Factory) Create(name string, args []string, opts *command.Opts) command.Command { 17 | ret := _m.Called(name, args, opts) 18 | 19 | var r0 command.Command 20 | if rf, ok := ret.Get(0).(func(string, []string, *command.Opts) command.Command); ok { 21 | r0 = rf(name, args, opts) 22 | } else { 23 | if ret.Get(0) != nil { 24 | r0 = ret.Get(0).(command.Command) 25 | } 26 | } 27 | 28 | return r0 29 | } 30 | 31 | type mockConstructorTestingTNewFactory interface { 32 | mock.TestingT 33 | Cleanup(func()) 34 | } 35 | 36 | // NewFactory creates a new instance of Factory. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. 37 | func NewFactory(t mockConstructorTestingTNewFactory) *Factory { 38 | mock := &Factory{} 39 | mock.Mock.Test(t) 40 | 41 | t.Cleanup(func() { mock.AssertExpectations(t) }) 42 | 43 | return mock 44 | } 45 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 2 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 3 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 5 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 6 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 7 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 8 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 9 | github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= 10 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 11 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 12 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 13 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 14 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 15 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 16 | -------------------------------------------------------------------------------- /vendor/github.com/kballard/go-shellquote/README: -------------------------------------------------------------------------------- 1 | PACKAGE 2 | 3 | package shellquote 4 | import "github.com/kballard/go-shellquote" 5 | 6 | Shellquote provides utilities for joining/splitting strings using sh's 7 | word-splitting rules. 8 | 9 | VARIABLES 10 | 11 | var ( 12 | UnterminatedSingleQuoteError = errors.New("Unterminated single-quoted string") 13 | UnterminatedDoubleQuoteError = errors.New("Unterminated double-quoted string") 14 | UnterminatedEscapeError = errors.New("Unterminated backslash-escape") 15 | ) 16 | 17 | 18 | FUNCTIONS 19 | 20 | func Join(args ...string) string 21 | Join quotes each argument and joins them with a space. If passed to 22 | /bin/sh, the resulting string will be split back into the original 23 | arguments. 24 | 25 | func Split(input string) (words []string, err error) 26 | Split splits a string according to /bin/sh's word-splitting rules. It 27 | supports backslash-escapes, single-quotes, and double-quotes. Notably it 28 | does not support the $'' style of quoting. It also doesn't attempt to 29 | perform any other sort of expansion, including brace expansion, shell 30 | expansion, or pathname expansion. 31 | 32 | If the given input has an unterminated quoted string or ends in a 33 | backslash-escape, one of UnterminatedSingleQuoteError, 34 | UnterminatedDoubleQuoteError, or UnterminatedEscapeError is returned. 35 | 36 | 37 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/sliceutil/sliceutil.go: -------------------------------------------------------------------------------- 1 | package sliceutil 2 | 3 | import "strings" 4 | 5 | // UniqueStringSlice - returns a cleaned up list, 6 | // where every item is unique. 7 | // Does NOT guarantee any ordering, the result can 8 | // be in any order! 9 | func UniqueStringSlice(strs []string) []string { 10 | lookupMap := map[string]interface{}{} 11 | for _, aStr := range strs { 12 | lookupMap[aStr] = 1 13 | } 14 | uniqueStrs := []string{} 15 | for k := range lookupMap { 16 | uniqueStrs = append(uniqueStrs, k) 17 | } 18 | return uniqueStrs 19 | } 20 | 21 | // IndexOfStringInSlice ... 22 | func IndexOfStringInSlice(searchFor string, searchIn []string) int { 23 | for idx, anItm := range searchIn { 24 | if anItm == searchFor { 25 | return idx 26 | } 27 | } 28 | return -1 29 | } 30 | 31 | // IsStringInSlice ... 32 | func IsStringInSlice(searchFor string, searchIn []string) bool { 33 | return IndexOfStringInSlice(searchFor, searchIn) >= 0 34 | } 35 | 36 | // CleanWhitespace removes leading and trailing white space from each element of the input slice. 37 | // Elements that end up as empty strings are excluded from the result depending on the value of the omitEmpty flag. 38 | func CleanWhitespace(list []string, omitEmpty bool) (items []string) { 39 | for _, e := range list { 40 | e = strings.TrimSpace(e) 41 | if !omitEmpty || len(e) > 0 { 42 | items = append(items, e) 43 | } 44 | } 45 | return 46 | } 47 | -------------------------------------------------------------------------------- /bitrise.yml: -------------------------------------------------------------------------------- 1 | format_version: "11" 2 | default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git 3 | 4 | workflows: 5 | check: 6 | steps: 7 | - git::https://github.com/bitrise-steplib/steps-check.git: { } 8 | 9 | e2e: 10 | steps: 11 | - git::https://github.com/bitrise-steplib/steps-check.git: 12 | inputs: 13 | - workflow: e2e 14 | 15 | generate_readme: 16 | steps: 17 | - git::https://github.com/bitrise-steplib/steps-readme-generator.git@main: { } 18 | 19 | sample: 20 | envs: 21 | - GRADLE_BUILD_FILE_PATH: build.gradle 22 | - GRADLEW_PATH: ./gradlew 23 | steps: 24 | - script: 25 | inputs: 26 | - content: |- 27 | #!/usr/bin/env bash 28 | set -e 29 | rm -rf ./_tmp 30 | - change-workdir: 31 | title: Switch working dir to test / _tmp dir 32 | run_if: "true" 33 | inputs: 34 | - path: ./_tmp 35 | - is_create_path: true 36 | - git::https://github.com/bitrise-steplib/bitrise-step-simple-git-clone.git@master: 37 | inputs: 38 | - repository_url: https://github.com/bitrise-io/sample-apps-android-sdk22.git 39 | - clone_into_dir: . 40 | - branch: master 41 | - path::./: 42 | title: Execute step 43 | inputs: 44 | - gradlew_dependencies_options: --configuration-cache-problems=warn 45 | - gradle-runner: 46 | inputs: 47 | - gradle_task: assembleDebug 48 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/log/defaultlogger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | // DefaultLogger ... 4 | type DefaultLogger struct { 5 | ts bool 6 | } 7 | 8 | // NewDefaultLogger ... 9 | func NewDefaultLogger(withTimestamp bool) DefaultLogger { 10 | return DefaultLogger{withTimestamp} 11 | } 12 | 13 | // Donef ... 14 | func (dl DefaultLogger) Donef(format string, v ...interface{}) { 15 | fSelect(dl.ts, TDonef, Donef)(format, v...) 16 | } 17 | 18 | // Successf ... 19 | func (dl DefaultLogger) Successf(format string, v ...interface{}) { 20 | fSelect(dl.ts, TSuccessf, Successf)(format, v...) 21 | } 22 | 23 | // Infof ... 24 | func (dl DefaultLogger) Infof(format string, v ...interface{}) { 25 | fSelect(dl.ts, TInfof, Infof)(format, v...) 26 | } 27 | 28 | // Printf ... 29 | func (dl DefaultLogger) Printf(format string, v ...interface{}) { 30 | fSelect(dl.ts, TPrintf, Printf)(format, v...) 31 | } 32 | 33 | // Warnf ... 34 | func (dl DefaultLogger) Warnf(format string, v ...interface{}) { 35 | fSelect(dl.ts, TWarnf, Warnf)(format, v...) 36 | } 37 | 38 | // Errorf ... 39 | func (dl DefaultLogger) Errorf(format string, v ...interface{}) { 40 | fSelect(dl.ts, TErrorf, Errorf)(format, v...) 41 | } 42 | 43 | // Debugf ... 44 | func (dl DefaultLogger) Debugf(format string, v ...interface{}) { 45 | if enableDebugLog { 46 | fSelect(dl.ts, TDebugf, Debugf)(format, v...) 47 | } 48 | } 49 | 50 | type logfunc func(string, ...interface{}) 51 | 52 | func fSelect(t bool, tf logfunc, f logfunc) logfunc { 53 | if t { 54 | return tf 55 | } 56 | return f 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/doc.go: -------------------------------------------------------------------------------- 1 | // Package assert provides a set of comprehensive testing tools for use with the normal Go testing system. 2 | // 3 | // # Example Usage 4 | // 5 | // The following is a complete example using assert in a standard test function: 6 | // 7 | // import ( 8 | // "testing" 9 | // "github.com/stretchr/testify/assert" 10 | // ) 11 | // 12 | // func TestSomething(t *testing.T) { 13 | // 14 | // var a string = "Hello" 15 | // var b string = "Hello" 16 | // 17 | // assert.Equal(t, a, b, "The two words should be the same.") 18 | // 19 | // } 20 | // 21 | // if you assert many times, use the format below: 22 | // 23 | // import ( 24 | // "testing" 25 | // "github.com/stretchr/testify/assert" 26 | // ) 27 | // 28 | // func TestSomething(t *testing.T) { 29 | // assert := assert.New(t) 30 | // 31 | // var a string = "Hello" 32 | // var b string = "Hello" 33 | // 34 | // assert.Equal(a, b, "The two words should be the same.") 35 | // } 36 | // 37 | // # Assertions 38 | // 39 | // Assertions allow you to easily write test code, and are global funcs in the `assert` package. 40 | // All assertion functions take, as the first argument, the `*testing.T` object provided by the 41 | // testing framework. This allows the assertion funcs to write the failings and other details to 42 | // the correct place. 43 | // 44 | // Every assertion function also takes an optional string message as the final argument, 45 | // allowing custom error messages to be appended to the message the assertion method outputs. 46 | package assert 47 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-cleanhttp/README.md: -------------------------------------------------------------------------------- 1 | # cleanhttp 2 | 3 | Functions for accessing "clean" Go http.Client values 4 | 5 | ------------- 6 | 7 | The Go standard library contains a default `http.Client` called 8 | `http.DefaultClient`. It is a common idiom in Go code to start with 9 | `http.DefaultClient` and tweak it as necessary, and in fact, this is 10 | encouraged; from the `http` package documentation: 11 | 12 | > The Client's Transport typically has internal state (cached TCP connections), 13 | so Clients should be reused instead of created as needed. Clients are safe for 14 | concurrent use by multiple goroutines. 15 | 16 | Unfortunately, this is a shared value, and it is not uncommon for libraries to 17 | assume that they are free to modify it at will. With enough dependencies, it 18 | can be very easy to encounter strange problems and race conditions due to 19 | manipulation of this shared value across libraries and goroutines (clients are 20 | safe for concurrent use, but writing values to the client struct itself is not 21 | protected). 22 | 23 | Making things worse is the fact that a bare `http.Client` will use a default 24 | `http.Transport` called `http.DefaultTransport`, which is another global value 25 | that behaves the same way. So it is not simply enough to replace 26 | `http.DefaultClient` with `&http.Client{}`. 27 | 28 | This repository provides some simple functions to get a "clean" `http.Client` 29 | -- one that uses the same default values as the Go standard library, but 30 | returns a client that does not share any state with other clients. 31 | -------------------------------------------------------------------------------- /vendor/github.com/pmezard/go-difflib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Patrick Mezard 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | The names of its contributors may not be used to endorse or promote 14 | products derived from this software without specific prior written 15 | permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 18 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-retryablehttp/roundtripper.go: -------------------------------------------------------------------------------- 1 | package retryablehttp 2 | 3 | import ( 4 | "errors" 5 | "net/http" 6 | "net/url" 7 | "sync" 8 | ) 9 | 10 | // RoundTripper implements the http.RoundTripper interface, using a retrying 11 | // HTTP client to execute requests. 12 | // 13 | // It is important to note that retryablehttp doesn't always act exactly as a 14 | // RoundTripper should. This is highly dependent on the retryable client's 15 | // configuration. 16 | type RoundTripper struct { 17 | // The client to use during requests. If nil, the default retryablehttp 18 | // client and settings will be used. 19 | Client *Client 20 | 21 | // once ensures that the logic to initialize the default client runs at 22 | // most once, in a single thread. 23 | once sync.Once 24 | } 25 | 26 | // init initializes the underlying retryable client. 27 | func (rt *RoundTripper) init() { 28 | if rt.Client == nil { 29 | rt.Client = NewClient() 30 | } 31 | } 32 | 33 | // RoundTrip satisfies the http.RoundTripper interface. 34 | func (rt *RoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { 35 | rt.once.Do(rt.init) 36 | 37 | // Convert the request to be retryable. 38 | retryableReq, err := FromRequest(req) 39 | if err != nil { 40 | return nil, err 41 | } 42 | 43 | // Execute the request. 44 | resp, err := rt.Client.Do(retryableReq) 45 | // If we got an error returned by standard library's `Do` method, unwrap it 46 | // otherwise we will wind up erroneously re-nesting the error. 47 | if _, ok := err.(*url.Error); ok { 48 | return resp, errors.Unwrap(err) 49 | } 50 | 51 | return resp, err 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/v2/errorutil/formatted_error.go: -------------------------------------------------------------------------------- 1 | package errorutil 2 | 3 | import ( 4 | "errors" 5 | "strings" 6 | ) 7 | 8 | // FormattedError ... 9 | func FormattedError(err error) string { 10 | var formatted string 11 | 12 | i := -1 13 | for { 14 | i++ 15 | 16 | reason := err.Error() 17 | 18 | if err = errors.Unwrap(err); err == nil { 19 | formatted = appendError(formatted, reason, i, true) 20 | return formatted 21 | } 22 | 23 | reason = strings.TrimSuffix(reason, err.Error()) 24 | reason = strings.TrimRight(reason, " ") 25 | reason = strings.TrimSuffix(reason, ":") 26 | 27 | formatted = appendError(formatted, reason, i, false) 28 | } 29 | } 30 | 31 | func appendError(errorMessage, reason string, i int, last bool) string { 32 | if i == 0 { 33 | errorMessage = indentedReason(reason, i) 34 | } else { 35 | errorMessage += "\n" 36 | errorMessage += indentedReason(reason, i) 37 | } 38 | 39 | if !last { 40 | errorMessage += ":" 41 | } 42 | 43 | return errorMessage 44 | } 45 | 46 | func indentedReason(reason string, level int) string { 47 | var lines []string 48 | split := strings.Split(reason, "\n") 49 | for _, line := range split { 50 | line = strings.TrimLeft(line, " ") 51 | line = strings.TrimRight(line, "\n") 52 | line = strings.TrimRight(line, " ") 53 | if line == "" { 54 | continue 55 | } 56 | lines = append(lines, line) 57 | } 58 | 59 | var indented string 60 | for i, line := range lines { 61 | indented += strings.Repeat(" ", level) 62 | indented += line 63 | if i != len(lines)-1 { 64 | indented += "\n" 65 | } 66 | } 67 | return indented 68 | } 69 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/mock/doc.go: -------------------------------------------------------------------------------- 1 | // Package mock provides a system by which it is possible to mock your objects 2 | // and verify calls are happening as expected. 3 | // 4 | // # Example Usage 5 | // 6 | // The mock package provides an object, Mock, that tracks activity on another object. It is usually 7 | // embedded into a test object as shown below: 8 | // 9 | // type MyTestObject struct { 10 | // // add a Mock object instance 11 | // mock.Mock 12 | // 13 | // // other fields go here as normal 14 | // } 15 | // 16 | // When implementing the methods of an interface, you wire your functions up 17 | // to call the Mock.Called(args...) method, and return the appropriate values. 18 | // 19 | // For example, to mock a method that saves the name and age of a person and returns 20 | // the year of their birth or an error, you might write this: 21 | // 22 | // func (o *MyTestObject) SavePersonDetails(firstname, lastname string, age int) (int, error) { 23 | // args := o.Called(firstname, lastname, age) 24 | // return args.Int(0), args.Error(1) 25 | // } 26 | // 27 | // The Int, Error and Bool methods are examples of strongly typed getters that take the argument 28 | // index position. Given this argument list: 29 | // 30 | // (12, true, "Something") 31 | // 32 | // You could read them out strongly typed like this: 33 | // 34 | // args.Int(0) 35 | // args.Bool(1) 36 | // args.String(2) 37 | // 38 | // For objects of your own type, use the generic Arguments.Get(index) method and make a type assertion: 39 | // 40 | // return args.Get(0).(*MyObject), args.Get(1).(*AnotherObjectOfMine) 41 | // 42 | // This may cause a panic if the object you are getting is nil (the type assertion will fail), in those 43 | // cases you should check for nil first. 44 | package mock 45 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/command/file.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "errors" 5 | "os" 6 | "strings" 7 | 8 | "github.com/bitrise-io/go-utils/pathutil" 9 | ) 10 | 11 | // CopyFile ... 12 | func CopyFile(src, dst string) error { 13 | // replace with a pure Go implementation? 14 | // Golang proposal was: https://go-review.googlesource.com/#/c/1591/5/src/io/ioutil/ioutil.go 15 | isDir, err := pathutil.IsDirExists(src) 16 | if err != nil { 17 | return err 18 | } 19 | if isDir { 20 | return errors.New("Source is a directory: " + src) 21 | } 22 | args := []string{src, dst} 23 | return RunCommand("rsync", args...) 24 | } 25 | 26 | // CopyDir ... 27 | func CopyDir(src, dst string, isOnlyContent bool) error { 28 | if isOnlyContent && !strings.HasSuffix(src, "/") { 29 | src = src + "/" 30 | } 31 | args := []string{"-ar", src, dst} 32 | return RunCommand("rsync", args...) 33 | } 34 | 35 | // RemoveDir ... 36 | // Deprecated: use RemoveAll instead. 37 | func RemoveDir(dirPth string) error { 38 | if exist, err := pathutil.IsPathExists(dirPth); err != nil { 39 | return err 40 | } else if exist { 41 | if err := os.RemoveAll(dirPth); err != nil { 42 | return err 43 | } 44 | } 45 | return nil 46 | } 47 | 48 | // RemoveFile ... 49 | // Deprecated: use RemoveAll instead. 50 | func RemoveFile(pth string) error { 51 | if exist, err := pathutil.IsPathExists(pth); err != nil { 52 | return err 53 | } else if exist { 54 | if err := os.Remove(pth); err != nil { 55 | return err 56 | } 57 | } 58 | return nil 59 | } 60 | 61 | // RemoveAll removes recursively every file on the given paths. 62 | func RemoveAll(pths ...string) error { 63 | for _, pth := range pths { 64 | if err := os.RemoveAll(pth); err != nil { 65 | return err 66 | } 67 | } 68 | return nil 69 | } 70 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypasssafe.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2016 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is running on Google App Engine, compiled by GopherJS, or 17 | // "-tags safe" is added to the go build command line. The "disableunsafe" 18 | // tag is deprecated and thus should not be used. 19 | // +build js appengine safe disableunsafe !go1.4 20 | 21 | package spew 22 | 23 | import "reflect" 24 | 25 | const ( 26 | // UnsafeDisabled is a build-time constant which specifies whether or 27 | // not access to the unsafe package is available. 28 | UnsafeDisabled = true 29 | ) 30 | 31 | // unsafeReflectValue typically converts the passed reflect.Value into a one 32 | // that bypasses the typical safety restrictions preventing access to 33 | // unaddressable and unexported data. However, doing this relies on access to 34 | // the unsafe package. This is a stub version which simply returns the passed 35 | // reflect.Value when the unsafe package is not available. 36 | func unsafeReflectValue(v reflect.Value) reflect.Value { 37 | return v 38 | } 39 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/writerc.go: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2011-2019 Canonical Ltd 3 | // Copyright (c) 2006-2010 Kirill Simonov 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files (the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | // of the Software, and to permit persons to whom the Software is furnished to do 10 | // 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 | 23 | package yaml 24 | 25 | // Set the writer error and return false. 26 | func yaml_emitter_set_writer_error(emitter *yaml_emitter_t, problem string) bool { 27 | emitter.error = yaml_WRITER_ERROR 28 | emitter.problem = problem 29 | return false 30 | } 31 | 32 | // Flush the output buffer. 33 | func yaml_emitter_flush(emitter *yaml_emitter_t) bool { 34 | if emitter.write_handler == nil { 35 | panic("write handler not set") 36 | } 37 | 38 | // Check if the buffer is empty. 39 | if emitter.buffer_pos == 0 { 40 | return true 41 | } 42 | 43 | if err := emitter.write_handler(emitter, emitter.buffer[:emitter.buffer_pos]); err != nil { 44 | return yaml_emitter_set_writer_error(emitter, "write error: "+err.Error()) 45 | } 46 | emitter.buffer_pos = 0 47 | return true 48 | } 49 | -------------------------------------------------------------------------------- /vendor/modules.txt: -------------------------------------------------------------------------------- 1 | # github.com/bitrise-io/go-android v1.0.0 2 | ## explicit 3 | github.com/bitrise-io/go-android/sdk 4 | github.com/bitrise-io/go-android/sdkcomponent 5 | github.com/bitrise-io/go-android/sdkmanager 6 | # github.com/bitrise-io/go-steputils v1.0.1 7 | ## explicit 8 | github.com/bitrise-io/go-steputils/stepconf 9 | github.com/bitrise-io/go-steputils/tools 10 | # github.com/bitrise-io/go-utils v1.0.1 11 | ## explicit 12 | github.com/bitrise-io/go-utils/colorstring 13 | github.com/bitrise-io/go-utils/command 14 | github.com/bitrise-io/go-utils/fileutil 15 | github.com/bitrise-io/go-utils/log 16 | github.com/bitrise-io/go-utils/parseutil 17 | github.com/bitrise-io/go-utils/pathutil 18 | github.com/bitrise-io/go-utils/pointers 19 | github.com/bitrise-io/go-utils/retry 20 | github.com/bitrise-io/go-utils/sliceutil 21 | # github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.14.0.20221208123037-ab31edd851e5 22 | ## explicit 23 | github.com/bitrise-io/go-utils/v2/command 24 | github.com/bitrise-io/go-utils/v2/env 25 | github.com/bitrise-io/go-utils/v2/errorutil 26 | github.com/bitrise-io/go-utils/v2/exitcode 27 | github.com/bitrise-io/go-utils/v2/log 28 | github.com/bitrise-io/go-utils/v2/log/colorstring 29 | # github.com/davecgh/go-spew v1.1.1 30 | github.com/davecgh/go-spew/spew 31 | # github.com/hashicorp/go-cleanhttp v0.5.2 32 | github.com/hashicorp/go-cleanhttp 33 | # github.com/hashicorp/go-retryablehttp v0.7.1 34 | github.com/hashicorp/go-retryablehttp 35 | # github.com/hashicorp/go-version v1.3.0 36 | ## explicit 37 | github.com/hashicorp/go-version 38 | # github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 39 | ## explicit 40 | github.com/kballard/go-shellquote 41 | # github.com/pmezard/go-difflib v1.0.0 42 | github.com/pmezard/go-difflib/difflib 43 | # github.com/stretchr/objx v0.5.0 44 | github.com/stretchr/objx 45 | # github.com/stretchr/testify v1.8.4 46 | ## explicit 47 | github.com/stretchr/testify/assert 48 | github.com/stretchr/testify/mock 49 | github.com/stretchr/testify/require 50 | # gopkg.in/yaml.v3 v3.0.1 51 | gopkg.in/yaml.v3 52 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-cleanhttp/cleanhttp.go: -------------------------------------------------------------------------------- 1 | package cleanhttp 2 | 3 | import ( 4 | "net" 5 | "net/http" 6 | "runtime" 7 | "time" 8 | ) 9 | 10 | // DefaultTransport returns a new http.Transport with similar default values to 11 | // http.DefaultTransport, but with idle connections and keepalives disabled. 12 | func DefaultTransport() *http.Transport { 13 | transport := DefaultPooledTransport() 14 | transport.DisableKeepAlives = true 15 | transport.MaxIdleConnsPerHost = -1 16 | return transport 17 | } 18 | 19 | // DefaultPooledTransport returns a new http.Transport with similar default 20 | // values to http.DefaultTransport. Do not use this for transient transports as 21 | // it can leak file descriptors over time. Only use this for transports that 22 | // will be re-used for the same host(s). 23 | func DefaultPooledTransport() *http.Transport { 24 | transport := &http.Transport{ 25 | Proxy: http.ProxyFromEnvironment, 26 | DialContext: (&net.Dialer{ 27 | Timeout: 30 * time.Second, 28 | KeepAlive: 30 * time.Second, 29 | DualStack: true, 30 | }).DialContext, 31 | MaxIdleConns: 100, 32 | IdleConnTimeout: 90 * time.Second, 33 | TLSHandshakeTimeout: 10 * time.Second, 34 | ExpectContinueTimeout: 1 * time.Second, 35 | ForceAttemptHTTP2: true, 36 | MaxIdleConnsPerHost: runtime.GOMAXPROCS(0) + 1, 37 | } 38 | return transport 39 | } 40 | 41 | // DefaultClient returns a new http.Client with similar default values to 42 | // http.Client, but with a non-shared Transport, idle connections disabled, and 43 | // keepalives disabled. 44 | func DefaultClient() *http.Client { 45 | return &http.Client{ 46 | Transport: DefaultTransport(), 47 | } 48 | } 49 | 50 | // DefaultPooledClient returns a new http.Client with similar default values to 51 | // http.Client, but with a shared Transport. Do not use this function for 52 | // transient clients as it can leak file descriptors over time. Only use this 53 | // for clients that will be re-used for the same host(s). 54 | func DefaultPooledClient() *http.Client { 55 | return &http.Client{ 56 | Transport: DefaultPooledTransport(), 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/retry/retry.go: -------------------------------------------------------------------------------- 1 | package retry 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | ) 7 | 8 | // Action ... 9 | type Action func(attempt uint) error 10 | 11 | // AbortableAction ... 12 | type AbortableAction func(attempt uint) (error, bool) 13 | 14 | // Model ... 15 | type Model struct { 16 | retry uint 17 | waitTime time.Duration 18 | } 19 | 20 | // Times ... 21 | func Times(retry uint) *Model { 22 | Model := Model{} 23 | return Model.Times(retry) 24 | } 25 | 26 | // Times ... 27 | func (Model *Model) Times(retry uint) *Model { 28 | Model.retry = retry 29 | return Model 30 | } 31 | 32 | // Wait ... 33 | func Wait(waitTime time.Duration) *Model { 34 | Model := Model{} 35 | return Model.Wait(waitTime) 36 | } 37 | 38 | // Wait ... 39 | func (Model *Model) Wait(waitTime time.Duration) *Model { 40 | Model.waitTime = waitTime 41 | return Model 42 | } 43 | 44 | // Try continues executing the supplied action while this action parameter returns an error and the configured 45 | // number of times has not been reached. Otherwise, it stops and returns the last received error. 46 | func (Model Model) Try(action Action) error { 47 | return Model.TryWithAbort(func(attempt uint) (error, bool) { 48 | return action(attempt), false 49 | }) 50 | } 51 | 52 | // TryWithAbort continues executing the supplied action while this action parameter returns an error, a false bool 53 | // value and the configured number of times has not been reached. Returning a true value from the action aborts the 54 | // retry loop. 55 | // 56 | // Good for retrying actions which can return a mix of retryable and non-retryable failures. 57 | func (Model Model) TryWithAbort(action AbortableAction) error { 58 | if action == nil { 59 | return fmt.Errorf("no action specified") 60 | } 61 | 62 | var err error 63 | var shouldAbort bool 64 | 65 | for attempt := uint(0); (0 == attempt || nil != err) && attempt <= Model.retry; attempt++ { 66 | if attempt > 0 && Model.waitTime > 0 { 67 | time.Sleep(Model.waitTime) 68 | } 69 | 70 | err, shouldAbort = action(attempt) 71 | 72 | if shouldAbort { 73 | break 74 | } 75 | } 76 | 77 | return err 78 | } 79 | -------------------------------------------------------------------------------- /androidcomponents/errors.go: -------------------------------------------------------------------------------- 1 | package androidcomponents 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "os/exec" 7 | ) 8 | 9 | func NewCommandError(cmd string, err error, reason string) error { 10 | var exitErr *exec.ExitError 11 | if errors.As(err, &exitErr) { 12 | if len(reason) == 0 { 13 | return NewCommandExitError(cmd, exitErr) 14 | } 15 | 16 | return NewCommandExitErrorWithReason(cmd, exitErr, reason) 17 | } 18 | 19 | return NewCommandExecutionError(cmd, err) 20 | } 21 | 22 | type CommandExecutionError struct { 23 | cmd string 24 | err error 25 | } 26 | 27 | func NewCommandExecutionError(cmd string, err error) CommandExecutionError { 28 | return CommandExecutionError{ 29 | cmd: cmd, 30 | err: err, 31 | } 32 | } 33 | 34 | func (e CommandExecutionError) Error() string { 35 | return fmt.Sprintf("executing command failed (%s): %s", e.cmd, e.err) 36 | } 37 | 38 | func (e CommandExecutionError) Unwrap() error { 39 | return e.err 40 | } 41 | 42 | type CommandExitError struct { 43 | cmd string 44 | err *exec.ExitError 45 | suggestion error 46 | } 47 | 48 | func NewCommandExitError(cmd string, err *exec.ExitError) CommandExitError { 49 | return CommandExitError{ 50 | cmd: cmd, 51 | err: err, 52 | suggestion: errors.New("check the command's output for details"), 53 | } 54 | } 55 | 56 | func (e CommandExitError) Error() string { 57 | return fmt.Sprintf("command failed with exit status %d (%s): %s", e.err.ExitCode(), e.cmd, e.suggestion) 58 | } 59 | 60 | func (e CommandExitError) Unwrap() error { 61 | return e.suggestion 62 | } 63 | 64 | type CommandExitErrorWithReason struct { 65 | cmd string 66 | err *exec.ExitError 67 | reason error 68 | } 69 | 70 | func NewCommandExitErrorWithReason(cmd string, err *exec.ExitError, reason string) CommandExitErrorWithReason { 71 | return CommandExitErrorWithReason{ 72 | cmd: cmd, 73 | err: err, 74 | reason: errors.New(reason), 75 | } 76 | } 77 | 78 | func (e CommandExitErrorWithReason) Error() string { 79 | return fmt.Sprintf("command failed with exit status %d (%s): %s", e.err.ExitCode(), e.cmd, e.reason) 80 | } 81 | 82 | func (e CommandExitErrorWithReason) Unwrap() error { 83 | return e.reason 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-version/README.md: -------------------------------------------------------------------------------- 1 | # Versioning Library for Go 2 | [![Build Status](https://circleci.com/gh/hashicorp/go-version/tree/master.svg?style=svg)](https://circleci.com/gh/hashicorp/go-version/tree/master) 3 | [![GoDoc](https://godoc.org/github.com/hashicorp/go-version?status.svg)](https://godoc.org/github.com/hashicorp/go-version) 4 | 5 | go-version is a library for parsing versions and version constraints, 6 | and verifying versions against a set of constraints. go-version 7 | can sort a collection of versions properly, handles prerelease/beta 8 | versions, can increment versions, etc. 9 | 10 | Versions used with go-version must follow [SemVer](http://semver.org/). 11 | 12 | ## Installation and Usage 13 | 14 | Package documentation can be found on 15 | [GoDoc](http://godoc.org/github.com/hashicorp/go-version). 16 | 17 | Installation can be done with a normal `go get`: 18 | 19 | ``` 20 | $ go get github.com/hashicorp/go-version 21 | ``` 22 | 23 | #### Version Parsing and Comparison 24 | 25 | ```go 26 | v1, err := version.NewVersion("1.2") 27 | v2, err := version.NewVersion("1.5+metadata") 28 | 29 | // Comparison example. There is also GreaterThan, Equal, and just 30 | // a simple Compare that returns an int allowing easy >=, <=, etc. 31 | if v1.LessThan(v2) { 32 | fmt.Printf("%s is less than %s", v1, v2) 33 | } 34 | ``` 35 | 36 | #### Version Constraints 37 | 38 | ```go 39 | v1, err := version.NewVersion("1.2") 40 | 41 | // Constraints example. 42 | constraints, err := version.NewConstraint(">= 1.0, < 1.4") 43 | if constraints.Check(v1) { 44 | fmt.Printf("%s satisfies constraints %s", v1, constraints) 45 | } 46 | ``` 47 | 48 | #### Version Sorting 49 | 50 | ```go 51 | versionsRaw := []string{"1.1", "0.7.1", "1.4-beta", "1.4", "2"} 52 | versions := make([]*version.Version, len(versionsRaw)) 53 | for i, raw := range versionsRaw { 54 | v, _ := version.NewVersion(raw) 55 | versions[i] = v 56 | } 57 | 58 | // After this, the versions are properly sorted 59 | sort.Sort(version.Collection(versions)) 60 | ``` 61 | 62 | ## Issues and Contributing 63 | 64 | If you find an issue with this library, please report an issue. If you'd 65 | like, we welcome any contributions. Fork this library and submit a pull 66 | request. 67 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/pointers/pointers.go: -------------------------------------------------------------------------------- 1 | package pointers 2 | 3 | import "time" 4 | 5 | // NewBoolPtr ... 6 | func NewBoolPtr(val bool) *bool { 7 | ptrValue := new(bool) 8 | *ptrValue = val 9 | return ptrValue 10 | } 11 | 12 | // NewStringPtr ... 13 | func NewStringPtr(val string) *string { 14 | ptrValue := new(string) 15 | *ptrValue = val 16 | return ptrValue 17 | } 18 | 19 | // NewTimePtr ... 20 | func NewTimePtr(val time.Time) *time.Time { 21 | ptrValue := new(time.Time) 22 | *ptrValue = val 23 | return ptrValue 24 | } 25 | 26 | // NewIntPtr ... 27 | func NewIntPtr(val int) *int { 28 | ptrValue := new(int) 29 | *ptrValue = val 30 | return ptrValue 31 | } 32 | 33 | // NewInt64Ptr ... 34 | func NewInt64Ptr(val int64) *int64 { 35 | ptrValue := new(int64) 36 | *ptrValue = val 37 | return ptrValue 38 | } 39 | 40 | // NewMapStringInterfacePtr ... 41 | func NewMapStringInterfacePtr(val map[string]interface{}) *map[string]interface{} { 42 | ptrValue := new(map[string]interface{}) 43 | *ptrValue = map[string]interface{}{} 44 | for key, value := range val { 45 | (*ptrValue)[key] = value 46 | } 47 | return ptrValue 48 | } 49 | 50 | // ------------------------------------------------------ 51 | // --- Safe Getters 52 | 53 | // Bool ... 54 | func Bool(val *bool) bool { 55 | return BoolWithDefault(val, false) 56 | } 57 | 58 | // BoolWithDefault ... 59 | func BoolWithDefault(val *bool, defaultValue bool) bool { 60 | if val == nil { 61 | return defaultValue 62 | } 63 | return *val 64 | } 65 | 66 | // String ... 67 | func String(val *string) string { 68 | return StringWithDefault(val, "") 69 | } 70 | 71 | // StringWithDefault ... 72 | func StringWithDefault(val *string, defaultValue string) string { 73 | if val == nil { 74 | return defaultValue 75 | } 76 | return *val 77 | } 78 | 79 | // TimeWithDefault ... 80 | func TimeWithDefault(val *time.Time, defaultValue time.Time) time.Time { 81 | if val == nil { 82 | return defaultValue 83 | } 84 | return *val 85 | } 86 | 87 | // Int ... 88 | func Int(val *int) int { 89 | return IntWithDefault(val, 0) 90 | } 91 | 92 | // IntWithDefault ... 93 | func IntWithDefault(val *int, defaultValue int) int { 94 | if val == nil { 95 | return defaultValue 96 | } 97 | return *val 98 | } 99 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/log/internal_logger.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "encoding/json" 7 | "fmt" 8 | "net/http" 9 | "time" 10 | ) 11 | 12 | var ( 13 | analyticsServerURL = "https://bitrise-step-analytics.herokuapp.com" 14 | httpClient = http.Client{ 15 | Timeout: time.Second * 5, 16 | } 17 | ) 18 | 19 | // Entry represents a line in a log 20 | type Entry struct { 21 | LogLevel string `json:"log_level"` 22 | Message string `json:"message"` 23 | Data map[string]interface{} `json:"data"` 24 | } 25 | 26 | // SetAnalyticsServerURL updates the the analytics server collecting the 27 | // logs. It is intended for use during tests. Warning: current implementation 28 | // is not thread safe, do not call the function during runtime. 29 | func SetAnalyticsServerURL(url string) { 30 | analyticsServerURL = url 31 | } 32 | 33 | // Internal sends the log message to the configured analytics server 34 | func rprintf(logLevel string, stepID string, tag string, data map[string]interface{}, format string, v ...interface{}) { 35 | e := Entry{ 36 | Message: fmt.Sprintf(format, v...), 37 | LogLevel: logLevel, 38 | } 39 | 40 | e.Data = make(map[string]interface{}) 41 | for k, v := range data { 42 | e.Data[k] = v 43 | } 44 | 45 | if v, ok := e.Data["step_id"]; ok { 46 | fmt.Printf("internal logger: data.step_id (%s) will be overriden with (%s) ", v, stepID) 47 | } 48 | if v, ok := e.Data["tag"]; ok { 49 | fmt.Printf("internal logger: data.tag (%s) will be overriden with (%s) ", v, tag) 50 | } 51 | 52 | e.Data["step_id"] = stepID 53 | e.Data["tag"] = tag 54 | 55 | var b bytes.Buffer 56 | if err := json.NewEncoder(&b).Encode(e); err != nil { 57 | return 58 | } 59 | 60 | ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second) 61 | defer cancel() 62 | 63 | req, err := http.NewRequest(http.MethodPost, analyticsServerURL+"/logs", &b) 64 | if err != nil { 65 | // deliberately not writing into users log 66 | return 67 | } 68 | req = req.WithContext(ctx) 69 | req.Header.Add("Content-Type", "application/json") 70 | 71 | if _, err := httpClient.Do(req); err != nil { 72 | // deliberately not writing into users log 73 | return 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-android/sdkmanager/sdkmanager.go: -------------------------------------------------------------------------------- 1 | package sdkmanager 2 | 3 | import ( 4 | "fmt" 5 | "path/filepath" 6 | "strings" 7 | 8 | "github.com/bitrise-io/go-android/sdk" 9 | "github.com/bitrise-io/go-android/sdkcomponent" 10 | "github.com/bitrise-io/go-utils/command" 11 | "github.com/bitrise-io/go-utils/pathutil" 12 | ) 13 | 14 | // Model ... 15 | type Model struct { 16 | androidHome string 17 | legacy bool 18 | binPth string 19 | } 20 | 21 | // New ... 22 | func New(sdk sdk.AndroidSdkInterface) (*Model, error) { 23 | cmdlineToolsPath, err := sdk.CmdlineToolsPath() 24 | if err != nil { 25 | return nil, err 26 | } 27 | 28 | sdkmanagerPath := filepath.Join(cmdlineToolsPath, "sdkmanager") 29 | if exist, err := pathutil.IsPathExists(sdkmanagerPath); err != nil { 30 | return nil, err 31 | } else if exist { 32 | return &Model{ 33 | androidHome: sdk.GetAndroidHome(), 34 | binPth: sdkmanagerPath, 35 | }, nil 36 | } 37 | 38 | legacySdkmanagerPath := filepath.Join(cmdlineToolsPath, "android") 39 | if exist, err := pathutil.IsPathExists(legacySdkmanagerPath); err != nil { 40 | return nil, err 41 | } else if exist { 42 | return &Model{ 43 | androidHome: sdk.GetAndroidHome(), 44 | legacy: true, 45 | binPth: legacySdkmanagerPath, 46 | }, nil 47 | } 48 | 49 | return nil, fmt.Errorf("no sdkmanager tool found at: %s", sdkmanagerPath) 50 | } 51 | 52 | // IsLegacySDK ... 53 | func (model Model) IsLegacySDK() bool { 54 | return model.legacy 55 | } 56 | 57 | // IsInstalled ... 58 | func (model Model) IsInstalled(component sdkcomponent.Model) (bool, error) { 59 | relPth := component.InstallPathInAndroidHome() 60 | indicatorFile := component.InstallationIndicatorFile() 61 | installPth := filepath.Join(model.androidHome, relPth) 62 | 63 | if indicatorFile != "" { 64 | installPth = filepath.Join(installPth, indicatorFile) 65 | } 66 | return pathutil.IsPathExists(installPth) 67 | } 68 | 69 | // InstallCommand ... 70 | func (model Model) InstallCommand(component sdkcomponent.Model) *command.Model { 71 | if model.legacy { 72 | return command.New(model.binPth, "update", "sdk", "--no-ui", "--all", "--filter", component.GetLegacySDKStylePath()) 73 | } 74 | cmd := command.New(model.binPth, component.GetSDKStylePath()) 75 | cmd.SetStdin(strings.NewReader("y")) 76 | return cmd 77 | } 78 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | This project is covered by two different licenses: MIT and Apache. 3 | 4 | #### MIT License #### 5 | 6 | The following files were ported to Go from C files of libyaml, and thus 7 | are still covered by their original MIT license, with the additional 8 | copyright staring in 2011 when the project was ported over: 9 | 10 | apic.go emitterc.go parserc.go readerc.go scannerc.go 11 | writerc.go yamlh.go yamlprivateh.go 12 | 13 | Copyright (c) 2006-2010 Kirill Simonov 14 | Copyright (c) 2006-2011 Kirill Simonov 15 | 16 | Permission is hereby granted, free of charge, to any person obtaining a copy of 17 | this software and associated documentation files (the "Software"), to deal in 18 | the Software without restriction, including without limitation the rights to 19 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 20 | of the Software, and to permit persons to whom the Software is furnished to do 21 | so, subject to the following conditions: 22 | 23 | The above copyright notice and this permission notice shall be included in all 24 | copies or substantial portions of the Software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 | SOFTWARE. 33 | 34 | ### Apache License ### 35 | 36 | All the remaining project files are covered by the Apache license: 37 | 38 | Copyright (c) 2011-2019 Canonical Ltd 39 | 40 | Licensed under the Apache License, Version 2.0 (the "License"); 41 | you may not use this file except in compliance with the License. 42 | You may obtain a copy of the License at 43 | 44 | http://www.apache.org/licenses/LICENSE-2.0 45 | 46 | Unless required by applicable law or agreed to in writing, software 47 | distributed under the License is distributed on an "AS IS" BASIS, 48 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 49 | See the License for the specific language governing permissions and 50 | limitations under the License. 51 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Objx - Go package for dealing with maps, slices, JSON and other data. 3 | 4 | Overview 5 | 6 | Objx provides the `objx.Map` type, which is a `map[string]interface{}` that exposes 7 | a powerful `Get` method (among others) that allows you to easily and quickly get 8 | access to data within the map, without having to worry too much about type assertions, 9 | missing data, default values etc. 10 | 11 | Pattern 12 | 13 | Objx uses a preditable pattern to make access data from within `map[string]interface{}` easy. 14 | Call one of the `objx.` functions to create your `objx.Map` to get going: 15 | 16 | m, err := objx.FromJSON(json) 17 | 18 | NOTE: Any methods or functions with the `Must` prefix will panic if something goes wrong, 19 | the rest will be optimistic and try to figure things out without panicking. 20 | 21 | Use `Get` to access the value you're interested in. You can use dot and array 22 | notation too: 23 | 24 | m.Get("places[0].latlng") 25 | 26 | Once you have sought the `Value` you're interested in, you can use the `Is*` methods to determine its type. 27 | 28 | if m.Get("code").IsStr() { // Your code... } 29 | 30 | Or you can just assume the type, and use one of the strong type methods to extract the real value: 31 | 32 | m.Get("code").Int() 33 | 34 | If there's no value there (or if it's the wrong type) then a default value will be returned, 35 | or you can be explicit about the default value. 36 | 37 | Get("code").Int(-1) 38 | 39 | If you're dealing with a slice of data as a value, Objx provides many useful methods for iterating, 40 | manipulating and selecting that data. You can find out more by exploring the index below. 41 | 42 | Reading data 43 | 44 | A simple example of how to use Objx: 45 | 46 | // Use MustFromJSON to make an objx.Map from some JSON 47 | m := objx.MustFromJSON(`{"name": "Mat", "age": 30}`) 48 | 49 | // Get the details 50 | name := m.Get("name").Str() 51 | age := m.Get("age").Int() 52 | 53 | // Get their nickname (or use their name if they don't have one) 54 | nickname := m.Get("nickname").Str(name) 55 | 56 | Ranging 57 | 58 | Since `objx.Map` is a `map[string]interface{}` you can treat it as such. 59 | For example, to `range` the data, do what you would expect: 60 | 61 | m := objx.MustFromJSON(json) 62 | for key, value := range m { 63 | // Your code... 64 | } 65 | */ 66 | package objx 67 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/mutations.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | // Exclude returns a new Map with the keys in the specified []string 4 | // excluded. 5 | func (m Map) Exclude(exclude []string) Map { 6 | excluded := make(Map) 7 | for k, v := range m { 8 | if !contains(exclude, k) { 9 | excluded[k] = v 10 | } 11 | } 12 | return excluded 13 | } 14 | 15 | // Copy creates a shallow copy of the Obj. 16 | func (m Map) Copy() Map { 17 | copied := Map{} 18 | for k, v := range m { 19 | copied[k] = v 20 | } 21 | return copied 22 | } 23 | 24 | // Merge blends the specified map with a copy of this map and returns the result. 25 | // 26 | // Keys that appear in both will be selected from the specified map. 27 | // This method requires that the wrapped object be a map[string]interface{} 28 | func (m Map) Merge(merge Map) Map { 29 | return m.Copy().MergeHere(merge) 30 | } 31 | 32 | // MergeHere blends the specified map with this map and returns the current map. 33 | // 34 | // Keys that appear in both will be selected from the specified map. The original map 35 | // will be modified. This method requires that 36 | // the wrapped object be a map[string]interface{} 37 | func (m Map) MergeHere(merge Map) Map { 38 | for k, v := range merge { 39 | m[k] = v 40 | } 41 | return m 42 | } 43 | 44 | // Transform builds a new Obj giving the transformer a chance 45 | // to change the keys and values as it goes. This method requires that 46 | // the wrapped object be a map[string]interface{} 47 | func (m Map) Transform(transformer func(key string, value interface{}) (string, interface{})) Map { 48 | newMap := Map{} 49 | for k, v := range m { 50 | modifiedKey, modifiedVal := transformer(k, v) 51 | newMap[modifiedKey] = modifiedVal 52 | } 53 | return newMap 54 | } 55 | 56 | // TransformKeys builds a new map using the specified key mapping. 57 | // 58 | // Unspecified keys will be unaltered. 59 | // This method requires that the wrapped object be a map[string]interface{} 60 | func (m Map) TransformKeys(mapping map[string]string) Map { 61 | return m.Transform(func(key string, value interface{}) (string, interface{}) { 62 | if newKey, ok := mapping[key]; ok { 63 | return newKey, value 64 | } 65 | return key, value 66 | }) 67 | } 68 | 69 | // Checks if a string slice contains a string 70 | func contains(s []string, e string) bool { 71 | for _, a := range s { 72 | if a == e { 73 | return true 74 | } 75 | } 76 | return false 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/parseutil/parseutil.go: -------------------------------------------------------------------------------- 1 | package parseutil 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "strconv" 7 | "strings" 8 | 9 | "github.com/bitrise-io/go-utils/pointers" 10 | ) 11 | 12 | // ParseBool ... 13 | func ParseBool(userInputStr string) (bool, error) { 14 | if userInputStr == "" { 15 | return false, errors.New("No string to parse") 16 | } 17 | userInputStr = strings.TrimSpace(userInputStr) 18 | 19 | lowercased := strings.ToLower(userInputStr) 20 | if lowercased == "yes" || lowercased == "y" { 21 | return true, nil 22 | } 23 | if lowercased == "no" || lowercased == "n" { 24 | return false, nil 25 | } 26 | return strconv.ParseBool(lowercased) 27 | } 28 | 29 | // CastToString ... 30 | func CastToString(value interface{}) string { 31 | casted, ok := value.(string) 32 | 33 | if !ok { 34 | castedStr := fmt.Sprintf("%v", value) 35 | casted = castedStr 36 | } 37 | 38 | return casted 39 | } 40 | 41 | // CastToStringPtr ... 42 | func CastToStringPtr(value interface{}) *string { 43 | castedValue := CastToString(value) 44 | return pointers.NewStringPtr(castedValue) 45 | } 46 | 47 | // CastToBool ... 48 | func CastToBool(value interface{}) (bool, bool) { 49 | casted, ok := value.(bool) 50 | 51 | if !ok { 52 | castedStr := CastToString(value) 53 | 54 | castedBool, err := ParseBool(castedStr) 55 | if err != nil { 56 | return false, false 57 | } 58 | 59 | casted = castedBool 60 | } 61 | 62 | return casted, true 63 | } 64 | 65 | // CastToBoolPtr ... 66 | func CastToBoolPtr(value interface{}) (*bool, bool) { 67 | castedValue, ok := CastToBool(value) 68 | if !ok { 69 | return nil, false 70 | } 71 | return pointers.NewBoolPtr(castedValue), true 72 | } 73 | 74 | // CastToMapStringInterface ... 75 | func CastToMapStringInterface(value interface{}) (map[string]interface{}, bool) { 76 | castedValue, ok := value.(map[interface{}]interface{}) 77 | desiredMap := map[string]interface{}{} 78 | for key, value := range castedValue { 79 | keyStr, ok := key.(string) 80 | if !ok { 81 | return map[string]interface{}{}, false 82 | } 83 | desiredMap[keyStr] = value 84 | } 85 | return desiredMap, ok 86 | } 87 | 88 | // CastToMapStringInterfacePtr ... 89 | func CastToMapStringInterfacePtr(value interface{}) (*map[string]interface{}, bool) { 90 | casted, ok := CastToMapStringInterface(value) 91 | if !ok { 92 | return nil, false 93 | } 94 | return pointers.NewMapStringInterfacePtr(casted), true 95 | } 96 | -------------------------------------------------------------------------------- /.github/workflows/stale-issues-workflow.yml: -------------------------------------------------------------------------------- 1 | name: Stale Issues Workflow 2 | 3 | on: 4 | # Allows manually running 5 | # https://docs.github.com/en/actions/reference/events-that-trigger-workflows#manual-events 6 | workflow_dispatch: 7 | 8 | schedule: 9 | # Runs at 08:00 UTC every day 10 | # https://docs.github.com/en/actions/reference/events-that-trigger-workflows#schedule 11 | - cron: '0 8 * * *' 12 | 13 | jobs: 14 | stale: 15 | runs-on: ubuntu-latest 16 | steps: 17 | # https://github.com/actions/stale 18 | - uses: actions/stale@v3 19 | with: 20 | repo-token: ${{ secrets.CORESTEPS_BOT_GITHUB_TOKEN }} 21 | # do not manage PRs 22 | days-before-pr-stale: -1 23 | days-before-pr-close: -1 24 | # stale issue config 25 | exempt-issue-labels: 'bug' 26 | days-before-issue-stale: 90 27 | days-before-issue-close: 21 28 | stale-issue-message: | 29 | Hello there, I'm a bot. On behalf of the community I thank you for opening this issue. 30 | 31 | To help our human contributors focus on the most relevant reports, I check up on old issues to see if they're still relevant. 32 | This issue has had no activity for 90 days, so I marked it as stale. 33 | 34 | The community would appreciate if you could check if the issue still persists. If it isn't, please close it. 35 | If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". 36 | 37 | If no comment left within 21 days, this issue will be closed. 38 | close-issue-message: > 39 | I'll close this issue as it doesn't seem to be relevant anymore. 40 | 41 | We believe an old issue probably has a bunch of context that's no longer relevant, therefore, if the problem still persists, please open a new issue. 42 | stale-issue-label: stale 43 | # https://github.com/jakejarvis/wait-action 44 | # Wait 1m to make sure lock-threads will actually lock the issue where stale just recently left a message. 45 | - uses: jakejarvis/wait-action@master 46 | with: 47 | time: '1m' 48 | # https://github.com/dessant/lock-threads 49 | - uses: dessant/lock-threads@v2 50 | with: 51 | github-token: ${{ secrets.CORESTEPS_BOT_GITHUB_TOKEN }} 52 | # do not manage PRs 53 | process-only: issues 54 | # stale issue config 55 | issue-lock-inactive-days: 0 # immediately lock closed issues 56 | issue-lock-reason: '' 57 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/command/zip.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "archive/zip" 5 | "errors" 6 | "io" 7 | "log" 8 | "net/http" 9 | "os" 10 | "path/filepath" 11 | 12 | "github.com/bitrise-io/go-utils/pathutil" 13 | ) 14 | 15 | // UnZIP ... 16 | func UnZIP(src, dest string) error { 17 | r, err := zip.OpenReader(src) 18 | if err != nil { 19 | return err 20 | } 21 | defer func() { 22 | if err := r.Close(); err != nil { 23 | log.Fatal(err) 24 | } 25 | }() 26 | 27 | if err := os.MkdirAll(dest, 0755); err != nil { 28 | return err 29 | } 30 | 31 | // Closure to address file descriptors issue with all the deferred .Close() methods 32 | extractAndWriteFile := func(f *zip.File) error { 33 | rc, err := f.Open() 34 | if err != nil { 35 | return err 36 | } 37 | defer func() { 38 | if err := rc.Close(); err != nil { 39 | log.Fatal(err) 40 | } 41 | }() 42 | 43 | path := filepath.Join(dest, f.Name) 44 | 45 | if f.FileInfo().IsDir() { 46 | if err := os.MkdirAll(path, f.Mode()); err != nil { 47 | return err 48 | } 49 | } else { 50 | f, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode()) 51 | if err != nil { 52 | return err 53 | } 54 | defer func() { 55 | if err := f.Close(); err != nil { 56 | log.Fatal(err) 57 | } 58 | }() 59 | 60 | if _, err = io.Copy(f, rc); err != nil { 61 | return err 62 | } 63 | } 64 | return nil 65 | } 66 | 67 | for _, f := range r.File { 68 | if err := extractAndWriteFile(f); err != nil { 69 | return err 70 | } 71 | } 72 | return nil 73 | } 74 | 75 | // DownloadAndUnZIP ... 76 | func DownloadAndUnZIP(url, pth string) error { 77 | tmpDir, err := pathutil.NormalizedOSTempDirPath("") 78 | if err != nil { 79 | return err 80 | } 81 | srcFilePath := tmpDir + "/target.zip" 82 | srcFile, err := os.Create(srcFilePath) 83 | if err != nil { 84 | return err 85 | } 86 | defer func() { 87 | if err := srcFile.Close(); err != nil { 88 | log.Fatal("Failed to close srcFile:", err) 89 | } 90 | if err := os.Remove(srcFilePath); err != nil { 91 | log.Fatal("Failed to remove srcFile:", err) 92 | } 93 | }() 94 | 95 | response, err := http.Get(url) 96 | if err != nil { 97 | return err 98 | } 99 | defer func() { 100 | if err := response.Body.Close(); err != nil { 101 | log.Fatal("Failed to close response body:", err) 102 | } 103 | }() 104 | 105 | if response.StatusCode != http.StatusOK { 106 | errorMsg := "Failed to download target from: " + url 107 | return errors.New(errorMsg) 108 | } 109 | 110 | if _, err := io.Copy(srcFile, response.Body); err != nil { 111 | return err 112 | } 113 | 114 | return UnZIP(srcFilePath, pth) 115 | } 116 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## Changelog (Current version: 2.2.0) 2 | 3 | ----------------- 4 | 5 | ### 2.2.0 (2018 Jun 04) 6 | 7 | * [b2e3e76] Prepare for 2.2.0 8 | * [26ec1c8] added ndk install (#36) 9 | * [5951123] Revision of the code base (#34) 10 | 11 | ### 2.1.1 (2018 Jan 26) 12 | 13 | * [cca8c8e] Bump version to 2.1.1 14 | * [8207e2b] Install support repositories and missing packages (#32) 15 | 16 | ### 2.1.0 (2018 Jan 16) 17 | 18 | * [27c92fc] prepare for 2.1.0 19 | * [6bd3b24] removed unused `root_build_gradle_file` input, migrate to dep (#31) 20 | 21 | ### 2.0.6 (2017 Dec 01) 22 | 23 | * [d799948] Bump version to 2.0.6 24 | * [624d19a] Merge pull request #30 from bitrise-steplib/plugin-version 25 | * [1485576] Add newline for step description 26 | * [4a9c7e8] Fix step description ambiguity 27 | 28 | ### 2.0.5 (2017 Nov 08) 29 | 30 | * [e812bc5] Prepare for 2.0.5 31 | * [c4d7112] removed log if --licenses command fails (#28) 32 | 33 | ### 2.0.4 (2017 Oct 27) 34 | 35 | * [43326f4] Prepare for 2.0.4 36 | * [d461077] added sdkmanager --licenses ensure (#27) 37 | 38 | ### 2.0.3 (2017 Oct 11) 39 | 40 | * [565850b] Prepare for 2.0.3 41 | * [7b4120f] Merge pull request #23 from bitrise-steplib/fix/sdkmanager-licenses 42 | * [e1961a9] Overwrite license files 43 | * [e8dff36] Fix licenses 44 | 45 | ### 2.0.2 (2017 Sep 05) 46 | 47 | * [6cc4e5c] prepare for 2.0.2 48 | * [69ede6a] mkdirall for licences directory (#19) 49 | 50 | ### 2.0.1 (2017 Aug 24) 51 | 52 | * [d64cd62] preparer for 2.0.1 53 | * [8b61805] Update (#18) 54 | 55 | ### 2.0.0 (2017 Aug 23) 56 | 57 | * [cfee6c0] prepare for 2.0.0 58 | * [d58c477] use `gradle dependencies` command to install missing components (#16) 59 | 60 | ### 1.1.0 (2017 Aug 10) 61 | 62 | * [f5128a1] prepare for 1.1.0 63 | * [59f4c88] handle project without modeles, solve not semver buildToolsVersion (#15) 64 | 65 | ### 1.0.3 (2017 Jun 12) 66 | 67 | * [aa55688] prepare for 1.0.3 68 | * [20ad08b] input grouping and reordering (#14) 69 | * [1d208ca] Revert "input grouping and reordering" 70 | * [2440ff0] input grouping and reordering 71 | 72 | ### 1.0.2 (2017 Apr 25) 73 | 74 | * [0c77f31] prepare for 1.0.2 75 | * [6160a2d] Typofixes in console messages (#12) 76 | 77 | ### 1.0.1 (2017 Mar 28) 78 | 79 | * [64598f0] Prepare for 1.0.1 80 | * [d22d5aa] Symlink issue fixed (#10) 81 | 82 | ### 1.0.0 (2017 Mar 23) 83 | 84 | * [a94a1b8] prepare for 1.0.0 85 | * [b83bfd6] extended analyzer (#8) 86 | * [efdfe9b] go-android packages (#7) 87 | 88 | ### 0.9.2 (2017 Jan 18) 89 | 90 | * [860c7ac] prepare for 0.9.2 91 | * [703d787] anaylzer test, regexp improvements (#3) 92 | 93 | ### 0.9.1 (2017 Jan 17) 94 | 95 | * [4ac2135] prepare for 0.9.1 96 | * [ab48d0c] root_build_gradle_file (#2) 97 | 98 | ----------------- 99 | 100 | Updated: 2018 Jun 04 -------------------------------------------------------------------------------- /vendor/github.com/kballard/go-shellquote/quote.go: -------------------------------------------------------------------------------- 1 | package shellquote 2 | 3 | import ( 4 | "bytes" 5 | "strings" 6 | "unicode/utf8" 7 | ) 8 | 9 | // Join quotes each argument and joins them with a space. 10 | // If passed to /bin/sh, the resulting string will be split back into the 11 | // original arguments. 12 | func Join(args ...string) string { 13 | var buf bytes.Buffer 14 | for i, arg := range args { 15 | if i != 0 { 16 | buf.WriteByte(' ') 17 | } 18 | quote(arg, &buf) 19 | } 20 | return buf.String() 21 | } 22 | 23 | const ( 24 | specialChars = "\\'\"`${[|&;<>()*?!" 25 | extraSpecialChars = " \t\n" 26 | prefixChars = "~" 27 | ) 28 | 29 | func quote(word string, buf *bytes.Buffer) { 30 | // We want to try to produce a "nice" output. As such, we will 31 | // backslash-escape most characters, but if we encounter a space, or if we 32 | // encounter an extra-special char (which doesn't work with 33 | // backslash-escaping) we switch over to quoting the whole word. We do this 34 | // with a space because it's typically easier for people to read multi-word 35 | // arguments when quoted with a space rather than with ugly backslashes 36 | // everywhere. 37 | origLen := buf.Len() 38 | 39 | if len(word) == 0 { 40 | // oops, no content 41 | buf.WriteString("''") 42 | return 43 | } 44 | 45 | cur, prev := word, word 46 | atStart := true 47 | for len(cur) > 0 { 48 | c, l := utf8.DecodeRuneInString(cur) 49 | cur = cur[l:] 50 | if strings.ContainsRune(specialChars, c) || (atStart && strings.ContainsRune(prefixChars, c)) { 51 | // copy the non-special chars up to this point 52 | if len(cur) < len(prev) { 53 | buf.WriteString(prev[0 : len(prev)-len(cur)-l]) 54 | } 55 | buf.WriteByte('\\') 56 | buf.WriteRune(c) 57 | prev = cur 58 | } else if strings.ContainsRune(extraSpecialChars, c) { 59 | // start over in quote mode 60 | buf.Truncate(origLen) 61 | goto quote 62 | } 63 | atStart = false 64 | } 65 | if len(prev) > 0 { 66 | buf.WriteString(prev) 67 | } 68 | return 69 | 70 | quote: 71 | // quote mode 72 | // Use single-quotes, but if we find a single-quote in the word, we need 73 | // to terminate the string, emit an escaped quote, and start the string up 74 | // again 75 | inQuote := false 76 | for len(word) > 0 { 77 | i := strings.IndexRune(word, '\'') 78 | if i == -1 { 79 | break 80 | } 81 | if i > 0 { 82 | if !inQuote { 83 | buf.WriteByte('\'') 84 | inQuote = true 85 | } 86 | buf.WriteString(word[0:i]) 87 | } 88 | word = word[i+1:] 89 | if inQuote { 90 | buf.WriteByte('\'') 91 | inQuote = false 92 | } 93 | buf.WriteString("\\'") 94 | } 95 | if len(word) > 0 { 96 | if !inQuote { 97 | buf.WriteByte('\'') 98 | } 99 | buf.WriteString(word) 100 | buf.WriteByte('\'') 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/colorstring/colorstring.go: -------------------------------------------------------------------------------- 1 | package colorstring 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | // Color ... 8 | // ANSI color escape sequences 9 | type Color string 10 | 11 | const ( 12 | blackColor Color = "\x1b[30;1m" 13 | redColor Color = "\x1b[31;1m" 14 | greenColor Color = "\x1b[32;1m" 15 | yellowColor Color = "\x1b[33;1m" 16 | blueColor Color = "\x1b[34;1m" 17 | magentaColor Color = "\x1b[35;1m" 18 | cyanColor Color = "\x1b[36;1m" 19 | resetColor Color = "\x1b[0m" 20 | ) 21 | 22 | // ColorFunc ... 23 | type ColorFunc func(a ...interface{}) string 24 | 25 | func addColor(color Color, msg string) string { 26 | return string(color) + msg + string(resetColor) 27 | } 28 | 29 | // NoColor ... 30 | func NoColor(a ...interface{}) string { 31 | return fmt.Sprint(a...) 32 | } 33 | 34 | // Black ... 35 | func Black(a ...interface{}) string { 36 | return addColor(blackColor, fmt.Sprint(a...)) 37 | } 38 | 39 | // Red ... 40 | func Red(a ...interface{}) string { 41 | return addColor(redColor, fmt.Sprint(a...)) 42 | } 43 | 44 | // Green ... 45 | func Green(a ...interface{}) string { 46 | return addColor(greenColor, fmt.Sprint(a...)) 47 | } 48 | 49 | // Yellow ... 50 | func Yellow(a ...interface{}) string { 51 | return addColor(yellowColor, fmt.Sprint(a...)) 52 | } 53 | 54 | // Blue ... 55 | func Blue(a ...interface{}) string { 56 | return addColor(blueColor, fmt.Sprint(a...)) 57 | } 58 | 59 | // Magenta ... 60 | func Magenta(a ...interface{}) string { 61 | return addColor(magentaColor, fmt.Sprint(a...)) 62 | } 63 | 64 | // Cyan ... 65 | func Cyan(a ...interface{}) string { 66 | return addColor(cyanColor, fmt.Sprint(a...)) 67 | } 68 | 69 | // ColorfFunc ... 70 | type ColorfFunc func(format string, a ...interface{}) string 71 | 72 | // NoColorf ... 73 | func NoColorf(format string, a ...interface{}) string { 74 | return NoColor(fmt.Sprintf(format, a...)) 75 | } 76 | 77 | // Blackf ... 78 | func Blackf(format string, a ...interface{}) string { 79 | return Black(fmt.Sprintf(format, a...)) 80 | } 81 | 82 | // Redf ... 83 | func Redf(format string, a ...interface{}) string { 84 | return Red(fmt.Sprintf(format, a...)) 85 | } 86 | 87 | // Greenf ... 88 | func Greenf(format string, a ...interface{}) string { 89 | return Green(fmt.Sprintf(format, a...)) 90 | } 91 | 92 | // Yellowf ... 93 | func Yellowf(format string, a ...interface{}) string { 94 | return Yellow(fmt.Sprintf(format, a...)) 95 | } 96 | 97 | // Bluef ... 98 | func Bluef(format string, a ...interface{}) string { 99 | return Blue(fmt.Sprintf(format, a...)) 100 | } 101 | 102 | // Magentaf ... 103 | func Magentaf(format string, a ...interface{}) string { 104 | return Magenta(fmt.Sprintf(format, a...)) 105 | } 106 | 107 | // Cyanf ... 108 | func Cyanf(format string, a ...interface{}) string { 109 | return Cyan(fmt.Sprintf(format, a...)) 110 | } 111 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/v2/log/colorstring/colorstring.go: -------------------------------------------------------------------------------- 1 | package colorstring 2 | 3 | // ANSI color escape sequences 4 | 5 | import ( 6 | "fmt" 7 | ) 8 | 9 | // Color ... 10 | type Color string 11 | 12 | const ( 13 | blackColor Color = "\x1b[30;1m" 14 | redColor Color = "\x1b[31;1m" 15 | greenColor Color = "\x1b[32;1m" 16 | yellowColor Color = "\x1b[33;1m" 17 | blueColor Color = "\x1b[34;1m" 18 | magentaColor Color = "\x1b[35;1m" 19 | cyanColor Color = "\x1b[36;1m" 20 | resetColor Color = "\x1b[0m" 21 | ) 22 | 23 | // ColorFunc ... 24 | type ColorFunc func(a ...interface{}) string 25 | 26 | func addColor(color Color, msg string) string { 27 | return string(color) + msg + string(resetColor) 28 | } 29 | 30 | // NoColor ... 31 | func NoColor(a ...interface{}) string { 32 | return fmt.Sprint(a...) 33 | } 34 | 35 | // Black ... 36 | func Black(a ...interface{}) string { 37 | return addColor(blackColor, fmt.Sprint(a...)) 38 | } 39 | 40 | // Red ... 41 | func Red(a ...interface{}) string { 42 | return addColor(redColor, fmt.Sprint(a...)) 43 | } 44 | 45 | // Green ... 46 | func Green(a ...interface{}) string { 47 | return addColor(greenColor, fmt.Sprint(a...)) 48 | } 49 | 50 | // Yellow ... 51 | func Yellow(a ...interface{}) string { 52 | return addColor(yellowColor, fmt.Sprint(a...)) 53 | } 54 | 55 | // Blue ... 56 | func Blue(a ...interface{}) string { 57 | return addColor(blueColor, fmt.Sprint(a...)) 58 | } 59 | 60 | // Magenta ... 61 | func Magenta(a ...interface{}) string { 62 | return addColor(magentaColor, fmt.Sprint(a...)) 63 | } 64 | 65 | // Cyan ... 66 | func Cyan(a ...interface{}) string { 67 | return addColor(cyanColor, fmt.Sprint(a...)) 68 | } 69 | 70 | // ColorfFunc ... 71 | type ColorfFunc func(format string, a ...interface{}) string 72 | 73 | // NoColorf ... 74 | func NoColorf(format string, a ...interface{}) string { 75 | return NoColor(fmt.Sprintf(format, a...)) 76 | } 77 | 78 | // Blackf ... 79 | func Blackf(format string, a ...interface{}) string { 80 | return Black(fmt.Sprintf(format, a...)) 81 | } 82 | 83 | // Redf ... 84 | func Redf(format string, a ...interface{}) string { 85 | return Red(fmt.Sprintf(format, a...)) 86 | } 87 | 88 | // Greenf ... 89 | func Greenf(format string, a ...interface{}) string { 90 | return Green(fmt.Sprintf(format, a...)) 91 | } 92 | 93 | // Yellowf ... 94 | func Yellowf(format string, a ...interface{}) string { 95 | return Yellow(fmt.Sprintf(format, a...)) 96 | } 97 | 98 | // Bluef ... 99 | func Bluef(format string, a ...interface{}) string { 100 | return Blue(fmt.Sprintf(format, a...)) 101 | } 102 | 103 | // Magentaf ... 104 | func Magentaf(format string, a ...interface{}) string { 105 | return Magenta(fmt.Sprintf(format, a...)) 106 | } 107 | 108 | // Cyanf ... 109 | func Cyanf(format string, a ...interface{}) string { 110 | return Cyan(fmt.Sprintf(format, a...)) 111 | } 112 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/pathutil/sortable_path.go: -------------------------------------------------------------------------------- 1 | package pathutil 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | "sort" 7 | "strings" 8 | ) 9 | 10 | // ListPathInDirSortedByComponents ... 11 | func ListPathInDirSortedByComponents(searchDir string, relPath bool) ([]string, error) { 12 | searchDir, err := filepath.Abs(searchDir) 13 | if err != nil { 14 | return []string{}, err 15 | } 16 | 17 | var fileList []string 18 | 19 | if err := filepath.Walk(searchDir, func(path string, _ os.FileInfo, walkErr error) error { 20 | if walkErr != nil { 21 | return walkErr 22 | } 23 | 24 | if relPath { 25 | rel, err := filepath.Rel(searchDir, path) 26 | if err != nil { 27 | return err 28 | } 29 | path = rel 30 | } 31 | 32 | fileList = append(fileList, path) 33 | 34 | return nil 35 | }); err != nil { 36 | return []string{}, err 37 | } 38 | return SortPathsByComponents(fileList) 39 | } 40 | 41 | // SortablePath ... 42 | type SortablePath struct { 43 | Pth string 44 | AbsPth string 45 | Components []string 46 | } 47 | 48 | // NewSortablePath ... 49 | func NewSortablePath(pth string) (SortablePath, error) { 50 | absPth, err := AbsPath(pth) 51 | if err != nil { 52 | return SortablePath{}, err 53 | } 54 | 55 | components := strings.Split(absPth, string(os.PathSeparator)) 56 | fixedComponents := []string{} 57 | for _, comp := range components { 58 | if comp != "" { 59 | fixedComponents = append(fixedComponents, comp) 60 | } 61 | } 62 | 63 | return SortablePath{ 64 | Pth: pth, 65 | AbsPth: absPth, 66 | Components: fixedComponents, 67 | }, nil 68 | } 69 | 70 | // BySortablePathComponents .. 71 | type BySortablePathComponents []SortablePath 72 | 73 | func (s BySortablePathComponents) Len() int { 74 | return len(s) 75 | } 76 | func (s BySortablePathComponents) Swap(i, j int) { 77 | s[i], s[j] = s[j], s[i] 78 | } 79 | func (s BySortablePathComponents) Less(i, j int) bool { 80 | path1 := s[i] 81 | path2 := s[j] 82 | 83 | d1 := len(path1.Components) 84 | d2 := len(path2.Components) 85 | 86 | if d1 < d2 { 87 | return true 88 | } else if d1 > d2 { 89 | return false 90 | } 91 | 92 | // if same component size, 93 | // do alphabetic sort based on the last component 94 | base1 := filepath.Base(path1.AbsPth) 95 | base2 := filepath.Base(path2.AbsPth) 96 | 97 | return base1 < base2 98 | } 99 | 100 | // SortPathsByComponents ... 101 | func SortPathsByComponents(paths []string) ([]string, error) { 102 | sortableFiles := []SortablePath{} 103 | for _, pth := range paths { 104 | sortable, err := NewSortablePath(pth) 105 | if err != nil { 106 | return []string{}, err 107 | } 108 | sortableFiles = append(sortableFiles, sortable) 109 | } 110 | 111 | sort.Sort(BySortablePathComponents(sortableFiles)) 112 | 113 | sortedFiles := []string{} 114 | for _, pth := range sortableFiles { 115 | sortedFiles = append(sortedFiles, pth.Pth) 116 | } 117 | 118 | return sortedFiles, nil 119 | } 120 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/assertion_order.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | ) 7 | 8 | // isOrdered checks that collection contains orderable elements. 9 | func isOrdered(t TestingT, object interface{}, allowedComparesResults []CompareType, failMessage string, msgAndArgs ...interface{}) bool { 10 | objKind := reflect.TypeOf(object).Kind() 11 | if objKind != reflect.Slice && objKind != reflect.Array { 12 | return false 13 | } 14 | 15 | objValue := reflect.ValueOf(object) 16 | objLen := objValue.Len() 17 | 18 | if objLen <= 1 { 19 | return true 20 | } 21 | 22 | value := objValue.Index(0) 23 | valueInterface := value.Interface() 24 | firstValueKind := value.Kind() 25 | 26 | for i := 1; i < objLen; i++ { 27 | prevValue := value 28 | prevValueInterface := valueInterface 29 | 30 | value = objValue.Index(i) 31 | valueInterface = value.Interface() 32 | 33 | compareResult, isComparable := compare(prevValueInterface, valueInterface, firstValueKind) 34 | 35 | if !isComparable { 36 | return Fail(t, fmt.Sprintf("Can not compare type \"%s\" and \"%s\"", reflect.TypeOf(value), reflect.TypeOf(prevValue)), msgAndArgs...) 37 | } 38 | 39 | if !containsValue(allowedComparesResults, compareResult) { 40 | return Fail(t, fmt.Sprintf(failMessage, prevValue, value), msgAndArgs...) 41 | } 42 | } 43 | 44 | return true 45 | } 46 | 47 | // IsIncreasing asserts that the collection is increasing 48 | // 49 | // assert.IsIncreasing(t, []int{1, 2, 3}) 50 | // assert.IsIncreasing(t, []float{1, 2}) 51 | // assert.IsIncreasing(t, []string{"a", "b"}) 52 | func IsIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { 53 | return isOrdered(t, object, []CompareType{compareLess}, "\"%v\" is not less than \"%v\"", msgAndArgs...) 54 | } 55 | 56 | // IsNonIncreasing asserts that the collection is not increasing 57 | // 58 | // assert.IsNonIncreasing(t, []int{2, 1, 1}) 59 | // assert.IsNonIncreasing(t, []float{2, 1}) 60 | // assert.IsNonIncreasing(t, []string{"b", "a"}) 61 | func IsNonIncreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { 62 | return isOrdered(t, object, []CompareType{compareEqual, compareGreater}, "\"%v\" is not greater than or equal to \"%v\"", msgAndArgs...) 63 | } 64 | 65 | // IsDecreasing asserts that the collection is decreasing 66 | // 67 | // assert.IsDecreasing(t, []int{2, 1, 0}) 68 | // assert.IsDecreasing(t, []float{2, 1}) 69 | // assert.IsDecreasing(t, []string{"b", "a"}) 70 | func IsDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { 71 | return isOrdered(t, object, []CompareType{compareGreater}, "\"%v\" is not greater than \"%v\"", msgAndArgs...) 72 | } 73 | 74 | // IsNonDecreasing asserts that the collection is not decreasing 75 | // 76 | // assert.IsNonDecreasing(t, []int{1, 1, 2}) 77 | // assert.IsNonDecreasing(t, []float{1, 2}) 78 | // assert.IsNonDecreasing(t, []string{"a", "b"}) 79 | func IsNonDecreasing(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { 80 | return isOrdered(t, object, []CompareType{compareLess, compareEqual}, "\"%v\" is not less than or equal to \"%v\"", msgAndArgs...) 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/v2/command/command.go: -------------------------------------------------------------------------------- 1 | package command 2 | 3 | import ( 4 | "io" 5 | "os/exec" 6 | "strconv" 7 | "strings" 8 | 9 | "github.com/bitrise-io/go-utils/v2/env" 10 | ) 11 | 12 | // Opts ... 13 | type Opts struct { 14 | Stdout io.Writer 15 | Stderr io.Writer 16 | Stdin io.Reader 17 | Env []string 18 | Dir string 19 | } 20 | 21 | // Factory ... 22 | type Factory interface { 23 | Create(name string, args []string, opts *Opts) Command 24 | } 25 | 26 | type factory struct { 27 | envRepository env.Repository 28 | } 29 | 30 | // NewFactory ... 31 | func NewFactory(envRepository env.Repository) Factory { 32 | return factory{envRepository: envRepository} 33 | } 34 | 35 | // Create ... 36 | func (f factory) Create(name string, args []string, opts *Opts) Command { 37 | cmd := exec.Command(name, args...) 38 | if opts != nil { 39 | cmd.Stdout = opts.Stdout 40 | cmd.Stderr = opts.Stderr 41 | cmd.Stdin = opts.Stdin 42 | 43 | // If Env is nil, the new process uses the current process's 44 | // environment. 45 | // If we pass env vars we want to append them to the 46 | // current process's environment. 47 | cmd.Env = append(f.envRepository.List(), opts.Env...) 48 | cmd.Dir = opts.Dir 49 | } 50 | return command{cmd} 51 | } 52 | 53 | // Command ... 54 | type Command interface { 55 | PrintableCommandArgs() string 56 | Run() error 57 | RunAndReturnExitCode() (int, error) 58 | RunAndReturnTrimmedOutput() (string, error) 59 | RunAndReturnTrimmedCombinedOutput() (string, error) 60 | Start() error 61 | Wait() error 62 | } 63 | 64 | type command struct { 65 | cmd *exec.Cmd 66 | } 67 | 68 | // PrintableCommandArgs ... 69 | func (c command) PrintableCommandArgs() string { 70 | return printableCommandArgs(false, c.cmd.Args) 71 | } 72 | 73 | // Run ... 74 | func (c command) Run() error { 75 | return c.cmd.Run() 76 | } 77 | 78 | // RunAndReturnExitCode ... 79 | func (c command) RunAndReturnExitCode() (int, error) { 80 | err := c.cmd.Run() 81 | exitCode := c.cmd.ProcessState.ExitCode() 82 | return exitCode, err 83 | } 84 | 85 | // RunAndReturnTrimmedOutput ... 86 | func (c command) RunAndReturnTrimmedOutput() (string, error) { 87 | outBytes, err := c.cmd.Output() 88 | outStr := string(outBytes) 89 | return strings.TrimSpace(outStr), err 90 | } 91 | 92 | // RunAndReturnTrimmedCombinedOutput ... 93 | func (c command) RunAndReturnTrimmedCombinedOutput() (string, error) { 94 | outBytes, err := c.cmd.CombinedOutput() 95 | outStr := string(outBytes) 96 | return strings.TrimSpace(outStr), err 97 | } 98 | 99 | // Start ... 100 | func (c command) Start() error { 101 | return c.cmd.Start() 102 | } 103 | 104 | // Wait ... 105 | func (c command) Wait() error { 106 | return c.cmd.Wait() 107 | } 108 | 109 | func printableCommandArgs(isQuoteFirst bool, fullCommandArgs []string) string { 110 | var cmdArgsDecorated []string 111 | for idx, anArg := range fullCommandArgs { 112 | quotedArg := strconv.Quote(anArg) 113 | if idx == 0 && !isQuoteFirst { 114 | quotedArg = anArg 115 | } 116 | cmdArgsDecorated = append(cmdArgsDecorated, quotedArg) 117 | } 118 | 119 | return strings.Join(cmdArgsDecorated, " ") 120 | } 121 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/log/print.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | ) 6 | 7 | func printf(severity Severity, withTime bool, format string, v ...interface{}) { 8 | message := createLogMsg(severity, withTime, format, v...) 9 | if _, err := fmt.Fprintln(outWriter, message); err != nil { 10 | fmt.Printf("failed to print message: %s, error: %s\n", message, err) 11 | } 12 | } 13 | 14 | func createLogMsg(severity Severity, withTime bool, format string, v ...interface{}) string { 15 | colorFunc := severityColorFuncMap[severity] 16 | message := colorFunc(format, v...) 17 | if withTime { 18 | message = prefixCurrentTime(message) 19 | } 20 | 21 | return message 22 | } 23 | 24 | func prefixCurrentTime(message string) string { 25 | return fmt.Sprintf("%s %s", timestampField(), message) 26 | } 27 | 28 | // Successf ... 29 | func Successf(format string, v ...interface{}) { 30 | printf(successSeverity, false, format, v...) 31 | } 32 | 33 | // Donef ... 34 | func Donef(format string, v ...interface{}) { 35 | Successf(format, v...) 36 | } 37 | 38 | // Infof ... 39 | func Infof(format string, v ...interface{}) { 40 | printf(infoSeverity, false, format, v...) 41 | } 42 | 43 | // Printf ... 44 | func Printf(format string, v ...interface{}) { 45 | printf(normalSeverity, false, format, v...) 46 | } 47 | 48 | // Debugf ... 49 | func Debugf(format string, v ...interface{}) { 50 | if enableDebugLog { 51 | printf(debugSeverity, false, format, v...) 52 | } 53 | } 54 | 55 | // Warnf ... 56 | func Warnf(format string, v ...interface{}) { 57 | printf(warnSeverity, false, format, v...) 58 | } 59 | 60 | // Errorf ... 61 | func Errorf(format string, v ...interface{}) { 62 | printf(errorSeverity, false, format, v...) 63 | } 64 | 65 | // TSuccessf ... 66 | func TSuccessf(format string, v ...interface{}) { 67 | printf(successSeverity, true, format, v...) 68 | } 69 | 70 | // TDonef ... 71 | func TDonef(format string, v ...interface{}) { 72 | TSuccessf(format, v...) 73 | } 74 | 75 | // TInfof ... 76 | func TInfof(format string, v ...interface{}) { 77 | printf(infoSeverity, true, format, v...) 78 | } 79 | 80 | // TPrintf ... 81 | func TPrintf(format string, v ...interface{}) { 82 | printf(normalSeverity, true, format, v...) 83 | } 84 | 85 | // TDebugf ... 86 | func TDebugf(format string, v ...interface{}) { 87 | if enableDebugLog { 88 | printf(debugSeverity, true, format, v...) 89 | } 90 | } 91 | 92 | // TWarnf ... 93 | func TWarnf(format string, v ...interface{}) { 94 | printf(warnSeverity, true, format, v...) 95 | } 96 | 97 | // TErrorf ... 98 | func TErrorf(format string, v ...interface{}) { 99 | printf(errorSeverity, true, format, v...) 100 | } 101 | 102 | // RInfof ... 103 | func RInfof(stepID string, tag string, data map[string]interface{}, format string, v ...interface{}) { 104 | rprintf("info", stepID, tag, data, format, v...) 105 | } 106 | 107 | // RWarnf ... 108 | func RWarnf(stepID string, tag string, data map[string]interface{}, format string, v ...interface{}) { 109 | rprintf("warn", stepID, tag, data, format, v...) 110 | } 111 | 112 | // RErrorf ... 113 | func RErrorf(stepID string, tag string, data map[string]interface{}, format string, v ...interface{}) { 114 | rprintf("error", stepID, tag, data, format, v...) 115 | } 116 | -------------------------------------------------------------------------------- /androidcomponents/androidcomponents_test.go: -------------------------------------------------------------------------------- 1 | package androidcomponents 2 | 3 | import ( 4 | "errors" 5 | "io" 6 | "os/exec" 7 | "testing" 8 | 9 | commandv2 "github.com/bitrise-io/go-utils/v2/command" 10 | "github.com/bitrise-io/go-utils/v2/env" 11 | "github.com/bitrise-steplib/steps-install-missing-android-tools/mocks" 12 | "github.com/stretchr/testify/mock" 13 | "github.com/stretchr/testify/require" 14 | ) 15 | 16 | func Test_GivenCommand_WhenFails_ThenReturnsExitError(t *testing.T) { 17 | // TODO: androidcomponents.NewCommandError requires a command execution function to return an *exec.ExitError, 18 | // when the command was successfully executed, but returned non-zero exit status. 19 | // In go-utils/v2@v2.0.0-alpha.15 the command package was updated to return a new custom error. 20 | // Upgrading to this or higher version breaks androidcomponents.NewCommandError. 21 | // This test ensures that the used go-utils/v2/command package works well with androidcomponents.NewCommandError. 22 | factory := commandv2.NewFactory(env.NewRepository()) 23 | cmd := factory.Create("bash", []string{"-c", "exit 1"}, nil) 24 | err := cmd.Run() 25 | var exitErr *exec.ExitError 26 | require.True(t, errors.As(err, &exitErr)) 27 | } 28 | 29 | func Test_GivenInstallerAndGradlePrintsToStderr_WhenScanDependencies_ThenErrorContainStderr(t *testing.T) { 30 | // Given 31 | var stderr io.Writer 32 | 33 | command := new(mocks.Command) 34 | command.On("Run").Run(func(args mock.Arguments) { 35 | _, err := stderr.Write([]byte("error reason")) 36 | require.NoError(t, err) 37 | }).Return(&exec.ExitError{}) 38 | command.On("PrintableCommandArgs").Return("./gradlew dependencies --stacktrace") 39 | 40 | factory := new(mocks.Factory) 41 | factory.On("Create", "./gradlew", []string{"dependencies", "--stacktrace"}, mock.Anything).Run(func(args mock.Arguments) { 42 | opts := args.Get(2).(*commandv2.Opts) 43 | stderr = opts.Stderr 44 | }).Return(command) 45 | 46 | installer := installer{ 47 | gradlewPath: "./gradlew", 48 | factory: factory, 49 | } 50 | 51 | // When 52 | err := installer.scanDependencies(false) 53 | 54 | // Then 55 | require.EqualError(t, err, "command failed with exit status -1 (./gradlew dependencies --stacktrace): error reason") 56 | } 57 | 58 | func Test_GivenInstallerAndGradleDoesNotPrintToStderr_WhenScanDependenciesAndLastAttempt_ThenErrorGenericErrorThrownAndStdoutLogged(t *testing.T) { 59 | // Given 60 | var stdout io.Writer 61 | 62 | command := new(mocks.Command) 63 | command.On("Run").Run(func(args mock.Arguments) { 64 | _, err := stdout.Write([]byte("Task failed")) 65 | require.NoError(t, err) 66 | }).Return(&exec.ExitError{}) 67 | command.On("PrintableCommandArgs").Return("./gradlew dependencies --stacktrace") 68 | 69 | factory := new(mocks.Factory) 70 | factory.On("Create", "./gradlew", []string{"dependencies", "--stacktrace"}, mock.Anything).Run(func(args mock.Arguments) { 71 | opts := args.Get(2).(*commandv2.Opts) 72 | stdout = opts.Stdout 73 | }).Return(command) 74 | 75 | logger := new(mocks.Logger) 76 | logger.On("Printf", "Task failed").Return() 77 | 78 | installer := installer{ 79 | gradlewPath: "./gradlew", 80 | factory: factory, 81 | logger: logger, 82 | } 83 | 84 | // When 85 | err := installer.scanDependencies(true) 86 | 87 | // Then 88 | require.EqualError(t, err, "command failed with exit status -1 (./gradlew dependencies --stacktrace): check the command's output for details") 89 | logger.AssertExpectations(t) 90 | } 91 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-retryablehttp/README.md: -------------------------------------------------------------------------------- 1 | go-retryablehttp 2 | ================ 3 | 4 | [![Build Status](http://img.shields.io/travis/hashicorp/go-retryablehttp.svg?style=flat-square)][travis] 5 | [![Go Documentation](http://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)][godocs] 6 | 7 | [travis]: http://travis-ci.org/hashicorp/go-retryablehttp 8 | [godocs]: http://godoc.org/github.com/hashicorp/go-retryablehttp 9 | 10 | The `retryablehttp` package provides a familiar HTTP client interface with 11 | automatic retries and exponential backoff. It is a thin wrapper over the 12 | standard `net/http` client library and exposes nearly the same public API. This 13 | makes `retryablehttp` very easy to drop into existing programs. 14 | 15 | `retryablehttp` performs automatic retries under certain conditions. Mainly, if 16 | an error is returned by the client (connection errors, etc.), or if a 500-range 17 | response code is received (except 501), then a retry is invoked after a wait 18 | period. Otherwise, the response is returned and left to the caller to 19 | interpret. 20 | 21 | The main difference from `net/http` is that requests which take a request body 22 | (POST/PUT et. al) can have the body provided in a number of ways (some more or 23 | less efficient) that allow "rewinding" the request body if the initial request 24 | fails so that the full request can be attempted again. See the 25 | [godoc](http://godoc.org/github.com/hashicorp/go-retryablehttp) for more 26 | details. 27 | 28 | Version 0.6.0 and before are compatible with Go prior to 1.12. From 0.6.1 onward, Go 1.12+ is required. 29 | From 0.6.7 onward, Go 1.13+ is required. 30 | 31 | Example Use 32 | =========== 33 | 34 | Using this library should look almost identical to what you would do with 35 | `net/http`. The most simple example of a GET request is shown below: 36 | 37 | ```go 38 | resp, err := retryablehttp.Get("/foo") 39 | if err != nil { 40 | panic(err) 41 | } 42 | ``` 43 | 44 | The returned response object is an `*http.Response`, the same thing you would 45 | usually get from `net/http`. Had the request failed one or more times, the above 46 | call would block and retry with exponential backoff. 47 | 48 | ## Retrying cases that fail after a seeming success 49 | 50 | It's possible for a request to succeed in the sense that the expected response headers are received, but then to encounter network-level errors while reading the response body. In go-retryablehttp's most basic usage, this error would not be retryable, due to the out-of-band handling of the response body. In some cases it may be desirable to handle the response body as part of the retryable operation. 51 | 52 | A toy example (which will retry the full request and succeed on the second attempt) is shown below: 53 | 54 | ```go 55 | c := retryablehttp.NewClient() 56 | r := retryablehttp.NewRequest("GET", "://foo", nil) 57 | handlerShouldRetry := true 58 | r.SetResponseHandler(func(*http.Response) error { 59 | if !handlerShouldRetry { 60 | return nil 61 | } 62 | handlerShouldRetry = false 63 | return errors.New("retryable error") 64 | }) 65 | ``` 66 | 67 | ## Getting a stdlib `*http.Client` with retries 68 | 69 | It's possible to convert a `*retryablehttp.Client` directly to a `*http.Client`. 70 | This makes use of retryablehttp broadly applicable with minimal effort. Simply 71 | configure a `*retryablehttp.Client` as you wish, and then call `StandardClient()`: 72 | 73 | ```go 74 | retryClient := retryablehttp.NewClient() 75 | retryClient.RetryMax = 10 76 | 77 | standardClient := retryClient.StandardClient() // *http.Client 78 | ``` 79 | 80 | For more usage and examples see the 81 | [godoc](http://godoc.org/github.com/hashicorp/go-retryablehttp). 82 | -------------------------------------------------------------------------------- /mocks/Command.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery v2.20.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import mock "github.com/stretchr/testify/mock" 6 | 7 | // Command is an autogenerated mock type for the Command type 8 | type Command struct { 9 | mock.Mock 10 | } 11 | 12 | // PrintableCommandArgs provides a mock function with given fields: 13 | func (_m *Command) PrintableCommandArgs() string { 14 | ret := _m.Called() 15 | 16 | var r0 string 17 | if rf, ok := ret.Get(0).(func() string); ok { 18 | r0 = rf() 19 | } else { 20 | r0 = ret.Get(0).(string) 21 | } 22 | 23 | return r0 24 | } 25 | 26 | // Run provides a mock function with given fields: 27 | func (_m *Command) Run() error { 28 | ret := _m.Called() 29 | 30 | var r0 error 31 | if rf, ok := ret.Get(0).(func() error); ok { 32 | r0 = rf() 33 | } else { 34 | r0 = ret.Error(0) 35 | } 36 | 37 | return r0 38 | } 39 | 40 | // RunAndReturnExitCode provides a mock function with given fields: 41 | func (_m *Command) RunAndReturnExitCode() (int, error) { 42 | ret := _m.Called() 43 | 44 | var r0 int 45 | var r1 error 46 | if rf, ok := ret.Get(0).(func() (int, error)); ok { 47 | return rf() 48 | } 49 | if rf, ok := ret.Get(0).(func() int); ok { 50 | r0 = rf() 51 | } else { 52 | r0 = ret.Get(0).(int) 53 | } 54 | 55 | if rf, ok := ret.Get(1).(func() error); ok { 56 | r1 = rf() 57 | } else { 58 | r1 = ret.Error(1) 59 | } 60 | 61 | return r0, r1 62 | } 63 | 64 | // RunAndReturnTrimmedCombinedOutput provides a mock function with given fields: 65 | func (_m *Command) RunAndReturnTrimmedCombinedOutput() (string, error) { 66 | ret := _m.Called() 67 | 68 | var r0 string 69 | var r1 error 70 | if rf, ok := ret.Get(0).(func() (string, error)); ok { 71 | return rf() 72 | } 73 | if rf, ok := ret.Get(0).(func() string); ok { 74 | r0 = rf() 75 | } else { 76 | r0 = ret.Get(0).(string) 77 | } 78 | 79 | if rf, ok := ret.Get(1).(func() error); ok { 80 | r1 = rf() 81 | } else { 82 | r1 = ret.Error(1) 83 | } 84 | 85 | return r0, r1 86 | } 87 | 88 | // RunAndReturnTrimmedOutput provides a mock function with given fields: 89 | func (_m *Command) RunAndReturnTrimmedOutput() (string, error) { 90 | ret := _m.Called() 91 | 92 | var r0 string 93 | var r1 error 94 | if rf, ok := ret.Get(0).(func() (string, error)); ok { 95 | return rf() 96 | } 97 | if rf, ok := ret.Get(0).(func() string); ok { 98 | r0 = rf() 99 | } else { 100 | r0 = ret.Get(0).(string) 101 | } 102 | 103 | if rf, ok := ret.Get(1).(func() error); ok { 104 | r1 = rf() 105 | } else { 106 | r1 = ret.Error(1) 107 | } 108 | 109 | return r0, r1 110 | } 111 | 112 | // Start provides a mock function with given fields: 113 | func (_m *Command) Start() error { 114 | ret := _m.Called() 115 | 116 | var r0 error 117 | if rf, ok := ret.Get(0).(func() error); ok { 118 | r0 = rf() 119 | } else { 120 | r0 = ret.Error(0) 121 | } 122 | 123 | return r0 124 | } 125 | 126 | // Wait provides a mock function with given fields: 127 | func (_m *Command) Wait() error { 128 | ret := _m.Called() 129 | 130 | var r0 error 131 | if rf, ok := ret.Get(0).(func() error); ok { 132 | r0 = rf() 133 | } else { 134 | r0 = ret.Error(0) 135 | } 136 | 137 | return r0 138 | } 139 | 140 | type mockConstructorTestingTNewCommand interface { 141 | mock.TestingT 142 | Cleanup(func()) 143 | } 144 | 145 | // NewCommand creates a new instance of Command. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. 146 | func NewCommand(t mockConstructorTestingTNewCommand) *Command { 147 | mock := &Command{} 148 | mock.Mock.Test(t) 149 | 150 | t.Cleanup(func() { mock.AssertExpectations(t) }) 151 | 152 | return mock 153 | } 154 | -------------------------------------------------------------------------------- /step.yml: -------------------------------------------------------------------------------- 1 | title: Install missing Android SDK components 2 | summary: Install Android SDK components that are required for the app. 3 | 4 | description: |- 5 | 6 | This Step makes sure that required Android SDK components (platforms and build-tools) are installed. To do so, the Step runs the `gradlew dependencies` command. 7 | 8 | If the Android Plugin for Gradle version is 2.2.0 or higher, the plugin will download and install the missing components during the Gradle command. 9 | Otherwise the command fails and the Step parses the command's output to determine which SDK components are missing and installs them. 10 | 11 | ### Configuring the Step 12 | 13 | 1. Set the path of the `gradlew` file. 14 | 15 | The default value is that of the $PROJECT_LOCATION Environment Variable. 16 | 17 | 1. If you use an Android NDK in your app, set its revision in the **NDK Revision** input. 18 | 19 | ### Troubleshooting 20 | 21 | If the Step fails, check that your repo actually contains a `gradlew` file. Without the Gradle wrapper, this Step won't work. 22 | 23 | ### Useful links 24 | 25 | [Installing an additional Android SDK package](https://devcenter.bitrise.io/tips-and-tricks/android-tips-and-tricks/#how-to-install-an-additional-android-sdk-package) 26 | 27 | ### Related Steps 28 | 29 | * [Android SDK Update](https://www.bitrise.io/integrations/steps/android-sdk-update) 30 | * [Install React Native](https://www.bitrise.io/integrations/steps/install-react-native) 31 | website: https://github.com/bitrise-steplib/steps-install-missing-android-tools 32 | source_code_url: https://github.com/bitrise-steplib/steps-install-missing-android-tools 33 | support_url: https://github.com/bitrise-steplib/steps-install-missing-android-tools/issues 34 | project_type_tags: 35 | - android 36 | - cordova 37 | - flutter 38 | - ionic 39 | - kotlin-multiplatform 40 | - react-native 41 | type_tags: 42 | - installer 43 | is_always_run: false 44 | is_skippable: false 45 | toolkit: 46 | go: 47 | package_name: github.com/bitrise-steplib/steps-install-missing-android-tools 48 | inputs: 49 | - gradlew_path: $GRADLEW_PATH 50 | opts: 51 | title: gradlew file path 52 | description: | 53 | Using a Gradle Wrapper (gradlew) is required, as the wrapper is what makes sure 54 | that the right Gradle version is installed and used for the build. 55 | __You can find more information about the Gradle Wrapper (gradlew), 56 | and about how you can generate one (if you would not have one already)__ 57 | in the official guide at: [https://docs.gradle.org/current/userguide/gradle_wrapper.html](https://docs.gradle.org/current/userguide/gradle_wrapper.html). 58 | 59 | **The path should be relative** to the repository root, for example: `./gradlew`, 60 | or if it's in a sub directory: `./sub/dir/gradlew`. 61 | is_required: true 62 | - ndk_version: 63 | opts: 64 | title: NDK version 65 | summary: NDK version to install. Leave this input empty if you are not using the Native Development Kit in your project. 66 | description: NDK version to install, for example `23.0.7599858`. Run `sdkmanager --list` on your machine to see all available versions. Leave this input empty if you are not using the Native Development Kit in your project. 67 | - gradlew_dependencies_options: 68 | opts: 69 | title: Additional options for the `gradlew dependencies` command 70 | summary: Additional options to be added to the executed `gradlew dependencies` command. 71 | description: |- 72 | Additional options to be added to the executed `gradlew dependencies` command. 73 | 74 | The step runs `gradlew dependencies --stacktrace` to list and install the missing project dependencies. 75 | 76 | Additional options will be appended to the end of this command. 77 | 78 | Example: `--configuration-cache-problems=warn`. 79 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/README.md: -------------------------------------------------------------------------------- 1 | # Objx 2 | [![Build Status](https://travis-ci.org/stretchr/objx.svg?branch=master)](https://travis-ci.org/stretchr/objx) 3 | [![Go Report Card](https://goreportcard.com/badge/github.com/stretchr/objx)](https://goreportcard.com/report/github.com/stretchr/objx) 4 | [![Maintainability](https://api.codeclimate.com/v1/badges/1d64bc6c8474c2074f2b/maintainability)](https://codeclimate.com/github/stretchr/objx/maintainability) 5 | [![Test Coverage](https://api.codeclimate.com/v1/badges/1d64bc6c8474c2074f2b/test_coverage)](https://codeclimate.com/github/stretchr/objx/test_coverage) 6 | [![Sourcegraph](https://sourcegraph.com/github.com/stretchr/objx/-/badge.svg)](https://sourcegraph.com/github.com/stretchr/objx) 7 | [![GoDoc](https://godoc.org/github.com/stretchr/objx?status.svg)](https://godoc.org/github.com/stretchr/objx) 8 | 9 | Objx - Go package for dealing with maps, slices, JSON and other data. 10 | 11 | Get started: 12 | 13 | - Install Objx with [one line of code](#installation), or [update it with another](#staying-up-to-date) 14 | - Check out the API Documentation http://godoc.org/github.com/stretchr/objx 15 | 16 | ## Overview 17 | Objx provides the `objx.Map` type, which is a `map[string]interface{}` that exposes a powerful `Get` method (among others) that allows you to easily and quickly get access to data within the map, without having to worry too much about type assertions, missing data, default values etc. 18 | 19 | ### Pattern 20 | Objx uses a preditable pattern to make access data from within `map[string]interface{}` easy. Call one of the `objx.` functions to create your `objx.Map` to get going: 21 | 22 | m, err := objx.FromJSON(json) 23 | 24 | NOTE: Any methods or functions with the `Must` prefix will panic if something goes wrong, the rest will be optimistic and try to figure things out without panicking. 25 | 26 | Use `Get` to access the value you're interested in. You can use dot and array 27 | notation too: 28 | 29 | m.Get("places[0].latlng") 30 | 31 | Once you have sought the `Value` you're interested in, you can use the `Is*` methods to determine its type. 32 | 33 | if m.Get("code").IsStr() { // Your code... } 34 | 35 | Or you can just assume the type, and use one of the strong type methods to extract the real value: 36 | 37 | m.Get("code").Int() 38 | 39 | If there's no value there (or if it's the wrong type) then a default value will be returned, or you can be explicit about the default value. 40 | 41 | Get("code").Int(-1) 42 | 43 | If you're dealing with a slice of data as a value, Objx provides many useful methods for iterating, manipulating and selecting that data. You can find out more by exploring the index below. 44 | 45 | ### Reading data 46 | A simple example of how to use Objx: 47 | 48 | // Use MustFromJSON to make an objx.Map from some JSON 49 | m := objx.MustFromJSON(`{"name": "Mat", "age": 30}`) 50 | 51 | // Get the details 52 | name := m.Get("name").Str() 53 | age := m.Get("age").Int() 54 | 55 | // Get their nickname (or use their name if they don't have one) 56 | nickname := m.Get("nickname").Str(name) 57 | 58 | ### Ranging 59 | Since `objx.Map` is a `map[string]interface{}` you can treat it as such. For example, to `range` the data, do what you would expect: 60 | 61 | m := objx.MustFromJSON(json) 62 | for key, value := range m { 63 | // Your code... 64 | } 65 | 66 | ## Installation 67 | To install Objx, use go get: 68 | 69 | go get github.com/stretchr/objx 70 | 71 | ### Staying up to date 72 | To update Objx to the latest version, run: 73 | 74 | go get -u github.com/stretchr/objx 75 | 76 | ### Supported go versions 77 | We support the lastest three major Go versions, which are 1.10, 1.11 and 1.12 at the moment. 78 | 79 | ## Contributing 80 | Please feel free to submit issues, fork the repository and send pull requests! 81 | -------------------------------------------------------------------------------- /main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "testing" 6 | 7 | "github.com/stretchr/testify/require" 8 | ) 9 | 10 | func Test_currentNDKHome(t *testing.T) { 11 | type test struct { 12 | name string 13 | envs map[string]string 14 | wantPath string 15 | wantCleanup bool 16 | } 17 | 18 | requestedNDKVersion := "23.0.7599858" 19 | tests := []test{ 20 | { 21 | name: "ANDROID_NDK_HOME is set", 22 | envs: map[string]string{ 23 | "ANDROID_NDK_HOME": "/opt/android-ndk", 24 | }, 25 | wantPath: "/opt/android-ndk", 26 | wantCleanup: true, 27 | }, 28 | { 29 | name: "both ANDROID_NDK_HOME and ANDROID_HOME are set", 30 | envs: map[string]string{ 31 | "ANDROID_NDK_HOME": "/opt/android-ndk", 32 | "ANDROID_HOME": "/opt/android-sdk", 33 | }, 34 | wantPath: "/opt/android-ndk", 35 | wantCleanup: true, 36 | }, 37 | { 38 | name: "only ndk-bundle is installed", 39 | envs: map[string]string{ 40 | "ANDROID_HOME": "/home/user/android-sdk", 41 | }, 42 | wantPath: "/home/user/android-sdk/ndk/23.0.7599858", 43 | wantCleanup: false, 44 | }, 45 | { 46 | name: "ndk-bundle and side-by-side NDK is installed", 47 | envs: map[string]string{ 48 | "ANDROID_HOME": "/home/user/android-sdk", 49 | }, 50 | wantPath: "/home/user/android-sdk/ndk/23.0.7599858", 51 | wantCleanup: false, 52 | }, 53 | { 54 | name: "the exact requested side-by-side NDK is installed", 55 | envs: map[string]string{ 56 | "ANDROID_HOME": "/home/user/android-sdk", 57 | }, 58 | wantPath: "/home/user/android-sdk/ndk/23.0.7599858", 59 | wantCleanup: false, 60 | }, 61 | { 62 | name: "a different side-by-side NDK is installed than requested", 63 | envs: map[string]string{ 64 | "ANDROID_HOME": "/home/user/android-sdk", 65 | }, 66 | wantPath: "/home/user/android-sdk/ndk/23.0.7599858", 67 | wantCleanup: false, 68 | }, 69 | { 70 | name: "both ANDROID_HOME and SDK_ROOT are set, pointing to the same dir", 71 | envs: map[string]string{ 72 | "ANDROID_HOME": "/home/user/android-sdk", 73 | "SDK_ROOT": "/home/user/android-sdk", 74 | }, 75 | wantPath: "/home/user/android-sdk/ndk/23.0.7599858", 76 | wantCleanup: false, 77 | }, 78 | { 79 | name: "both ANDROID_HOME and SDK_ROOT are set, pointing to different dirs", 80 | envs: map[string]string{ 81 | "ANDROID_HOME": "/home/user/android-sdk-home", 82 | "ANDROID_SDK_ROOT": "/home/user/android-sdk-root", 83 | }, 84 | wantPath: "/home/user/android-sdk-home/ndk/23.0.7599858", 85 | wantCleanup: false, 86 | }, 87 | { 88 | name: "only SDK_ROOT is set", 89 | envs: map[string]string{ 90 | "ANDROID_SDK_ROOT": "/home/user/android-sdk-root", 91 | }, 92 | wantPath: "/home/user/android-sdk-root/ndk/23.0.7599858", 93 | wantCleanup: false, 94 | }, 95 | } 96 | 97 | for _, tt := range tests { 98 | t.Run(tt.name, func(t *testing.T) { 99 | envRepo := fakeEnvRepo{envVars: tt.envs} 100 | gotPath, gotCleanup := targetNDKPath(envRepo, requestedNDKVersion) 101 | require.Equal(t, tt.wantPath, gotPath) 102 | require.Equal(t, tt.wantCleanup, gotCleanup) 103 | }) 104 | } 105 | 106 | } 107 | 108 | type fakeEnvRepo struct { 109 | envVars map[string]string 110 | } 111 | 112 | func (repo fakeEnvRepo) Get(key string) string { 113 | value, ok := repo.envVars[key] 114 | if ok { 115 | return value 116 | } else { 117 | return "" 118 | } 119 | } 120 | 121 | func (repo fakeEnvRepo) Set(key, value string) error { 122 | repo.envVars[key] = value 123 | return nil 124 | } 125 | 126 | func (repo fakeEnvRepo) Unset(key string) error { 127 | repo.envVars[key] = "" 128 | return nil 129 | } 130 | 131 | func (repo fakeEnvRepo) List() []string { 132 | envs := []string{} 133 | for k, v := range repo.envVars { 134 | envs = append(envs, fmt.Sprintf("%s=%s", k, v)) 135 | } 136 | return envs 137 | } 138 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/sorter.go: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) 2011-2019 Canonical Ltd 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package yaml 17 | 18 | import ( 19 | "reflect" 20 | "unicode" 21 | ) 22 | 23 | type keyList []reflect.Value 24 | 25 | func (l keyList) Len() int { return len(l) } 26 | func (l keyList) Swap(i, j int) { l[i], l[j] = l[j], l[i] } 27 | func (l keyList) Less(i, j int) bool { 28 | a := l[i] 29 | b := l[j] 30 | ak := a.Kind() 31 | bk := b.Kind() 32 | for (ak == reflect.Interface || ak == reflect.Ptr) && !a.IsNil() { 33 | a = a.Elem() 34 | ak = a.Kind() 35 | } 36 | for (bk == reflect.Interface || bk == reflect.Ptr) && !b.IsNil() { 37 | b = b.Elem() 38 | bk = b.Kind() 39 | } 40 | af, aok := keyFloat(a) 41 | bf, bok := keyFloat(b) 42 | if aok && bok { 43 | if af != bf { 44 | return af < bf 45 | } 46 | if ak != bk { 47 | return ak < bk 48 | } 49 | return numLess(a, b) 50 | } 51 | if ak != reflect.String || bk != reflect.String { 52 | return ak < bk 53 | } 54 | ar, br := []rune(a.String()), []rune(b.String()) 55 | digits := false 56 | for i := 0; i < len(ar) && i < len(br); i++ { 57 | if ar[i] == br[i] { 58 | digits = unicode.IsDigit(ar[i]) 59 | continue 60 | } 61 | al := unicode.IsLetter(ar[i]) 62 | bl := unicode.IsLetter(br[i]) 63 | if al && bl { 64 | return ar[i] < br[i] 65 | } 66 | if al || bl { 67 | if digits { 68 | return al 69 | } else { 70 | return bl 71 | } 72 | } 73 | var ai, bi int 74 | var an, bn int64 75 | if ar[i] == '0' || br[i] == '0' { 76 | for j := i - 1; j >= 0 && unicode.IsDigit(ar[j]); j-- { 77 | if ar[j] != '0' { 78 | an = 1 79 | bn = 1 80 | break 81 | } 82 | } 83 | } 84 | for ai = i; ai < len(ar) && unicode.IsDigit(ar[ai]); ai++ { 85 | an = an*10 + int64(ar[ai]-'0') 86 | } 87 | for bi = i; bi < len(br) && unicode.IsDigit(br[bi]); bi++ { 88 | bn = bn*10 + int64(br[bi]-'0') 89 | } 90 | if an != bn { 91 | return an < bn 92 | } 93 | if ai != bi { 94 | return ai < bi 95 | } 96 | return ar[i] < br[i] 97 | } 98 | return len(ar) < len(br) 99 | } 100 | 101 | // keyFloat returns a float value for v if it is a number/bool 102 | // and whether it is a number/bool or not. 103 | func keyFloat(v reflect.Value) (f float64, ok bool) { 104 | switch v.Kind() { 105 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 106 | return float64(v.Int()), true 107 | case reflect.Float32, reflect.Float64: 108 | return v.Float(), true 109 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 110 | return float64(v.Uint()), true 111 | case reflect.Bool: 112 | if v.Bool() { 113 | return 1, true 114 | } 115 | return 0, true 116 | } 117 | return 0, false 118 | } 119 | 120 | // numLess returns whether a < b. 121 | // a and b must necessarily have the same kind. 122 | func numLess(a, b reflect.Value) bool { 123 | switch a.Kind() { 124 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: 125 | return a.Int() < b.Int() 126 | case reflect.Float32, reflect.Float64: 127 | return a.Float() < b.Float() 128 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: 129 | return a.Uint() < b.Uint() 130 | case reflect.Bool: 131 | return !a.Bool() && b.Bool() 132 | } 133 | panic("not a number") 134 | } 135 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/v2/log/log.go: -------------------------------------------------------------------------------- 1 | package log 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "os" 7 | "time" 8 | ) 9 | 10 | // Logger ... 11 | type Logger interface { 12 | Infof(format string, v ...interface{}) 13 | Warnf(format string, v ...interface{}) 14 | Printf(format string, v ...interface{}) 15 | Donef(format string, v ...interface{}) 16 | Debugf(format string, v ...interface{}) 17 | Errorf(format string, v ...interface{}) 18 | TInfof(format string, v ...interface{}) 19 | TWarnf(format string, v ...interface{}) 20 | TPrintf(format string, v ...interface{}) 21 | TDonef(format string, v ...interface{}) 22 | TDebugf(format string, v ...interface{}) 23 | TErrorf(format string, v ...interface{}) 24 | Println() 25 | EnableDebugLog(enable bool) 26 | } 27 | 28 | const defaultTimeStampLayout = "15:04:05" 29 | 30 | type logger struct { 31 | enableDebugLog bool 32 | timestampLayout string 33 | stdout io.Writer 34 | } 35 | 36 | // NewLogger ... 37 | func NewLogger() Logger { 38 | return &logger{enableDebugLog: false, timestampLayout: defaultTimeStampLayout, stdout: os.Stdout} 39 | } 40 | 41 | // EnableDebugLog ... 42 | func (l *logger) EnableDebugLog(enable bool) { 43 | l.enableDebugLog = enable 44 | } 45 | 46 | // Infof ... 47 | func (l *logger) Infof(format string, v ...interface{}) { 48 | l.printf(infoSeverity, false, format, v...) 49 | } 50 | 51 | // Warnf ... 52 | func (l *logger) Warnf(format string, v ...interface{}) { 53 | l.printf(warnSeverity, false, format, v...) 54 | } 55 | 56 | // Printf ... 57 | func (l *logger) Printf(format string, v ...interface{}) { 58 | l.printf(normalSeverity, false, format, v...) 59 | } 60 | 61 | // Donef ... 62 | func (l *logger) Donef(format string, v ...interface{}) { 63 | l.printf(doneSeverity, false, format, v...) 64 | } 65 | 66 | // Debugf ... 67 | func (l *logger) Debugf(format string, v ...interface{}) { 68 | if l.enableDebugLog { 69 | l.printf(debugSeverity, false, format, v...) 70 | } 71 | } 72 | 73 | // Errorf ... 74 | func (l *logger) Errorf(format string, v ...interface{}) { 75 | l.printf(errorSeverity, false, format, v...) 76 | } 77 | 78 | // TInfof ... 79 | func (l *logger) TInfof(format string, v ...interface{}) { 80 | l.printf(infoSeverity, true, format, v...) 81 | } 82 | 83 | // TWarnf ... 84 | func (l *logger) TWarnf(format string, v ...interface{}) { 85 | l.printf(warnSeverity, true, format, v...) 86 | } 87 | 88 | // TPrintf ... 89 | func (l *logger) TPrintf(format string, v ...interface{}) { 90 | l.printf(normalSeverity, true, format, v...) 91 | } 92 | 93 | // TDonef ... 94 | func (l *logger) TDonef(format string, v ...interface{}) { 95 | l.printf(doneSeverity, true, format, v...) 96 | } 97 | 98 | // TDebugf ... 99 | func (l *logger) TDebugf(format string, v ...interface{}) { 100 | if l.enableDebugLog { 101 | l.printf(debugSeverity, true, format, v...) 102 | } 103 | } 104 | 105 | // TErrorf ... 106 | func (l *logger) TErrorf(format string, v ...interface{}) { 107 | l.printf(errorSeverity, true, format, v...) 108 | } 109 | 110 | // Println ... 111 | func (l *logger) Println() { 112 | fmt.Println() 113 | } 114 | 115 | func (l *logger) timestampField() string { 116 | currentTime := time.Now() 117 | return fmt.Sprintf("[%s]", currentTime.Format(l.timestampLayout)) 118 | } 119 | 120 | func (l *logger) prefixCurrentTime(message string) string { 121 | return fmt.Sprintf("%s %s", l.timestampField(), message) 122 | } 123 | 124 | func (l *logger) createLogMsg(severity Severity, withTime bool, format string, v ...interface{}) string { 125 | colorFunc := severityColorFuncMap[severity] 126 | message := colorFunc(format, v...) 127 | if withTime { 128 | message = l.prefixCurrentTime(message) 129 | } 130 | 131 | return message 132 | } 133 | 134 | func (l *logger) printf(severity Severity, withTime bool, format string, v ...interface{}) { 135 | message := l.createLogMsg(severity, withTime, format, v...) 136 | if _, err := fmt.Fprintln(l.stdout, message); err != nil { 137 | fmt.Printf("failed to print message: %s, error: %s\n", message, err) 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /mocks/Logger.go: -------------------------------------------------------------------------------- 1 | // Code generated by mockery v2.20.0. DO NOT EDIT. 2 | 3 | package mocks 4 | 5 | import mock "github.com/stretchr/testify/mock" 6 | 7 | // Logger is an autogenerated mock type for the Logger type 8 | type Logger struct { 9 | mock.Mock 10 | } 11 | 12 | // Debugf provides a mock function with given fields: format, v 13 | func (_m *Logger) Debugf(format string, v ...interface{}) { 14 | var _ca []interface{} 15 | _ca = append(_ca, format) 16 | _ca = append(_ca, v...) 17 | _m.Called(_ca...) 18 | } 19 | 20 | // Donef provides a mock function with given fields: format, v 21 | func (_m *Logger) Donef(format string, v ...interface{}) { 22 | var _ca []interface{} 23 | _ca = append(_ca, format) 24 | _ca = append(_ca, v...) 25 | _m.Called(_ca...) 26 | } 27 | 28 | // EnableDebugLog provides a mock function with given fields: enable 29 | func (_m *Logger) EnableDebugLog(enable bool) { 30 | _m.Called(enable) 31 | } 32 | 33 | // Errorf provides a mock function with given fields: format, v 34 | func (_m *Logger) Errorf(format string, v ...interface{}) { 35 | var _ca []interface{} 36 | _ca = append(_ca, format) 37 | _ca = append(_ca, v...) 38 | _m.Called(_ca...) 39 | } 40 | 41 | // Infof provides a mock function with given fields: format, v 42 | func (_m *Logger) Infof(format string, v ...interface{}) { 43 | var _ca []interface{} 44 | _ca = append(_ca, format) 45 | _ca = append(_ca, v...) 46 | _m.Called(_ca...) 47 | } 48 | 49 | // Printf provides a mock function with given fields: format, v 50 | func (_m *Logger) Printf(format string, v ...interface{}) { 51 | var _ca []interface{} 52 | _ca = append(_ca, format) 53 | _ca = append(_ca, v...) 54 | _m.Called(_ca...) 55 | } 56 | 57 | // Println provides a mock function with given fields: 58 | func (_m *Logger) Println() { 59 | _m.Called() 60 | } 61 | 62 | // TDebugf provides a mock function with given fields: format, v 63 | func (_m *Logger) TDebugf(format string, v ...interface{}) { 64 | var _ca []interface{} 65 | _ca = append(_ca, format) 66 | _ca = append(_ca, v...) 67 | _m.Called(_ca...) 68 | } 69 | 70 | // TDonef provides a mock function with given fields: format, v 71 | func (_m *Logger) TDonef(format string, v ...interface{}) { 72 | var _ca []interface{} 73 | _ca = append(_ca, format) 74 | _ca = append(_ca, v...) 75 | _m.Called(_ca...) 76 | } 77 | 78 | // TErrorf provides a mock function with given fields: format, v 79 | func (_m *Logger) TErrorf(format string, v ...interface{}) { 80 | var _ca []interface{} 81 | _ca = append(_ca, format) 82 | _ca = append(_ca, v...) 83 | _m.Called(_ca...) 84 | } 85 | 86 | // TInfof provides a mock function with given fields: format, v 87 | func (_m *Logger) TInfof(format string, v ...interface{}) { 88 | var _ca []interface{} 89 | _ca = append(_ca, format) 90 | _ca = append(_ca, v...) 91 | _m.Called(_ca...) 92 | } 93 | 94 | // TPrintf provides a mock function with given fields: format, v 95 | func (_m *Logger) TPrintf(format string, v ...interface{}) { 96 | var _ca []interface{} 97 | _ca = append(_ca, format) 98 | _ca = append(_ca, v...) 99 | _m.Called(_ca...) 100 | } 101 | 102 | // TWarnf provides a mock function with given fields: format, v 103 | func (_m *Logger) TWarnf(format string, v ...interface{}) { 104 | var _ca []interface{} 105 | _ca = append(_ca, format) 106 | _ca = append(_ca, v...) 107 | _m.Called(_ca...) 108 | } 109 | 110 | // Warnf provides a mock function with given fields: format, v 111 | func (_m *Logger) Warnf(format string, v ...interface{}) { 112 | var _ca []interface{} 113 | _ca = append(_ca, format) 114 | _ca = append(_ca, v...) 115 | _m.Called(_ca...) 116 | } 117 | 118 | type mockConstructorTestingTNewLogger interface { 119 | mock.TestingT 120 | Cleanup(func()) 121 | } 122 | 123 | // NewLogger creates a new instance of Logger. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. 124 | func NewLogger(t mockConstructorTestingTNewLogger) *Logger { 125 | mock := &Logger{} 126 | mock.Mock.Test(t) 127 | 128 | t.Cleanup(func() { mock.AssertExpectations(t) }) 129 | 130 | return mock 131 | } 132 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Install missing Android SDK components 2 | 3 | [![Step changelog](https://shields.io/github/v/release/bitrise-steplib/steps-install-missing-android-tools?include_prereleases&label=changelog&color=blueviolet)](https://github.com/bitrise-steplib/steps-install-missing-android-tools/releases) 4 | 5 | Install Android SDK components that are required for the app. 6 | 7 |
8 | Description 9 | 10 | 11 | This Step makes sure that required Android SDK components (platforms and build-tools) are installed. To do so, the Step runs the `gradlew dependencies` command. 12 | 13 | If the Android Plugin for Gradle version is 2.2.0 or higher, the plugin will download and install the missing components during the Gradle command. 14 | Otherwise the command fails and the Step parses the command's output to determine which SDK components are missing and installs them. 15 | 16 | ### Configuring the Step 17 | 18 | 1. Set the path of the `gradlew` file. 19 | 20 | The default value is that of the $PROJECT_LOCATION Environment Variable. 21 | 22 | 1. If you use an Android NDK in your app, set its revision in the **NDK Revision** input. 23 | 24 | ### Troubleshooting 25 | 26 | If the Step fails, check that your repo actually contains a `gradlew` file. Without the Gradle wrapper, this Step won't work. 27 | 28 | ### Useful links 29 | 30 | [Installing an additional Android SDK package](https://devcenter.bitrise.io/tips-and-tricks/android-tips-and-tricks/#how-to-install-an-additional-android-sdk-package) 31 | 32 | ### Related Steps 33 | 34 | * [Android SDK Update](https://www.bitrise.io/integrations/steps/android-sdk-update) 35 | * [Install React Native](https://www.bitrise.io/integrations/steps/install-react-native) 36 |
37 | 38 | ## 🧩 Get started 39 | 40 | Add this step directly to your workflow in the [Bitrise Workflow Editor](https://docs.bitrise.io/en/bitrise-ci/workflows-and-pipelines/steps/adding-steps-to-a-workflow.html). 41 | 42 | You can also run this step directly with [Bitrise CLI](https://github.com/bitrise-io/bitrise). 43 | 44 | ## ⚙️ Configuration 45 | 46 |
47 | Inputs 48 | 49 | | Key | Description | Flags | Default | 50 | | --- | --- | --- | --- | 51 | | `gradlew_path` | Using a Gradle Wrapper (gradlew) is required, as the wrapper is what makes sure that the right Gradle version is installed and used for the build. __You can find more information about the Gradle Wrapper (gradlew), and about how you can generate one (if you would not have one already)__ in the official guide at: [https://docs.gradle.org/current/userguide/gradle_wrapper.html](https://docs.gradle.org/current/userguide/gradle_wrapper.html). **The path should be relative** to the repository root, for example: `./gradlew`, or if it's in a sub directory: `./sub/dir/gradlew`. | required | `$GRADLEW_PATH` | 52 | | `ndk_version` | NDK version to install, for example `23.0.7599858`. Run `sdkmanager --list` on your machine to see all available versions. Leave this input empty if you are not using the Native Development Kit in your project. | | | 53 | | `gradlew_dependencies_options` | Additional options to be added to the executed `gradlew dependencies` command. The step runs `gradlew dependencies --stacktrace` to list and install the missing project dependencies. Additional options will be appended to the end of this command. Example: `--configuration-cache-problems=warn`. | | | 54 |
55 | 56 |
57 | Outputs 58 | There are no outputs defined in this step 59 |
60 | 61 | ## 🙋 Contributing 62 | 63 | We welcome [pull requests](https://github.com/bitrise-steplib/steps-install-missing-android-tools/pulls) and [issues](https://github.com/bitrise-steplib/steps-install-missing-android-tools/issues) against this repository. 64 | 65 | For pull requests, work on your changes in a forked repository and use the Bitrise CLI to [run step tests locally](https://docs.bitrise.io/en/bitrise-ci/bitrise-cli/running-your-first-local-build-with-the-cli.html). 66 | 67 | Learn more about developing steps: 68 | 69 | - [Create your own step](https://docs.bitrise.io/en/bitrise-ci/workflows-and-pipelines/developing-your-own-bitrise-step/developing-a-new-step.html) 70 | -------------------------------------------------------------------------------- /vendor/gopkg.in/yaml.v3/README.md: -------------------------------------------------------------------------------- 1 | # YAML support for the Go language 2 | 3 | Introduction 4 | ------------ 5 | 6 | The yaml package enables Go programs to comfortably encode and decode YAML 7 | values. It was developed within [Canonical](https://www.canonical.com) as 8 | part of the [juju](https://juju.ubuntu.com) project, and is based on a 9 | pure Go port of the well-known [libyaml](http://pyyaml.org/wiki/LibYAML) 10 | C library to parse and generate YAML data quickly and reliably. 11 | 12 | Compatibility 13 | ------------- 14 | 15 | The yaml package supports most of YAML 1.2, but preserves some behavior 16 | from 1.1 for backwards compatibility. 17 | 18 | Specifically, as of v3 of the yaml package: 19 | 20 | - YAML 1.1 bools (_yes/no, on/off_) are supported as long as they are being 21 | decoded into a typed bool value. Otherwise they behave as a string. Booleans 22 | in YAML 1.2 are _true/false_ only. 23 | - Octals encode and decode as _0777_ per YAML 1.1, rather than _0o777_ 24 | as specified in YAML 1.2, because most parsers still use the old format. 25 | Octals in the _0o777_ format are supported though, so new files work. 26 | - Does not support base-60 floats. These are gone from YAML 1.2, and were 27 | actually never supported by this package as it's clearly a poor choice. 28 | 29 | and offers backwards 30 | compatibility with YAML 1.1 in some cases. 31 | 1.2, including support for 32 | anchors, tags, map merging, etc. Multi-document unmarshalling is not yet 33 | implemented, and base-60 floats from YAML 1.1 are purposefully not 34 | supported since they're a poor design and are gone in YAML 1.2. 35 | 36 | Installation and usage 37 | ---------------------- 38 | 39 | The import path for the package is *gopkg.in/yaml.v3*. 40 | 41 | To install it, run: 42 | 43 | go get gopkg.in/yaml.v3 44 | 45 | API documentation 46 | ----------------- 47 | 48 | If opened in a browser, the import path itself leads to the API documentation: 49 | 50 | - [https://gopkg.in/yaml.v3](https://gopkg.in/yaml.v3) 51 | 52 | API stability 53 | ------------- 54 | 55 | The package API for yaml v3 will remain stable as described in [gopkg.in](https://gopkg.in). 56 | 57 | 58 | License 59 | ------- 60 | 61 | The yaml package is licensed under the MIT and Apache License 2.0 licenses. 62 | Please see the LICENSE file for details. 63 | 64 | 65 | Example 66 | ------- 67 | 68 | ```Go 69 | package main 70 | 71 | import ( 72 | "fmt" 73 | "log" 74 | 75 | "gopkg.in/yaml.v3" 76 | ) 77 | 78 | var data = ` 79 | a: Easy! 80 | b: 81 | c: 2 82 | d: [3, 4] 83 | ` 84 | 85 | // Note: struct fields must be public in order for unmarshal to 86 | // correctly populate the data. 87 | type T struct { 88 | A string 89 | B struct { 90 | RenamedC int `yaml:"c"` 91 | D []int `yaml:",flow"` 92 | } 93 | } 94 | 95 | func main() { 96 | t := T{} 97 | 98 | err := yaml.Unmarshal([]byte(data), &t) 99 | if err != nil { 100 | log.Fatalf("error: %v", err) 101 | } 102 | fmt.Printf("--- t:\n%v\n\n", t) 103 | 104 | d, err := yaml.Marshal(&t) 105 | if err != nil { 106 | log.Fatalf("error: %v", err) 107 | } 108 | fmt.Printf("--- t dump:\n%s\n\n", string(d)) 109 | 110 | m := make(map[interface{}]interface{}) 111 | 112 | err = yaml.Unmarshal([]byte(data), &m) 113 | if err != nil { 114 | log.Fatalf("error: %v", err) 115 | } 116 | fmt.Printf("--- m:\n%v\n\n", m) 117 | 118 | d, err = yaml.Marshal(&m) 119 | if err != nil { 120 | log.Fatalf("error: %v", err) 121 | } 122 | fmt.Printf("--- m dump:\n%s\n\n", string(d)) 123 | } 124 | ``` 125 | 126 | This example will generate the following output: 127 | 128 | ``` 129 | --- t: 130 | {Easy! {2 [3 4]}} 131 | 132 | --- t dump: 133 | a: Easy! 134 | b: 135 | c: 2 136 | d: [3, 4] 137 | 138 | 139 | --- m: 140 | map[a:Easy! b:map[c:2 d:[3 4]]] 141 | 142 | --- m dump: 143 | a: Easy! 144 | b: 145 | c: 2 146 | d: 147 | - 3 148 | - 4 149 | ``` 150 | 151 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/fileutil/fileutil.go: -------------------------------------------------------------------------------- 1 | package fileutil 2 | 3 | import ( 4 | "encoding/json" 5 | "errors" 6 | "fmt" 7 | "io/ioutil" 8 | "log" 9 | "os" 10 | 11 | "github.com/bitrise-io/go-utils/pathutil" 12 | ) 13 | 14 | // WriteStringToFile ... 15 | func WriteStringToFile(pth string, fileCont string) error { 16 | return WriteBytesToFile(pth, []byte(fileCont)) 17 | } 18 | 19 | // WriteStringToFileWithPermission ... 20 | func WriteStringToFileWithPermission(pth string, fileCont string, perm os.FileMode) error { 21 | return WriteBytesToFileWithPermission(pth, []byte(fileCont), perm) 22 | } 23 | 24 | // WriteBytesToFileWithPermission ... 25 | func WriteBytesToFileWithPermission(pth string, fileCont []byte, perm os.FileMode) error { 26 | if pth == "" { 27 | return errors.New("No path provided") 28 | } 29 | 30 | var file *os.File 31 | var err error 32 | if perm == 0 { 33 | file, err = os.Create(pth) 34 | } else { 35 | // same as os.Create, but with a specified permission 36 | // the flags are copy-pasted from the official 37 | // os.Create func: https://golang.org/src/os/file.go?s=7327:7366#L244 38 | file, err = os.OpenFile(pth, os.O_RDWR|os.O_CREATE|os.O_TRUNC, perm) 39 | } 40 | if err != nil { 41 | return err 42 | } 43 | defer func() { 44 | if err := file.Close(); err != nil { 45 | log.Println(" [!] Failed to close file:", err) 46 | } 47 | }() 48 | 49 | if _, err := file.Write(fileCont); err != nil { 50 | return err 51 | } 52 | 53 | return nil 54 | } 55 | 56 | // WriteBytesToFile ... 57 | func WriteBytesToFile(pth string, fileCont []byte) error { 58 | return WriteBytesToFileWithPermission(pth, fileCont, 0) 59 | } 60 | 61 | // WriteJSONToFile ... 62 | func WriteJSONToFile(pth string, fileCont interface{}) error { 63 | bytes, err := json.Marshal(fileCont) 64 | if err != nil { 65 | return fmt.Errorf("failed to JSON marshal the provided object: %+v", err) 66 | } 67 | return WriteBytesToFile(pth, bytes) 68 | } 69 | 70 | // AppendStringToFile ... 71 | func AppendStringToFile(pth string, fileCont string) error { 72 | return AppendBytesToFile(pth, []byte(fileCont)) 73 | } 74 | 75 | // AppendBytesToFile ... 76 | func AppendBytesToFile(pth string, fileCont []byte) error { 77 | if pth == "" { 78 | return errors.New("No path provided") 79 | } 80 | 81 | var file *os.File 82 | filePerm, err := GetFilePermissions(pth) 83 | if err != nil { 84 | // create the file 85 | file, err = os.Create(pth) 86 | } else { 87 | // open for append 88 | file, err = os.OpenFile(pth, os.O_APPEND|os.O_CREATE|os.O_WRONLY, filePerm) 89 | } 90 | if err != nil { 91 | // failed to create or open-for-append the file 92 | return err 93 | } 94 | defer func() { 95 | if err := file.Close(); err != nil { 96 | log.Println(" [!] Failed to close file:", err) 97 | } 98 | }() 99 | 100 | if _, err := file.Write(fileCont); err != nil { 101 | return err 102 | } 103 | 104 | return nil 105 | } 106 | 107 | // ReadBytesFromFile ... 108 | func ReadBytesFromFile(pth string) ([]byte, error) { 109 | if isExists, err := pathutil.IsPathExists(pth); err != nil { 110 | return []byte{}, err 111 | } else if !isExists { 112 | return []byte{}, fmt.Errorf("No file found at path: %s", pth) 113 | } 114 | 115 | bytes, err := ioutil.ReadFile(pth) 116 | if err != nil { 117 | return []byte{}, err 118 | } 119 | return bytes, nil 120 | } 121 | 122 | // ReadStringFromFile ... 123 | func ReadStringFromFile(pth string) (string, error) { 124 | contBytes, err := ReadBytesFromFile(pth) 125 | if err != nil { 126 | return "", err 127 | } 128 | return string(contBytes), nil 129 | } 130 | 131 | // GetFileModeOfFile ... 132 | // this is the "permissions" info, which can be passed directly to 133 | // functions like WriteBytesToFileWithPermission or os.OpenFile 134 | func GetFileModeOfFile(pth string) (os.FileMode, error) { 135 | finfo, err := os.Lstat(pth) 136 | if err != nil { 137 | return 0, err 138 | } 139 | return finfo.Mode(), nil 140 | } 141 | 142 | // GetFilePermissions ... 143 | // - alias of: GetFileModeOfFile 144 | // this is the "permissions" info, which can be passed directly to 145 | // functions like WriteBytesToFileWithPermission or os.OpenFile 146 | func GetFilePermissions(filePth string) (os.FileMode, error) { 147 | return GetFileModeOfFile(filePth) 148 | } 149 | -------------------------------------------------------------------------------- /vendor/github.com/kballard/go-shellquote/unquote.go: -------------------------------------------------------------------------------- 1 | package shellquote 2 | 3 | import ( 4 | "bytes" 5 | "errors" 6 | "strings" 7 | "unicode/utf8" 8 | ) 9 | 10 | var ( 11 | UnterminatedSingleQuoteError = errors.New("Unterminated single-quoted string") 12 | UnterminatedDoubleQuoteError = errors.New("Unterminated double-quoted string") 13 | UnterminatedEscapeError = errors.New("Unterminated backslash-escape") 14 | ) 15 | 16 | var ( 17 | splitChars = " \n\t" 18 | singleChar = '\'' 19 | doubleChar = '"' 20 | escapeChar = '\\' 21 | doubleEscapeChars = "$`\"\n\\" 22 | ) 23 | 24 | // Split splits a string according to /bin/sh's word-splitting rules. It 25 | // supports backslash-escapes, single-quotes, and double-quotes. Notably it does 26 | // not support the $'' style of quoting. It also doesn't attempt to perform any 27 | // other sort of expansion, including brace expansion, shell expansion, or 28 | // pathname expansion. 29 | // 30 | // If the given input has an unterminated quoted string or ends in a 31 | // backslash-escape, one of UnterminatedSingleQuoteError, 32 | // UnterminatedDoubleQuoteError, or UnterminatedEscapeError is returned. 33 | func Split(input string) (words []string, err error) { 34 | var buf bytes.Buffer 35 | words = make([]string, 0) 36 | 37 | for len(input) > 0 { 38 | // skip any splitChars at the start 39 | c, l := utf8.DecodeRuneInString(input) 40 | if strings.ContainsRune(splitChars, c) { 41 | input = input[l:] 42 | continue 43 | } else if c == escapeChar { 44 | // Look ahead for escaped newline so we can skip over it 45 | next := input[l:] 46 | if len(next) == 0 { 47 | err = UnterminatedEscapeError 48 | return 49 | } 50 | c2, l2 := utf8.DecodeRuneInString(next) 51 | if c2 == '\n' { 52 | input = next[l2:] 53 | continue 54 | } 55 | } 56 | 57 | var word string 58 | word, input, err = splitWord(input, &buf) 59 | if err != nil { 60 | return 61 | } 62 | words = append(words, word) 63 | } 64 | return 65 | } 66 | 67 | func splitWord(input string, buf *bytes.Buffer) (word string, remainder string, err error) { 68 | buf.Reset() 69 | 70 | raw: 71 | { 72 | cur := input 73 | for len(cur) > 0 { 74 | c, l := utf8.DecodeRuneInString(cur) 75 | cur = cur[l:] 76 | if c == singleChar { 77 | buf.WriteString(input[0 : len(input)-len(cur)-l]) 78 | input = cur 79 | goto single 80 | } else if c == doubleChar { 81 | buf.WriteString(input[0 : len(input)-len(cur)-l]) 82 | input = cur 83 | goto double 84 | } else if c == escapeChar { 85 | buf.WriteString(input[0 : len(input)-len(cur)-l]) 86 | input = cur 87 | goto escape 88 | } else if strings.ContainsRune(splitChars, c) { 89 | buf.WriteString(input[0 : len(input)-len(cur)-l]) 90 | return buf.String(), cur, nil 91 | } 92 | } 93 | if len(input) > 0 { 94 | buf.WriteString(input) 95 | input = "" 96 | } 97 | goto done 98 | } 99 | 100 | escape: 101 | { 102 | if len(input) == 0 { 103 | return "", "", UnterminatedEscapeError 104 | } 105 | c, l := utf8.DecodeRuneInString(input) 106 | if c == '\n' { 107 | // a backslash-escaped newline is elided from the output entirely 108 | } else { 109 | buf.WriteString(input[:l]) 110 | } 111 | input = input[l:] 112 | } 113 | goto raw 114 | 115 | single: 116 | { 117 | i := strings.IndexRune(input, singleChar) 118 | if i == -1 { 119 | return "", "", UnterminatedSingleQuoteError 120 | } 121 | buf.WriteString(input[0:i]) 122 | input = input[i+1:] 123 | goto raw 124 | } 125 | 126 | double: 127 | { 128 | cur := input 129 | for len(cur) > 0 { 130 | c, l := utf8.DecodeRuneInString(cur) 131 | cur = cur[l:] 132 | if c == doubleChar { 133 | buf.WriteString(input[0 : len(input)-len(cur)-l]) 134 | input = cur 135 | goto raw 136 | } else if c == escapeChar { 137 | // bash only supports certain escapes in double-quoted strings 138 | c2, l2 := utf8.DecodeRuneInString(cur) 139 | cur = cur[l2:] 140 | if strings.ContainsRune(doubleEscapeChars, c2) { 141 | buf.WriteString(input[0 : len(input)-len(cur)-l-l2]) 142 | if c2 == '\n' { 143 | // newline is special, skip the backslash entirely 144 | } else { 145 | buf.WriteRune(c2) 146 | } 147 | input = cur 148 | } 149 | } 150 | } 151 | return "", "", UnterminatedDoubleQuoteError 152 | } 153 | 154 | done: 155 | return buf.String(), input, nil 156 | } 157 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/pathutil/path_filter.go: -------------------------------------------------------------------------------- 1 | package pathutil 2 | 3 | import ( 4 | "errors" 5 | "io/ioutil" 6 | "os" 7 | "path/filepath" 8 | "regexp" 9 | "strings" 10 | ) 11 | 12 | // ListEntries filters contents of a directory using the provided filters 13 | func ListEntries(dir string, filters ...FilterFunc) ([]string, error) { 14 | absDir, err := filepath.Abs(dir) 15 | if err != nil { 16 | return []string{}, err 17 | } 18 | 19 | entries, err := ioutil.ReadDir(absDir) 20 | if err != nil { 21 | return []string{}, err 22 | } 23 | 24 | var paths []string 25 | for _, entry := range entries { 26 | pth := filepath.Join(absDir, entry.Name()) 27 | paths = append(paths, pth) 28 | } 29 | 30 | return FilterPaths(paths, filters...) 31 | } 32 | 33 | // FilterPaths ... 34 | func FilterPaths(fileList []string, filters ...FilterFunc) ([]string, error) { 35 | var filtered []string 36 | 37 | for _, pth := range fileList { 38 | allowed := true 39 | for _, filter := range filters { 40 | if allows, err := filter(pth); err != nil { 41 | return []string{}, err 42 | } else if !allows { 43 | allowed = false 44 | break 45 | } 46 | } 47 | if allowed { 48 | filtered = append(filtered, pth) 49 | } 50 | } 51 | 52 | return filtered, nil 53 | } 54 | 55 | // FilterFunc ... 56 | type FilterFunc func(string) (bool, error) 57 | 58 | // BaseFilter ... 59 | func BaseFilter(base string, allowed bool) FilterFunc { 60 | return func(pth string) (bool, error) { 61 | b := filepath.Base(pth) 62 | return allowed == strings.EqualFold(base, b), nil 63 | } 64 | } 65 | 66 | // ExtensionFilter ... 67 | func ExtensionFilter(ext string, allowed bool) FilterFunc { 68 | return func(pth string) (bool, error) { 69 | e := filepath.Ext(pth) 70 | return allowed == strings.EqualFold(ext, e), nil 71 | } 72 | } 73 | 74 | // RegexpFilter ... 75 | func RegexpFilter(pattern string, allowed bool) FilterFunc { 76 | return func(pth string) (bool, error) { 77 | re := regexp.MustCompile(pattern) 78 | found := re.FindString(pth) != "" 79 | return allowed == found, nil 80 | } 81 | } 82 | 83 | // ComponentFilter ... 84 | func ComponentFilter(component string, allowed bool) FilterFunc { 85 | return func(pth string) (bool, error) { 86 | found := false 87 | pathComponents := strings.Split(pth, string(filepath.Separator)) 88 | for _, c := range pathComponents { 89 | if c == component { 90 | found = true 91 | } 92 | } 93 | return allowed == found, nil 94 | } 95 | } 96 | 97 | // ComponentWithExtensionFilter ... 98 | func ComponentWithExtensionFilter(ext string, allowed bool) FilterFunc { 99 | return func(pth string) (bool, error) { 100 | found := false 101 | pathComponents := strings.Split(pth, string(filepath.Separator)) 102 | for _, c := range pathComponents { 103 | e := filepath.Ext(c) 104 | if e == ext { 105 | found = true 106 | } 107 | } 108 | return allowed == found, nil 109 | } 110 | } 111 | 112 | // IsDirectoryFilter ... 113 | func IsDirectoryFilter(allowed bool) FilterFunc { 114 | return func(pth string) (bool, error) { 115 | fileInf, err := os.Lstat(pth) 116 | if err != nil { 117 | return false, err 118 | } 119 | if fileInf == nil { 120 | return false, errors.New("no file info available") 121 | } 122 | return allowed == fileInf.IsDir(), nil 123 | } 124 | } 125 | 126 | // InDirectoryFilter ... 127 | func InDirectoryFilter(dir string, allowed bool) FilterFunc { 128 | return func(pth string) (bool, error) { 129 | in := filepath.Dir(pth) == dir 130 | return allowed == in, nil 131 | } 132 | } 133 | 134 | // DirectoryContainsFileFilter returns a FilterFunc that checks if a directory contains a file 135 | func DirectoryContainsFileFilter(fileName string) FilterFunc { 136 | return func(pth string) (bool, error) { 137 | isDir, err := IsDirectoryFilter(true)(pth) 138 | if err != nil { 139 | return false, err 140 | } 141 | if !isDir { 142 | return false, nil 143 | } 144 | 145 | absPath := filepath.Join(pth, fileName) 146 | if _, err := os.Lstat(absPath); err != nil { 147 | if !os.IsNotExist(err) { 148 | return false, err 149 | } 150 | return false, nil 151 | } 152 | return true, nil 153 | } 154 | } 155 | 156 | // FileContainsFilter ... 157 | func FileContainsFilter(pth, str string) (bool, error) { 158 | bytes, err := ioutil.ReadFile(pth) 159 | if err != nil { 160 | return false, err 161 | } 162 | 163 | return strings.Contains(string(bytes), str), nil 164 | } 165 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/value.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "fmt" 5 | "strconv" 6 | ) 7 | 8 | // Value provides methods for extracting interface{} data in various 9 | // types. 10 | type Value struct { 11 | // data contains the raw data being managed by this Value 12 | data interface{} 13 | } 14 | 15 | // Data returns the raw data contained by this Value 16 | func (v *Value) Data() interface{} { 17 | return v.data 18 | } 19 | 20 | // String returns the value always as a string 21 | func (v *Value) String() string { 22 | switch { 23 | case v.IsNil(): 24 | return "" 25 | case v.IsStr(): 26 | return v.Str() 27 | case v.IsBool(): 28 | return strconv.FormatBool(v.Bool()) 29 | case v.IsFloat32(): 30 | return strconv.FormatFloat(float64(v.Float32()), 'f', -1, 32) 31 | case v.IsFloat64(): 32 | return strconv.FormatFloat(v.Float64(), 'f', -1, 64) 33 | case v.IsInt(): 34 | return strconv.FormatInt(int64(v.Int()), 10) 35 | case v.IsInt8(): 36 | return strconv.FormatInt(int64(v.Int8()), 10) 37 | case v.IsInt16(): 38 | return strconv.FormatInt(int64(v.Int16()), 10) 39 | case v.IsInt32(): 40 | return strconv.FormatInt(int64(v.Int32()), 10) 41 | case v.IsInt64(): 42 | return strconv.FormatInt(v.Int64(), 10) 43 | case v.IsUint(): 44 | return strconv.FormatUint(uint64(v.Uint()), 10) 45 | case v.IsUint8(): 46 | return strconv.FormatUint(uint64(v.Uint8()), 10) 47 | case v.IsUint16(): 48 | return strconv.FormatUint(uint64(v.Uint16()), 10) 49 | case v.IsUint32(): 50 | return strconv.FormatUint(uint64(v.Uint32()), 10) 51 | case v.IsUint64(): 52 | return strconv.FormatUint(v.Uint64(), 10) 53 | } 54 | return fmt.Sprintf("%#v", v.Data()) 55 | } 56 | 57 | // StringSlice returns the value always as a []string 58 | func (v *Value) StringSlice(optionalDefault ...[]string) []string { 59 | switch { 60 | case v.IsStrSlice(): 61 | return v.MustStrSlice() 62 | case v.IsBoolSlice(): 63 | slice := v.MustBoolSlice() 64 | vals := make([]string, len(slice)) 65 | for i, iv := range slice { 66 | vals[i] = strconv.FormatBool(iv) 67 | } 68 | return vals 69 | case v.IsFloat32Slice(): 70 | slice := v.MustFloat32Slice() 71 | vals := make([]string, len(slice)) 72 | for i, iv := range slice { 73 | vals[i] = strconv.FormatFloat(float64(iv), 'f', -1, 32) 74 | } 75 | return vals 76 | case v.IsFloat64Slice(): 77 | slice := v.MustFloat64Slice() 78 | vals := make([]string, len(slice)) 79 | for i, iv := range slice { 80 | vals[i] = strconv.FormatFloat(iv, 'f', -1, 64) 81 | } 82 | return vals 83 | case v.IsIntSlice(): 84 | slice := v.MustIntSlice() 85 | vals := make([]string, len(slice)) 86 | for i, iv := range slice { 87 | vals[i] = strconv.FormatInt(int64(iv), 10) 88 | } 89 | return vals 90 | case v.IsInt8Slice(): 91 | slice := v.MustInt8Slice() 92 | vals := make([]string, len(slice)) 93 | for i, iv := range slice { 94 | vals[i] = strconv.FormatInt(int64(iv), 10) 95 | } 96 | return vals 97 | case v.IsInt16Slice(): 98 | slice := v.MustInt16Slice() 99 | vals := make([]string, len(slice)) 100 | for i, iv := range slice { 101 | vals[i] = strconv.FormatInt(int64(iv), 10) 102 | } 103 | return vals 104 | case v.IsInt32Slice(): 105 | slice := v.MustInt32Slice() 106 | vals := make([]string, len(slice)) 107 | for i, iv := range slice { 108 | vals[i] = strconv.FormatInt(int64(iv), 10) 109 | } 110 | return vals 111 | case v.IsInt64Slice(): 112 | slice := v.MustInt64Slice() 113 | vals := make([]string, len(slice)) 114 | for i, iv := range slice { 115 | vals[i] = strconv.FormatInt(iv, 10) 116 | } 117 | return vals 118 | case v.IsUintSlice(): 119 | slice := v.MustUintSlice() 120 | vals := make([]string, len(slice)) 121 | for i, iv := range slice { 122 | vals[i] = strconv.FormatUint(uint64(iv), 10) 123 | } 124 | return vals 125 | case v.IsUint8Slice(): 126 | slice := v.MustUint8Slice() 127 | vals := make([]string, len(slice)) 128 | for i, iv := range slice { 129 | vals[i] = strconv.FormatUint(uint64(iv), 10) 130 | } 131 | return vals 132 | case v.IsUint16Slice(): 133 | slice := v.MustUint16Slice() 134 | vals := make([]string, len(slice)) 135 | for i, iv := range slice { 136 | vals[i] = strconv.FormatUint(uint64(iv), 10) 137 | } 138 | return vals 139 | case v.IsUint32Slice(): 140 | slice := v.MustUint32Slice() 141 | vals := make([]string, len(slice)) 142 | for i, iv := range slice { 143 | vals[i] = strconv.FormatUint(uint64(iv), 10) 144 | } 145 | return vals 146 | case v.IsUint64Slice(): 147 | slice := v.MustUint64Slice() 148 | vals := make([]string, len(slice)) 149 | for i, iv := range slice { 150 | vals[i] = strconv.FormatUint(iv, 10) 151 | } 152 | return vals 153 | } 154 | if len(optionalDefault) == 1 { 155 | return optionalDefault[0] 156 | } 157 | 158 | return []string{} 159 | } 160 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/bypass.go: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015-2016 Dave Collins 2 | // 3 | // Permission to use, copy, modify, and distribute this software for any 4 | // purpose with or without fee is hereby granted, provided that the above 5 | // copyright notice and this permission notice appear in all copies. 6 | // 7 | // THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 8 | // WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 9 | // MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 10 | // ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 11 | // WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 12 | // ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 13 | // OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 14 | 15 | // NOTE: Due to the following build constraints, this file will only be compiled 16 | // when the code is not running on Google App Engine, compiled by GopherJS, and 17 | // "-tags safe" is not added to the go build command line. The "disableunsafe" 18 | // tag is deprecated and thus should not be used. 19 | // Go versions prior to 1.4 are disabled because they use a different layout 20 | // for interfaces which make the implementation of unsafeReflectValue more complex. 21 | // +build !js,!appengine,!safe,!disableunsafe,go1.4 22 | 23 | package spew 24 | 25 | import ( 26 | "reflect" 27 | "unsafe" 28 | ) 29 | 30 | const ( 31 | // UnsafeDisabled is a build-time constant which specifies whether or 32 | // not access to the unsafe package is available. 33 | UnsafeDisabled = false 34 | 35 | // ptrSize is the size of a pointer on the current arch. 36 | ptrSize = unsafe.Sizeof((*byte)(nil)) 37 | ) 38 | 39 | type flag uintptr 40 | 41 | var ( 42 | // flagRO indicates whether the value field of a reflect.Value 43 | // is read-only. 44 | flagRO flag 45 | 46 | // flagAddr indicates whether the address of the reflect.Value's 47 | // value may be taken. 48 | flagAddr flag 49 | ) 50 | 51 | // flagKindMask holds the bits that make up the kind 52 | // part of the flags field. In all the supported versions, 53 | // it is in the lower 5 bits. 54 | const flagKindMask = flag(0x1f) 55 | 56 | // Different versions of Go have used different 57 | // bit layouts for the flags type. This table 58 | // records the known combinations. 59 | var okFlags = []struct { 60 | ro, addr flag 61 | }{{ 62 | // From Go 1.4 to 1.5 63 | ro: 1 << 5, 64 | addr: 1 << 7, 65 | }, { 66 | // Up to Go tip. 67 | ro: 1<<5 | 1<<6, 68 | addr: 1 << 8, 69 | }} 70 | 71 | var flagValOffset = func() uintptr { 72 | field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") 73 | if !ok { 74 | panic("reflect.Value has no flag field") 75 | } 76 | return field.Offset 77 | }() 78 | 79 | // flagField returns a pointer to the flag field of a reflect.Value. 80 | func flagField(v *reflect.Value) *flag { 81 | return (*flag)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + flagValOffset)) 82 | } 83 | 84 | // unsafeReflectValue converts the passed reflect.Value into a one that bypasses 85 | // the typical safety restrictions preventing access to unaddressable and 86 | // unexported data. It works by digging the raw pointer to the underlying 87 | // value out of the protected value and generating a new unprotected (unsafe) 88 | // reflect.Value to it. 89 | // 90 | // This allows us to check for implementations of the Stringer and error 91 | // interfaces to be used for pretty printing ordinarily unaddressable and 92 | // inaccessible values such as unexported struct fields. 93 | func unsafeReflectValue(v reflect.Value) reflect.Value { 94 | if !v.IsValid() || (v.CanInterface() && v.CanAddr()) { 95 | return v 96 | } 97 | flagFieldPtr := flagField(&v) 98 | *flagFieldPtr &^= flagRO 99 | *flagFieldPtr |= flagAddr 100 | return v 101 | } 102 | 103 | // Sanity checks against future reflect package changes 104 | // to the type or semantics of the Value.flag field. 105 | func init() { 106 | field, ok := reflect.TypeOf(reflect.Value{}).FieldByName("flag") 107 | if !ok { 108 | panic("reflect.Value has no flag field") 109 | } 110 | if field.Type.Kind() != reflect.TypeOf(flag(0)).Kind() { 111 | panic("reflect.Value flag field has changed kind") 112 | } 113 | type t0 int 114 | var t struct { 115 | A t0 116 | // t0 will have flagEmbedRO set. 117 | t0 118 | // a will have flagStickyRO set 119 | a t0 120 | } 121 | vA := reflect.ValueOf(t).FieldByName("A") 122 | va := reflect.ValueOf(t).FieldByName("a") 123 | vt0 := reflect.ValueOf(t).FieldByName("t0") 124 | 125 | // Infer flagRO from the difference between the flags 126 | // for the (otherwise identical) fields in t. 127 | flagPublic := *flagField(&vA) 128 | flagWithRO := *flagField(&va) | *flagField(&vt0) 129 | flagRO = flagPublic ^ flagWithRO 130 | 131 | // Infer flagAddr from the difference between a value 132 | // taken from a pointer and not. 133 | vPtrA := reflect.ValueOf(&t).Elem().FieldByName("A") 134 | flagNoPtr := *flagField(&vA) 135 | flagPtr := *flagField(&vPtrA) 136 | flagAddr = flagNoPtr ^ flagPtr 137 | 138 | // Check that the inferred flags tally with one of the known versions. 139 | for _, f := range okFlags { 140 | if flagRO == f.ro && flagAddr == f.addr { 141 | return 142 | } 143 | } 144 | panic("reflect.Value read-only flag has changed semantics") 145 | } 146 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-utils/pathutil/pathutil.go: -------------------------------------------------------------------------------- 1 | package pathutil 2 | 3 | import ( 4 | "errors" 5 | "io/ioutil" 6 | "os" 7 | "os/user" 8 | "path/filepath" 9 | "runtime" 10 | "strings" 11 | ) 12 | 13 | // NormalizedOSTempDirPath ... 14 | // Creates a temp dir, and returns its path. 15 | // If tmpDirNamePrefix is provided it'll be used 16 | // as the tmp dir's name prefix. 17 | // Normalized: it's guaranteed that the path won't end with '/'. 18 | func NormalizedOSTempDirPath(tmpDirNamePrefix string) (retPth string, err error) { 19 | retPth, err = ioutil.TempDir("", tmpDirNamePrefix) 20 | if strings.HasSuffix(retPth, "/") { 21 | retPth = retPth[:len(retPth)-1] 22 | } 23 | return 24 | } 25 | 26 | // CurrentWorkingDirectoryAbsolutePath ... 27 | func CurrentWorkingDirectoryAbsolutePath() (string, error) { 28 | return filepath.Abs("./") 29 | } 30 | 31 | // UserHomeDir ... 32 | func UserHomeDir() string { 33 | if runtime.GOOS == "windows" { 34 | home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH") 35 | if home == "" { 36 | home = os.Getenv("USERPROFILE") 37 | } 38 | return home 39 | } 40 | return os.Getenv("HOME") 41 | } 42 | 43 | // EnsureDirExist ... 44 | func EnsureDirExist(dir string) error { 45 | exist, err := IsDirExists(dir) 46 | if !exist || err != nil { 47 | return os.MkdirAll(dir, 0777) 48 | } 49 | return nil 50 | } 51 | 52 | func genericIsPathExists(pth string) (os.FileInfo, bool, error) { 53 | if pth == "" { 54 | return nil, false, errors.New("No path provided") 55 | } 56 | fileInf, err := os.Lstat(pth) 57 | if err == nil { 58 | return fileInf, true, nil 59 | } 60 | if os.IsNotExist(err) { 61 | return nil, false, nil 62 | } 63 | return fileInf, false, err 64 | } 65 | 66 | // PathCheckAndInfos ... 67 | // Returns: 68 | // 1. file info or nil 69 | // 2. bool, indicating whether the path exists 70 | // 3. error, if any error happens during the check 71 | func PathCheckAndInfos(pth string) (os.FileInfo, bool, error) { 72 | return genericIsPathExists(pth) 73 | } 74 | 75 | // IsDirExists ... 76 | func IsDirExists(pth string) (bool, error) { 77 | fileInf, isExists, err := genericIsPathExists(pth) 78 | if err != nil { 79 | return false, err 80 | } 81 | if !isExists { 82 | return false, nil 83 | } 84 | if fileInf == nil { 85 | return false, errors.New("No file info available") 86 | } 87 | return fileInf.IsDir(), nil 88 | } 89 | 90 | // IsPathExists ... 91 | func IsPathExists(pth string) (bool, error) { 92 | _, isExists, err := genericIsPathExists(pth) 93 | return isExists, err 94 | } 95 | 96 | // 97 | // Path modifier functions 98 | 99 | // PathModifier ... 100 | type PathModifier interface { 101 | AbsPath(pth string) (string, error) 102 | } 103 | 104 | type defaultPathModifier struct{} 105 | 106 | // NewPathModifier ... 107 | func NewPathModifier() PathModifier { 108 | return defaultPathModifier{} 109 | } 110 | 111 | // AbsPath ... 112 | func (defaultPathModifier) AbsPath(pth string) (string, error) { 113 | return AbsPath(pth) 114 | } 115 | 116 | // AbsPath expands ENV vars and the ~ character 117 | // then call Go's Abs 118 | func AbsPath(pth string) (string, error) { 119 | if pth == "" { 120 | return "", errors.New("No Path provided") 121 | } 122 | 123 | pth, err := ExpandTilde(pth) 124 | if err != nil { 125 | return "", err 126 | } 127 | 128 | return filepath.Abs(os.ExpandEnv(pth)) 129 | } 130 | 131 | // ExpandTilde ... 132 | func ExpandTilde(pth string) (string, error) { 133 | if pth == "" { 134 | return "", errors.New("No Path provided") 135 | } 136 | 137 | if strings.HasPrefix(pth, "~") { 138 | pth = strings.TrimPrefix(pth, "~") 139 | 140 | if len(pth) == 0 || strings.HasPrefix(pth, "/") { 141 | return os.ExpandEnv("$HOME" + pth), nil 142 | } 143 | 144 | splitPth := strings.Split(pth, "/") 145 | username := splitPth[0] 146 | 147 | usr, err := user.Lookup(username) 148 | if err != nil { 149 | return "", err 150 | } 151 | 152 | pathInUsrHome := strings.Join(splitPth[1:], "/") 153 | 154 | return filepath.Join(usr.HomeDir, pathInUsrHome), nil 155 | } 156 | 157 | return pth, nil 158 | } 159 | 160 | // IsRelativePath ... 161 | func IsRelativePath(pth string) bool { 162 | if strings.HasPrefix(pth, "./") { 163 | return true 164 | } 165 | 166 | if strings.HasPrefix(pth, "/") { 167 | return false 168 | } 169 | 170 | if strings.HasPrefix(pth, "$") { 171 | return false 172 | } 173 | 174 | return true 175 | } 176 | 177 | // GetFileName returns the name of the file from a given path or the name of the directory if it is a directory 178 | func GetFileName(path string) string { 179 | return strings.TrimSuffix(filepath.Base(path), filepath.Ext(path)) 180 | } 181 | 182 | // EscapeGlobPath escapes a partial path, determined at runtime, used as a parameter for filepath.Glob 183 | func EscapeGlobPath(path string) string { 184 | var escaped string 185 | for _, ch := range path { 186 | if ch == '[' || ch == ']' || ch == '-' || ch == '*' || ch == '?' || ch == '\\' { 187 | escaped += "\\" 188 | } 189 | escaped += string(ch) 190 | } 191 | return escaped 192 | } 193 | 194 | // 195 | // Change dir functions 196 | 197 | // RevokableChangeDir ... 198 | func RevokableChangeDir(dir string) (func() error, error) { 199 | origDir, err := CurrentWorkingDirectoryAbsolutePath() 200 | if err != nil { 201 | return nil, err 202 | } 203 | 204 | revokeFn := func() error { 205 | return os.Chdir(origDir) 206 | } 207 | 208 | return revokeFn, os.Chdir(dir) 209 | } 210 | 211 | // ChangeDirForFunction ... 212 | func ChangeDirForFunction(dir string, fn func()) error { 213 | revokeFn, err := RevokableChangeDir(dir) 214 | if err != nil { 215 | return err 216 | } 217 | 218 | fn() 219 | 220 | return revokeFn() 221 | } 222 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/objx/accessors.go: -------------------------------------------------------------------------------- 1 | package objx 2 | 3 | import ( 4 | "reflect" 5 | "regexp" 6 | "strconv" 7 | "strings" 8 | ) 9 | 10 | const ( 11 | // PathSeparator is the character used to separate the elements 12 | // of the keypath. 13 | // 14 | // For example, `location.address.city` 15 | PathSeparator string = "." 16 | 17 | // arrayAccesRegexString is the regex used to extract the array number 18 | // from the access path 19 | arrayAccesRegexString = `^(.+)\[([0-9]+)\]$` 20 | 21 | // mapAccessRegexString is the regex used to extract the map key 22 | // from the access path 23 | mapAccessRegexString = `^([^\[]*)\[([^\]]+)\](.*)$` 24 | ) 25 | 26 | // arrayAccesRegex is the compiled arrayAccesRegexString 27 | var arrayAccesRegex = regexp.MustCompile(arrayAccesRegexString) 28 | 29 | // mapAccessRegex is the compiled mapAccessRegexString 30 | var mapAccessRegex = regexp.MustCompile(mapAccessRegexString) 31 | 32 | // Get gets the value using the specified selector and 33 | // returns it inside a new Obj object. 34 | // 35 | // If it cannot find the value, Get will return a nil 36 | // value inside an instance of Obj. 37 | // 38 | // Get can only operate directly on map[string]interface{} and []interface. 39 | // 40 | // Example 41 | // 42 | // To access the title of the third chapter of the second book, do: 43 | // 44 | // o.Get("books[1].chapters[2].title") 45 | func (m Map) Get(selector string) *Value { 46 | rawObj := access(m, selector, nil, false) 47 | return &Value{data: rawObj} 48 | } 49 | 50 | // Set sets the value using the specified selector and 51 | // returns the object on which Set was called. 52 | // 53 | // Set can only operate directly on map[string]interface{} and []interface 54 | // 55 | // Example 56 | // 57 | // To set the title of the third chapter of the second book, do: 58 | // 59 | // o.Set("books[1].chapters[2].title","Time to Go") 60 | func (m Map) Set(selector string, value interface{}) Map { 61 | access(m, selector, value, true) 62 | return m 63 | } 64 | 65 | // getIndex returns the index, which is hold in s by two braches. 66 | // It also returns s withour the index part, e.g. name[1] will return (1, name). 67 | // If no index is found, -1 is returned 68 | func getIndex(s string) (int, string) { 69 | arrayMatches := arrayAccesRegex.FindStringSubmatch(s) 70 | if len(arrayMatches) > 0 { 71 | // Get the key into the map 72 | selector := arrayMatches[1] 73 | // Get the index into the array at the key 74 | // We know this cannt fail because arrayMatches[2] is an int for sure 75 | index, _ := strconv.Atoi(arrayMatches[2]) 76 | return index, selector 77 | } 78 | return -1, s 79 | } 80 | 81 | // getKey returns the key which is held in s by two brackets. 82 | // It also returns the next selector. 83 | func getKey(s string) (string, string) { 84 | selSegs := strings.SplitN(s, PathSeparator, 2) 85 | thisSel := selSegs[0] 86 | nextSel := "" 87 | 88 | if len(selSegs) > 1 { 89 | nextSel = selSegs[1] 90 | } 91 | 92 | mapMatches := mapAccessRegex.FindStringSubmatch(s) 93 | if len(mapMatches) > 0 { 94 | if _, err := strconv.Atoi(mapMatches[2]); err != nil { 95 | thisSel = mapMatches[1] 96 | nextSel = "[" + mapMatches[2] + "]" + mapMatches[3] 97 | 98 | if thisSel == "" { 99 | thisSel = mapMatches[2] 100 | nextSel = mapMatches[3] 101 | } 102 | 103 | if nextSel == "" { 104 | selSegs = []string{"", ""} 105 | } else if nextSel[0] == '.' { 106 | nextSel = nextSel[1:] 107 | } 108 | } 109 | } 110 | 111 | return thisSel, nextSel 112 | } 113 | 114 | // access accesses the object using the selector and performs the 115 | // appropriate action. 116 | func access(current interface{}, selector string, value interface{}, isSet bool) interface{} { 117 | thisSel, nextSel := getKey(selector) 118 | 119 | indexes := []int{} 120 | for strings.Contains(thisSel, "[") { 121 | prevSel := thisSel 122 | index := -1 123 | index, thisSel = getIndex(thisSel) 124 | indexes = append(indexes, index) 125 | if prevSel == thisSel { 126 | break 127 | } 128 | } 129 | 130 | if curMap, ok := current.(Map); ok { 131 | current = map[string]interface{}(curMap) 132 | } 133 | // get the object in question 134 | switch current.(type) { 135 | case map[string]interface{}: 136 | curMSI := current.(map[string]interface{}) 137 | if nextSel == "" && isSet { 138 | curMSI[thisSel] = value 139 | return nil 140 | } 141 | 142 | _, ok := curMSI[thisSel].(map[string]interface{}) 143 | if !ok { 144 | _, ok = curMSI[thisSel].(Map) 145 | } 146 | 147 | if (curMSI[thisSel] == nil || !ok) && len(indexes) == 0 && isSet { 148 | curMSI[thisSel] = map[string]interface{}{} 149 | } 150 | 151 | current = curMSI[thisSel] 152 | default: 153 | current = nil 154 | } 155 | 156 | // do we need to access the item of an array? 157 | if len(indexes) > 0 { 158 | num := len(indexes) 159 | for num > 0 { 160 | num-- 161 | index := indexes[num] 162 | indexes = indexes[:num] 163 | if array, ok := interSlice(current); ok { 164 | if index < len(array) { 165 | current = array[index] 166 | } else { 167 | current = nil 168 | break 169 | } 170 | } 171 | } 172 | } 173 | 174 | if nextSel != "" { 175 | current = access(current, nextSel, value, isSet) 176 | } 177 | return current 178 | } 179 | 180 | func interSlice(slice interface{}) ([]interface{}, bool) { 181 | if array, ok := slice.([]interface{}); ok { 182 | return array, ok 183 | } 184 | 185 | s := reflect.ValueOf(slice) 186 | if s.Kind() != reflect.Slice { 187 | return nil, false 188 | } 189 | 190 | ret := make([]interface{}, s.Len()) 191 | 192 | for i := 0; i < s.Len(); i++ { 193 | ret[i] = s.Index(i).Interface() 194 | } 195 | 196 | return ret, true 197 | } 198 | -------------------------------------------------------------------------------- /vendor/github.com/bitrise-io/go-android/sdk/sdk.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "os" 7 | "path/filepath" 8 | "strings" 9 | 10 | "github.com/bitrise-io/go-utils/pathutil" 11 | "github.com/hashicorp/go-version" 12 | ) 13 | 14 | // Model ... 15 | type Model struct { 16 | androidHome string 17 | } 18 | 19 | // Environment is used to pass in environment variables used to locate Android SDK 20 | type Environment struct { 21 | AndroidHome string // ANDROID_HOME 22 | AndroidSDKRoot string // ANDROID_SDK_ROOT 23 | } 24 | 25 | // NewEnvironment gets needed environment variables 26 | func NewEnvironment() *Environment { 27 | return &Environment{ 28 | AndroidHome: os.Getenv("ANDROID_HOME"), 29 | AndroidSDKRoot: os.Getenv("ANDROID_SDK_ROOT"), 30 | } 31 | } 32 | 33 | // AndroidSdkInterface ... 34 | type AndroidSdkInterface interface { 35 | GetAndroidHome() string 36 | CmdlineToolsPath() (string, error) 37 | } 38 | 39 | // New creates a Model with a supplied Android SDK path 40 | func New(androidHome string) (*Model, error) { 41 | evaluatedSDKRoot, err := validateAndroidSDKRoot(androidHome) 42 | if err != nil { 43 | return nil, err 44 | } 45 | 46 | return &Model{androidHome: evaluatedSDKRoot}, nil 47 | } 48 | 49 | // NewDefaultModel locates Android SDK based on environement variables 50 | func NewDefaultModel(envs Environment) (*Model, error) { 51 | // https://developer.android.com/studio/command-line/variables#envar 52 | // Sets the path to the SDK installation directory. 53 | // ANDROID_HOME, which also points to the SDK installation directory, is deprecated. 54 | // If you continue to use it, the following rules apply: 55 | // If ANDROID_HOME is defined and contains a valid SDK installation, its value is used instead of the value in ANDROID_SDK_ROOT. 56 | // If ANDROID_HOME is not defined, the value in ANDROID_SDK_ROOT is used. 57 | var warnings []string 58 | for _, SDKdir := range []string{envs.AndroidHome, envs.AndroidSDKRoot} { 59 | if SDKdir == "" { 60 | warnings = append(warnings, "environment variable is unset or empty") 61 | continue 62 | } 63 | 64 | evaluatedSDKRoot, err := validateAndroidSDKRoot(SDKdir) 65 | if err != nil { 66 | warnings = append(warnings, err.Error()) 67 | continue 68 | } 69 | 70 | return &Model{androidHome: evaluatedSDKRoot}, nil 71 | } 72 | 73 | return nil, fmt.Errorf("could not locate Android SDK root directory: %s", warnings) 74 | } 75 | 76 | func validateAndroidSDKRoot(androidSDKRoot string) (string, error) { 77 | evaluatedSDKRoot, err := filepath.EvalSymlinks(androidSDKRoot) 78 | if err != nil { 79 | return "", err 80 | } 81 | 82 | if exist, err := pathutil.IsDirExists(evaluatedSDKRoot); err != nil { 83 | return "", err 84 | } else if !exist { 85 | return "", fmt.Errorf("(%s) is not a valid Android SDK root", evaluatedSDKRoot) 86 | } 87 | 88 | return evaluatedSDKRoot, nil 89 | } 90 | 91 | // GetAndroidHome ... 92 | func (model *Model) GetAndroidHome() string { 93 | return model.androidHome 94 | } 95 | 96 | // LatestBuildToolsDir ... 97 | func (model *Model) LatestBuildToolsDir() (string, error) { 98 | buildTools := filepath.Join(model.androidHome, "build-tools") 99 | pattern := filepath.Join(buildTools, "*") 100 | 101 | buildToolsDirs, err := filepath.Glob(pattern) 102 | if err != nil { 103 | return "", err 104 | } 105 | 106 | var latestVersion *version.Version 107 | for _, buildToolsDir := range buildToolsDirs { 108 | versionStr := strings.TrimPrefix(buildToolsDir, buildTools+"/") 109 | version, err := version.NewVersion(versionStr) 110 | if err != nil { 111 | continue 112 | } 113 | 114 | if latestVersion == nil || version.GreaterThan(latestVersion) { 115 | latestVersion = version 116 | } 117 | } 118 | 119 | if latestVersion == nil || latestVersion.String() == "" { 120 | return "", errors.New("failed to find latest build-tools dir") 121 | } 122 | 123 | return filepath.Join(buildTools, latestVersion.String()), nil 124 | } 125 | 126 | // LatestBuildToolPath ... 127 | func (model *Model) LatestBuildToolPath(name string) (string, error) { 128 | buildToolsDir, err := model.LatestBuildToolsDir() 129 | if err != nil { 130 | return "", err 131 | } 132 | 133 | pth := filepath.Join(buildToolsDir, name) 134 | if exist, err := pathutil.IsPathExists(pth); err != nil { 135 | return "", err 136 | } else if !exist { 137 | return "", fmt.Errorf("tool (%s) not found at: %s", name, buildToolsDir) 138 | } 139 | 140 | return pth, nil 141 | } 142 | 143 | // CmdlineToolsPath locates the command-line tools directory 144 | func (model *Model) CmdlineToolsPath() (string, error) { 145 | toolPaths := []string{ 146 | filepath.Join(model.GetAndroidHome(), "cmdline-tools", "latest", "bin"), 147 | filepath.Join(model.GetAndroidHome(), "cmdline-tools", "*", "bin"), 148 | filepath.Join(model.GetAndroidHome(), "tools", "bin"), 149 | filepath.Join(model.GetAndroidHome(), "tools"), // legacy 150 | } 151 | 152 | var warnings []string 153 | for _, dirPattern := range toolPaths { 154 | matches, err := filepath.Glob(dirPattern) 155 | if err != nil { 156 | return "", fmt.Errorf("failed to locate Android command-line tools directory, invalid patterns specified (%s): %s", toolPaths, err) 157 | } 158 | 159 | if len(matches) == 0 { 160 | continue 161 | } 162 | 163 | sdkmanagerPath := matches[0] 164 | if exists, err := pathutil.IsDirExists(sdkmanagerPath); err != nil { 165 | warnings = append(warnings, fmt.Sprintf("failed to validate path (%s): %v", sdkmanagerPath, err)) 166 | continue 167 | } else if !exists { 168 | warnings = append(warnings, "path (%s) does not exist or it is not a directory") 169 | continue 170 | } 171 | 172 | return sdkmanagerPath, nil 173 | } 174 | 175 | return "", fmt.Errorf("failed to locate Android command-line tools directory on paths (%s), warnings: %s", toolPaths, warnings) 176 | } 177 | -------------------------------------------------------------------------------- /vendor/github.com/hashicorp/go-version/constraint.go: -------------------------------------------------------------------------------- 1 | package version 2 | 3 | import ( 4 | "fmt" 5 | "reflect" 6 | "regexp" 7 | "strings" 8 | ) 9 | 10 | // Constraint represents a single constraint for a version, such as 11 | // ">= 1.0". 12 | type Constraint struct { 13 | f constraintFunc 14 | check *Version 15 | original string 16 | } 17 | 18 | // Constraints is a slice of constraints. We make a custom type so that 19 | // we can add methods to it. 20 | type Constraints []*Constraint 21 | 22 | type constraintFunc func(v, c *Version) bool 23 | 24 | var constraintOperators map[string]constraintFunc 25 | 26 | var constraintRegexp *regexp.Regexp 27 | 28 | func init() { 29 | constraintOperators = map[string]constraintFunc{ 30 | "": constraintEqual, 31 | "=": constraintEqual, 32 | "!=": constraintNotEqual, 33 | ">": constraintGreaterThan, 34 | "<": constraintLessThan, 35 | ">=": constraintGreaterThanEqual, 36 | "<=": constraintLessThanEqual, 37 | "~>": constraintPessimistic, 38 | } 39 | 40 | ops := make([]string, 0, len(constraintOperators)) 41 | for k := range constraintOperators { 42 | ops = append(ops, regexp.QuoteMeta(k)) 43 | } 44 | 45 | constraintRegexp = regexp.MustCompile(fmt.Sprintf( 46 | `^\s*(%s)\s*(%s)\s*$`, 47 | strings.Join(ops, "|"), 48 | VersionRegexpRaw)) 49 | } 50 | 51 | // NewConstraint will parse one or more constraints from the given 52 | // constraint string. The string must be a comma-separated list of 53 | // constraints. 54 | func NewConstraint(v string) (Constraints, error) { 55 | vs := strings.Split(v, ",") 56 | result := make([]*Constraint, len(vs)) 57 | for i, single := range vs { 58 | c, err := parseSingle(single) 59 | if err != nil { 60 | return nil, err 61 | } 62 | 63 | result[i] = c 64 | } 65 | 66 | return Constraints(result), nil 67 | } 68 | 69 | // Check tests if a version satisfies all the constraints. 70 | func (cs Constraints) Check(v *Version) bool { 71 | for _, c := range cs { 72 | if !c.Check(v) { 73 | return false 74 | } 75 | } 76 | 77 | return true 78 | } 79 | 80 | // Returns the string format of the constraints 81 | func (cs Constraints) String() string { 82 | csStr := make([]string, len(cs)) 83 | for i, c := range cs { 84 | csStr[i] = c.String() 85 | } 86 | 87 | return strings.Join(csStr, ",") 88 | } 89 | 90 | // Check tests if a constraint is validated by the given version. 91 | func (c *Constraint) Check(v *Version) bool { 92 | return c.f(v, c.check) 93 | } 94 | 95 | func (c *Constraint) String() string { 96 | return c.original 97 | } 98 | 99 | func parseSingle(v string) (*Constraint, error) { 100 | matches := constraintRegexp.FindStringSubmatch(v) 101 | if matches == nil { 102 | return nil, fmt.Errorf("Malformed constraint: %s", v) 103 | } 104 | 105 | check, err := NewVersion(matches[2]) 106 | if err != nil { 107 | return nil, err 108 | } 109 | 110 | return &Constraint{ 111 | f: constraintOperators[matches[1]], 112 | check: check, 113 | original: v, 114 | }, nil 115 | } 116 | 117 | func prereleaseCheck(v, c *Version) bool { 118 | switch vPre, cPre := v.Prerelease() != "", c.Prerelease() != ""; { 119 | case cPre && vPre: 120 | // A constraint with a pre-release can only match a pre-release version 121 | // with the same base segments. 122 | return reflect.DeepEqual(c.Segments64(), v.Segments64()) 123 | 124 | case !cPre && vPre: 125 | // A constraint without a pre-release can only match a version without a 126 | // pre-release. 127 | return false 128 | 129 | case cPre && !vPre: 130 | // OK, except with the pessimistic operator 131 | case !cPre && !vPre: 132 | // OK 133 | } 134 | return true 135 | } 136 | 137 | //------------------------------------------------------------------- 138 | // Constraint functions 139 | //------------------------------------------------------------------- 140 | 141 | func constraintEqual(v, c *Version) bool { 142 | return v.Equal(c) 143 | } 144 | 145 | func constraintNotEqual(v, c *Version) bool { 146 | return !v.Equal(c) 147 | } 148 | 149 | func constraintGreaterThan(v, c *Version) bool { 150 | return prereleaseCheck(v, c) && v.Compare(c) == 1 151 | } 152 | 153 | func constraintLessThan(v, c *Version) bool { 154 | return prereleaseCheck(v, c) && v.Compare(c) == -1 155 | } 156 | 157 | func constraintGreaterThanEqual(v, c *Version) bool { 158 | return prereleaseCheck(v, c) && v.Compare(c) >= 0 159 | } 160 | 161 | func constraintLessThanEqual(v, c *Version) bool { 162 | return prereleaseCheck(v, c) && v.Compare(c) <= 0 163 | } 164 | 165 | func constraintPessimistic(v, c *Version) bool { 166 | // Using a pessimistic constraint with a pre-release, restricts versions to pre-releases 167 | if !prereleaseCheck(v, c) || (c.Prerelease() != "" && v.Prerelease() == "") { 168 | return false 169 | } 170 | 171 | // If the version being checked is naturally less than the constraint, then there 172 | // is no way for the version to be valid against the constraint 173 | if v.LessThan(c) { 174 | return false 175 | } 176 | // We'll use this more than once, so grab the length now so it's a little cleaner 177 | // to write the later checks 178 | cs := len(c.segments) 179 | 180 | // If the version being checked has less specificity than the constraint, then there 181 | // is no way for the version to be valid against the constraint 182 | if cs > len(v.segments) { 183 | return false 184 | } 185 | 186 | // Check the segments in the constraint against those in the version. If the version 187 | // being checked, at any point, does not have the same values in each index of the 188 | // constraints segments, then it cannot be valid against the constraint. 189 | for i := 0; i < c.si-1; i++ { 190 | if v.segments[i] != c.segments[i] { 191 | return false 192 | } 193 | } 194 | 195 | // Check the last part of the segment in the constraint. If the version segment at 196 | // this index is less than the constraints segment at this index, then it cannot 197 | // be valid against the constraint 198 | if c.segments[cs-1] > v.segments[cs-1] { 199 | return false 200 | } 201 | 202 | // If nothing has rejected the version by now, it's valid 203 | return true 204 | } 205 | -------------------------------------------------------------------------------- /vendor/github.com/stretchr/testify/assert/http_assertions.go: -------------------------------------------------------------------------------- 1 | package assert 2 | 3 | import ( 4 | "fmt" 5 | "net/http" 6 | "net/http/httptest" 7 | "net/url" 8 | "strings" 9 | ) 10 | 11 | // httpCode is a helper that returns HTTP code of the response. It returns -1 and 12 | // an error if building a new request fails. 13 | func httpCode(handler http.HandlerFunc, method, url string, values url.Values) (int, error) { 14 | w := httptest.NewRecorder() 15 | req, err := http.NewRequest(method, url, nil) 16 | if err != nil { 17 | return -1, err 18 | } 19 | req.URL.RawQuery = values.Encode() 20 | handler(w, req) 21 | return w.Code, nil 22 | } 23 | 24 | // HTTPSuccess asserts that a specified handler returns a success status code. 25 | // 26 | // assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) 27 | // 28 | // Returns whether the assertion was successful (true) or not (false). 29 | func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { 30 | if h, ok := t.(tHelper); ok { 31 | h.Helper() 32 | } 33 | code, err := httpCode(handler, method, url, values) 34 | if err != nil { 35 | Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) 36 | } 37 | 38 | isSuccessCode := code >= http.StatusOK && code <= http.StatusPartialContent 39 | if !isSuccessCode { 40 | Fail(t, fmt.Sprintf("Expected HTTP success status code for %q but received %d", url+"?"+values.Encode(), code)) 41 | } 42 | 43 | return isSuccessCode 44 | } 45 | 46 | // HTTPRedirect asserts that a specified handler returns a redirect status code. 47 | // 48 | // assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} 49 | // 50 | // Returns whether the assertion was successful (true) or not (false). 51 | func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { 52 | if h, ok := t.(tHelper); ok { 53 | h.Helper() 54 | } 55 | code, err := httpCode(handler, method, url, values) 56 | if err != nil { 57 | Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) 58 | } 59 | 60 | isRedirectCode := code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect 61 | if !isRedirectCode { 62 | Fail(t, fmt.Sprintf("Expected HTTP redirect status code for %q but received %d", url+"?"+values.Encode(), code)) 63 | } 64 | 65 | return isRedirectCode 66 | } 67 | 68 | // HTTPError asserts that a specified handler returns an error status code. 69 | // 70 | // assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} 71 | // 72 | // Returns whether the assertion was successful (true) or not (false). 73 | func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { 74 | if h, ok := t.(tHelper); ok { 75 | h.Helper() 76 | } 77 | code, err := httpCode(handler, method, url, values) 78 | if err != nil { 79 | Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) 80 | } 81 | 82 | isErrorCode := code >= http.StatusBadRequest 83 | if !isErrorCode { 84 | Fail(t, fmt.Sprintf("Expected HTTP error status code for %q but received %d", url+"?"+values.Encode(), code)) 85 | } 86 | 87 | return isErrorCode 88 | } 89 | 90 | // HTTPStatusCode asserts that a specified handler returns a specified status code. 91 | // 92 | // assert.HTTPStatusCode(t, myHandler, "GET", "/notImplemented", nil, 501) 93 | // 94 | // Returns whether the assertion was successful (true) or not (false). 95 | func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, statuscode int, msgAndArgs ...interface{}) bool { 96 | if h, ok := t.(tHelper); ok { 97 | h.Helper() 98 | } 99 | code, err := httpCode(handler, method, url, values) 100 | if err != nil { 101 | Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) 102 | } 103 | 104 | successful := code == statuscode 105 | if !successful { 106 | Fail(t, fmt.Sprintf("Expected HTTP status code %d for %q but received %d", statuscode, url+"?"+values.Encode(), code)) 107 | } 108 | 109 | return successful 110 | } 111 | 112 | // HTTPBody is a helper that returns HTTP body of the response. It returns 113 | // empty string if building a new request fails. 114 | func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string { 115 | w := httptest.NewRecorder() 116 | req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) 117 | if err != nil { 118 | return "" 119 | } 120 | handler(w, req) 121 | return w.Body.String() 122 | } 123 | 124 | // HTTPBodyContains asserts that a specified handler returns a 125 | // body that contains a string. 126 | // 127 | // assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") 128 | // 129 | // Returns whether the assertion was successful (true) or not (false). 130 | func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { 131 | if h, ok := t.(tHelper); ok { 132 | h.Helper() 133 | } 134 | body := HTTPBody(handler, method, url, values) 135 | 136 | contains := strings.Contains(body, fmt.Sprint(str)) 137 | if !contains { 138 | Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) 139 | } 140 | 141 | return contains 142 | } 143 | 144 | // HTTPBodyNotContains asserts that a specified handler returns a 145 | // body that does not contain a string. 146 | // 147 | // assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") 148 | // 149 | // Returns whether the assertion was successful (true) or not (false). 150 | func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { 151 | if h, ok := t.(tHelper); ok { 152 | h.Helper() 153 | } 154 | body := HTTPBody(handler, method, url, values) 155 | 156 | contains := strings.Contains(body, fmt.Sprint(str)) 157 | if contains { 158 | Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) 159 | } 160 | 161 | return !contains 162 | } 163 | -------------------------------------------------------------------------------- /vendor/github.com/davecgh/go-spew/spew/spew.go: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2013-2016 Dave Collins 3 | * 4 | * Permission to use, copy, modify, and distribute this software for any 5 | * purpose with or without fee is hereby granted, provided that the above 6 | * copyright notice and this permission notice appear in all copies. 7 | * 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15 | */ 16 | 17 | package spew 18 | 19 | import ( 20 | "fmt" 21 | "io" 22 | ) 23 | 24 | // Errorf is a wrapper for fmt.Errorf that treats each argument as if it were 25 | // passed with a default Formatter interface returned by NewFormatter. It 26 | // returns the formatted string as a value that satisfies error. See 27 | // NewFormatter for formatting details. 28 | // 29 | // This function is shorthand for the following syntax: 30 | // 31 | // fmt.Errorf(format, spew.NewFormatter(a), spew.NewFormatter(b)) 32 | func Errorf(format string, a ...interface{}) (err error) { 33 | return fmt.Errorf(format, convertArgs(a)...) 34 | } 35 | 36 | // Fprint is a wrapper for fmt.Fprint that treats each argument as if it were 37 | // passed with a default Formatter interface returned by NewFormatter. It 38 | // returns the number of bytes written and any write error encountered. See 39 | // NewFormatter for formatting details. 40 | // 41 | // This function is shorthand for the following syntax: 42 | // 43 | // fmt.Fprint(w, spew.NewFormatter(a), spew.NewFormatter(b)) 44 | func Fprint(w io.Writer, a ...interface{}) (n int, err error) { 45 | return fmt.Fprint(w, convertArgs(a)...) 46 | } 47 | 48 | // Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were 49 | // passed with a default Formatter interface returned by NewFormatter. It 50 | // returns the number of bytes written and any write error encountered. See 51 | // NewFormatter for formatting details. 52 | // 53 | // This function is shorthand for the following syntax: 54 | // 55 | // fmt.Fprintf(w, format, spew.NewFormatter(a), spew.NewFormatter(b)) 56 | func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { 57 | return fmt.Fprintf(w, format, convertArgs(a)...) 58 | } 59 | 60 | // Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it 61 | // passed with a default Formatter interface returned by NewFormatter. See 62 | // NewFormatter for formatting details. 63 | // 64 | // This function is shorthand for the following syntax: 65 | // 66 | // fmt.Fprintln(w, spew.NewFormatter(a), spew.NewFormatter(b)) 67 | func Fprintln(w io.Writer, a ...interface{}) (n int, err error) { 68 | return fmt.Fprintln(w, convertArgs(a)...) 69 | } 70 | 71 | // Print is a wrapper for fmt.Print that treats each argument as if it were 72 | // passed with a default Formatter interface returned by NewFormatter. It 73 | // returns the number of bytes written and any write error encountered. See 74 | // NewFormatter for formatting details. 75 | // 76 | // This function is shorthand for the following syntax: 77 | // 78 | // fmt.Print(spew.NewFormatter(a), spew.NewFormatter(b)) 79 | func Print(a ...interface{}) (n int, err error) { 80 | return fmt.Print(convertArgs(a)...) 81 | } 82 | 83 | // Printf is a wrapper for fmt.Printf that treats each argument as if it were 84 | // passed with a default Formatter interface returned by NewFormatter. It 85 | // returns the number of bytes written and any write error encountered. See 86 | // NewFormatter for formatting details. 87 | // 88 | // This function is shorthand for the following syntax: 89 | // 90 | // fmt.Printf(format, spew.NewFormatter(a), spew.NewFormatter(b)) 91 | func Printf(format string, a ...interface{}) (n int, err error) { 92 | return fmt.Printf(format, convertArgs(a)...) 93 | } 94 | 95 | // Println is a wrapper for fmt.Println that treats each argument as if it were 96 | // passed with a default Formatter interface returned by NewFormatter. It 97 | // returns the number of bytes written and any write error encountered. See 98 | // NewFormatter for formatting details. 99 | // 100 | // This function is shorthand for the following syntax: 101 | // 102 | // fmt.Println(spew.NewFormatter(a), spew.NewFormatter(b)) 103 | func Println(a ...interface{}) (n int, err error) { 104 | return fmt.Println(convertArgs(a)...) 105 | } 106 | 107 | // Sprint is a wrapper for fmt.Sprint that treats each argument as if it were 108 | // passed with a default Formatter interface returned by NewFormatter. It 109 | // returns the resulting string. See NewFormatter for formatting details. 110 | // 111 | // This function is shorthand for the following syntax: 112 | // 113 | // fmt.Sprint(spew.NewFormatter(a), spew.NewFormatter(b)) 114 | func Sprint(a ...interface{}) string { 115 | return fmt.Sprint(convertArgs(a)...) 116 | } 117 | 118 | // Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were 119 | // passed with a default Formatter interface returned by NewFormatter. It 120 | // returns the resulting string. See NewFormatter for formatting details. 121 | // 122 | // This function is shorthand for the following syntax: 123 | // 124 | // fmt.Sprintf(format, spew.NewFormatter(a), spew.NewFormatter(b)) 125 | func Sprintf(format string, a ...interface{}) string { 126 | return fmt.Sprintf(format, convertArgs(a)...) 127 | } 128 | 129 | // Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it 130 | // were passed with a default Formatter interface returned by NewFormatter. It 131 | // returns the resulting string. See NewFormatter for formatting details. 132 | // 133 | // This function is shorthand for the following syntax: 134 | // 135 | // fmt.Sprintln(spew.NewFormatter(a), spew.NewFormatter(b)) 136 | func Sprintln(a ...interface{}) string { 137 | return fmt.Sprintln(convertArgs(a)...) 138 | } 139 | 140 | // convertArgs accepts a slice of arguments and returns a slice of the same 141 | // length with each argument converted to a default spew Formatter interface. 142 | func convertArgs(args []interface{}) (formatters []interface{}) { 143 | formatters = make([]interface{}, len(args)) 144 | for index, arg := range args { 145 | formatters[index] = NewFormatter(arg) 146 | } 147 | return formatters 148 | } 149 | --------------------------------------------------------------------------------