diff --git a/go.mod b/go.mod index 1ac64cce..66d78f1e 100644 --- a/go.mod +++ b/go.mod @@ -5,11 +5,11 @@ go 1.20 require ( github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.23 github.com/bitrise-io/go-utils v1.0.12 - github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.20 - github.com/bitrise-io/go-xcode v1.0.19 - github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.45 + github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23 + github.com/bitrise-io/go-xcode v1.1.1 + github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.47 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 - github.com/stretchr/testify v1.8.4 + github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v3 v3.0.1 howett.net/plist v1.0.1 ) @@ -28,9 +28,9 @@ require ( github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/ryanuber/go-glob v1.0.0 // indirect - github.com/stretchr/objx v0.5.1 // indirect + github.com/stretchr/objx v0.5.2 // indirect golang.org/x/crypto v0.16.0 // indirect - golang.org/x/sys v0.20.0 // indirect + golang.org/x/sys v0.22.0 // indirect golang.org/x/term v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect ) diff --git a/go.sum b/go.sum index 058462b5..2b1c023b 100644 --- a/go.sum +++ b/go.sum @@ -9,12 +9,12 @@ github.com/bitrise-io/go-steputils/v2 v2.0.0-alpha.23/go.mod h1:R9HD1kg1Ay4zX+y7 github.com/bitrise-io/go-utils v1.0.1/go.mod h1:ZY1DI+fEpZuFpO9szgDeICM4QbqoWVt0RSY3tRI1heY= github.com/bitrise-io/go-utils v1.0.12 h1:iJV1ZpyvSA0NCte/N6x+aIQ9TrNr5sIBlcJBf0dn1dE= github.com/bitrise-io/go-utils v1.0.12/go.mod h1:ZY1DI+fEpZuFpO9szgDeICM4QbqoWVt0RSY3tRI1heY= -github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.20 h1:R+xJRWsuHhF/Pnx0gjI1+HH4Y0YSFVI+U/CbLpSx4sU= -github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.20/go.mod h1:Laih4ji980SQkRgdnMCH0g4u2GZI/5nnbqmYT9UfKFQ= -github.com/bitrise-io/go-xcode v1.0.19 h1:pbPEIqTHigviG9+1ppMTLv5h6z4k2oz3gKYLKoHJ0yg= -github.com/bitrise-io/go-xcode v1.0.19/go.mod h1:9OwsvrhZ4A2JxHVoEY7CPcABAKA+OE7FQqFfBfvbFuY= -github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.45 h1:/XTNblRyY6aoJlEsfe32czMm5DKWrMjDZcn4NLgBb3Y= -github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.45/go.mod h1:BFDhHF1ftPWpnZt4sjpPQ+H6QaQLkRoNwQZC2/xdcgg= +github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23 h1:Dfh4nyZPuEtilBisidejqxBrkx9cWvbOUrpq8VEION0= +github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23/go.mod h1:3XUplo0dOWc3DqT2XA2SeHToDSg7+j1y1HTHibT2H68= +github.com/bitrise-io/go-xcode v1.1.1 h1:Krfa8iYZZWdLBuH7AXbufFZwL+Pys7etqvd8+Ehdwt8= +github.com/bitrise-io/go-xcode v1.1.1/go.mod h1:9OwsvrhZ4A2JxHVoEY7CPcABAKA+OE7FQqFfBfvbFuY= +github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.47 h1:5lX4comm6w3VAOQnnmbArtYlPNHxuZ/Sdr4VPhR9m40= +github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.47/go.mod h1:KpxSPrRLgY0fscSajOyO/5h7MhapsqnSJr17oXEaPsg= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -55,18 +55,13 @@ github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkB github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/objx v0.5.1 h1:4VhoImhV/Bm0ToFkXFi8hXNXwpDRZ/ynw3amt82mzq0= -github.com/stretchr/objx v0.5.1/go.mod h1:/iHQpkQwBD6DLUmQ4pE+s1TXdob1mORJ4/UFdrifcy0= +github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= golang.org/x/crypto v0.0.0-20211202192323-5770296d904e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= @@ -75,8 +70,8 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y= -golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= +golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= diff --git a/step/step.go b/step/step.go index 71814d6b..688c6f81 100644 --- a/step/step.go +++ b/step/step.go @@ -22,6 +22,7 @@ import ( "github.com/bitrise-io/go-utils/v2/log" "github.com/bitrise-io/go-utils/v2/pathutil" "github.com/bitrise-io/go-xcode/devportalservice" + "github.com/bitrise-io/go-xcode/exportoptions" "github.com/bitrise-io/go-xcode/profileutil" "github.com/bitrise-io/go-xcode/v2/autocodesign/certdownloader" "github.com/bitrise-io/go-xcode/v2/autocodesign/codesignasset" @@ -1001,10 +1002,14 @@ func (s XcodebuildArchiver) xcodeIPAExport(opts xcodeIPAExportOpts) (xcodeIPAExp } archiveCodeSignIsXcodeManaged := opts.Archive.IsXcodeManaged() + signingStyle := exportoptions.SigningStyleManual + if opts.XcodeAuthOptions != nil { + signingStyle = exportoptions.SigningStyleAutomatic + } generator := exportoptionsgenerator.New(xcodeProj, scheme, configuration, s.logger) exportOptions, err := generator.GenerateApplicationExportOptions(exportMethod, opts.ICloudContainerEnvironment, opts.ExportDevelopmentTeam, - opts.UploadBitcode, opts.CompileBitcode, archiveCodeSignIsXcodeManaged, int64(opts.XcodeMajorVersion)) + opts.UploadBitcode, opts.CompileBitcode, archiveCodeSignIsXcodeManaged, signingStyle, int64(opts.XcodeMajorVersion)) if err != nil { return out, err } diff --git a/vendor/github.com/bitrise-io/go-utils/v2/command/command.go b/vendor/github.com/bitrise-io/go-utils/v2/command/command.go index 5672ef69..37b650f4 100644 --- a/vendor/github.com/bitrise-io/go-utils/v2/command/command.go +++ b/vendor/github.com/bitrise-io/go-utils/v2/command/command.go @@ -168,11 +168,14 @@ func printableCommandArgs(isQuoteFirst bool, fullCommandArgs []string) string { func (c command) wrapError(err error) error { var exitErr *exec.ExitError if errors.As(err, &exitErr) { - if c.errorCollector != nil && len(c.errorCollector.errorLines) > 0 { - return fmt.Errorf("command failed with exit status %d (%s): %w", exitErr.ExitCode(), c.PrintableCommandArgs(), errors.New(strings.Join(c.errorCollector.errorLines, "\n"))) + errorLines := []string{} + if c.errorCollector != nil { + errorLines = c.errorCollector.errorLines } - return fmt.Errorf("command failed with exit status %d (%s): %w", exitErr.ExitCode(), c.PrintableCommandArgs(), errors.New("check the command's output for details")) + + return NewExitStatusError(c.PrintableCommandArgs(), exitErr, errorLines) } + return fmt.Errorf("executing command failed (%s): %w", c.PrintableCommandArgs(), err) } diff --git a/vendor/github.com/bitrise-io/go-utils/v2/command/errors.go b/vendor/github.com/bitrise-io/go-utils/v2/command/errors.go new file mode 100644 index 00000000..f88c0f91 --- /dev/null +++ b/vendor/github.com/bitrise-io/go-utils/v2/command/errors.go @@ -0,0 +1,45 @@ +package command + +import ( + "errors" + "fmt" + "os/exec" + "strings" +) + +// ExitStatusError ... +type ExitStatusError struct { + readableReason error + originalExitErr error +} + +// NewExitStatusError ... +func NewExitStatusError(printableCmdArgs string, exitErr *exec.ExitError, errorLines []string) error { + reasonMsg := fmt.Sprintf("command failed with exit status %d (%s)", exitErr.ExitCode(), printableCmdArgs) + if len(errorLines) == 0 { + return &ExitStatusError{ + readableReason: fmt.Errorf("%s: %w", reasonMsg, errors.New("check the command's output for details")), + originalExitErr: exitErr, + } + } + + return &ExitStatusError{ + readableReason: fmt.Errorf("%s: %w", reasonMsg, errors.New(strings.Join(errorLines, "\n"))), + originalExitErr: exitErr, + } +} + +// Error returns the formatted error message. Does not include the original error message (`exit status 1`). +func (e *ExitStatusError) Error() string { + return e.readableReason.Error() +} + +// Unwrap is needed for errors.Is and errors.As to work correctly. +func (e *ExitStatusError) Unwrap() error { + return e.originalExitErr +} + +// Reason returns the user-friendly error, to be used by errorutil.ErrorFormatter. +func (e *ExitStatusError) Reason() error { + return e.readableReason +} diff --git a/vendor/github.com/bitrise-io/go-utils/v2/fileutil/fileutil.go b/vendor/github.com/bitrise-io/go-utils/v2/fileutil/fileutil.go index b2b9ba86..4b2bfa5b 100644 --- a/vendor/github.com/bitrise-io/go-utils/v2/fileutil/fileutil.go +++ b/vendor/github.com/bitrise-io/go-utils/v2/fileutil/fileutil.go @@ -17,6 +17,7 @@ type FileManager interface { RemoveAll(path string) error Write(path string, value string, perm os.FileMode) error WriteBytes(path string, value []byte) error + FileSizeInBytes(pth string) (int64, error) } type fileManager struct { @@ -89,3 +90,16 @@ func (fileManager) ensureSavePath(savePath string) error { func (f fileManager) WriteBytes(path string, value []byte) error { return os.WriteFile(path, value, 0600) } + +// FileSizeInBytes checks if the provided path exists and return with the file size (bytes) using os.Lstat. +func (fileManager) FileSizeInBytes(pth string) (int64, error) { + if pth == "" { + return 0, errors.New("No path provided") + } + fileInf, err := os.Stat(pth) + if err != nil { + return 0, err + } + + return fileInf.Size(), nil +} diff --git a/vendor/github.com/bitrise-io/go-xcode/appleauth/key_helper.go b/vendor/github.com/bitrise-io/go-xcode/appleauth/key_helper.go index 543457a3..9c53b7a6 100644 --- a/vendor/github.com/bitrise-io/go-xcode/appleauth/key_helper.go +++ b/vendor/github.com/bitrise-io/go-xcode/appleauth/key_helper.go @@ -1,9 +1,9 @@ package appleauth import ( - "io/ioutil" "net/http" "net/url" + "os" "path/filepath" "regexp" @@ -24,7 +24,7 @@ func fetchPrivateKey(privateKeyURL string) ([]byte, string, error) { if err != nil { return nil, "", err } - key, err := ioutil.ReadFile(localFile) + key, err := os.ReadFile(localFile) if err != nil { return nil, "", err } diff --git a/vendor/github.com/bitrise-io/go-xcode/certificateutil/filter.go b/vendor/github.com/bitrise-io/go-xcode/certificateutil/filter.go index 24fe025e..5baa1daa 100644 --- a/vendor/github.com/bitrise-io/go-xcode/certificateutil/filter.go +++ b/vendor/github.com/bitrise-io/go-xcode/certificateutil/filter.go @@ -42,7 +42,7 @@ func FilterValidCertificateInfos(certificateInfos []CertificateInfoModel) ValidC } sort.Slice(certs, func(i, j int) bool { - return certs[i].EndDate.Before(certs[j].EndDate) + return certs[i].EndDate.After(certs[j].EndDate) }) validCertificates = append(validCertificates, certs[0]) if len(certs) > 1 { diff --git a/vendor/github.com/bitrise-io/go-xcode/certificateutil/util.go b/vendor/github.com/bitrise-io/go-xcode/certificateutil/util.go index bde99690..50697675 100644 --- a/vendor/github.com/bitrise-io/go-xcode/certificateutil/util.go +++ b/vendor/github.com/bitrise-io/go-xcode/certificateutil/util.go @@ -8,9 +8,9 @@ import ( "regexp" "strings" + "github.com/bitrise-io/go-pkcs12" "github.com/bitrise-io/go-utils/command" "github.com/bitrise-io/go-utils/fileutil" - "github.com/bitrise-io/go-pkcs12" "github.com/pkg/errors" ) diff --git a/vendor/github.com/bitrise-io/go-xcode/devportalservice/devportalservice.go b/vendor/github.com/bitrise-io/go-xcode/devportalservice/devportalservice.go index ccab44af..efcf6f7c 100644 --- a/vendor/github.com/bitrise-io/go-xcode/devportalservice/devportalservice.go +++ b/vendor/github.com/bitrise-io/go-xcode/devportalservice/devportalservice.go @@ -4,7 +4,7 @@ import ( "bytes" "encoding/json" "fmt" - "io/ioutil" + "io" "net/http" "os" "regexp" @@ -126,7 +126,7 @@ func (c *BitriseClient) download() ([]byte, error) { } }() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return nil, fmt.Errorf("failed to read response body: %s", err) } diff --git a/vendor/github.com/bitrise-io/go-xcode/exportoptions/appstore_options.go b/vendor/github.com/bitrise-io/go-xcode/exportoptions/appstore_options.go index 3ed5816d..187dbbf7 100644 --- a/vendor/github.com/bitrise-io/go-xcode/exportoptions/appstore_options.go +++ b/vendor/github.com/bitrise-io/go-xcode/exportoptions/appstore_options.go @@ -12,7 +12,8 @@ type AppStoreOptionsModel struct { BundleIDProvisioningProfileMapping map[string]string SigningCertificate string InstallerSigningCertificate string - SigningStyle string + SigningStyle SigningStyle + Destination Destination ICloudContainerEnvironment ICloudContainerEnvironment DistributionBundleIdentifier string @@ -39,12 +40,15 @@ func (options AppStoreOptionsModel) Hash() map[string]interface{} { if options.TeamID != "" { hash[TeamIDKey] = options.TeamID } + //nolint:gosimple if options.UploadBitcode != UploadBitcodeDefault { hash[UploadBitcodeKey] = options.UploadBitcode } + //nolint:gosimple if options.UploadSymbols != UploadSymbolsDefault { hash[UploadSymbolsKey] = options.UploadSymbols } + //nolint:gosimple if options.ManageAppVersion != manageAppVersionDefault { hash[manageAppVersionKey] = options.ManageAppVersion } @@ -66,6 +70,9 @@ func (options AppStoreOptionsModel) Hash() map[string]interface{} { if options.SigningStyle != "" { hash[SigningStyleKey] = options.SigningStyle } + if options.Destination != "" { + hash[DestinationKey] = options.Destination + } return hash } diff --git a/vendor/github.com/bitrise-io/go-xcode/exportoptions/non_appstore_options.go b/vendor/github.com/bitrise-io/go-xcode/exportoptions/non_appstore_options.go index ebee1357..5a2a03e5 100644 --- a/vendor/github.com/bitrise-io/go-xcode/exportoptions/non_appstore_options.go +++ b/vendor/github.com/bitrise-io/go-xcode/exportoptions/non_appstore_options.go @@ -12,7 +12,8 @@ type NonAppStoreOptionsModel struct { TeamID string BundleIDProvisioningProfileMapping map[string]string SigningCertificate string - SigningStyle string + SigningStyle SigningStyle + Destination Destination ICloudContainerEnvironment ICloudContainerEnvironment DistributionBundleIdentifier string @@ -43,9 +44,11 @@ func (options NonAppStoreOptionsModel) Hash() map[string]interface{} { if options.TeamID != "" { hash[TeamIDKey] = options.TeamID } + //nolint:gosimple if options.CompileBitcode != CompileBitcodeDefault { hash[CompileBitcodeKey] = options.CompileBitcode } + //nolint:gosimple if options.EmbedOnDemandResourcesAssetPacksInBundle != EmbedOnDemandResourcesAssetPacksInBundleDefault { hash[EmbedOnDemandResourcesAssetPacksInBundleKey] = options.EmbedOnDemandResourcesAssetPacksInBundle } @@ -73,6 +76,9 @@ func (options NonAppStoreOptionsModel) Hash() map[string]interface{} { if options.SigningStyle != "" { hash[SigningStyleKey] = options.SigningStyle } + if options.Destination != "" { + hash[DestinationKey] = options.Destination + } return hash } diff --git a/vendor/github.com/bitrise-io/go-xcode/exportoptions/properties.go b/vendor/github.com/bitrise-io/go-xcode/exportoptions/properties.go index bb2e94c1..66069d7f 100644 --- a/vendor/github.com/bitrise-io/go-xcode/exportoptions/properties.go +++ b/vendor/github.com/bitrise-io/go-xcode/exportoptions/properties.go @@ -17,6 +17,9 @@ const EmbedOnDemandResourcesAssetPacksInBundleDefault = true // ICloudContainerEnvironmentKey ... const ICloudContainerEnvironmentKey = "iCloudContainerEnvironment" +// ICloudContainerEnvironment ... +type ICloudContainerEnvironment string + const ( // ICloudContainerEnvironmentDevelopment ... ICloudContainerEnvironmentDevelopment ICloudContainerEnvironment = "Development" @@ -24,9 +27,6 @@ const ( ICloudContainerEnvironmentProduction ICloudContainerEnvironment = "Production" ) -// ICloudContainerEnvironment ... -type ICloudContainerEnvironment string - // DistributionBundleIdentifier ... const DistributionBundleIdentifier = "distributionBundleIdentifier" @@ -79,6 +79,9 @@ func (manifest Manifest) ToHash() map[string]string { // MethodKey ... const MethodKey = "method" +// Method ... +type Method string + const ( // MethodAppStore ... MethodAppStore Method = "app-store" @@ -96,9 +99,6 @@ const ( MethodDefault Method = MethodDevelopment ) -// Method ... -type Method string - // ParseMethod ... func ParseMethod(method string) (Method, error) { switch method { @@ -165,3 +165,22 @@ const InstallerSigningCertificateKey = "installerSigningCertificate" // SigningStyleKey ... const SigningStyleKey = "signingStyle" + +// SigningStyle ... +type SigningStyle string + +// SigningStyle ... +const ( + SigningStyleManual SigningStyle = "manual" + SigningStyleAutomatic SigningStyle = "automatic" +) + +const DestinationKey = "destination" + +type Destination string + +// Destination ... +const ( + DestinationExport Destination = "export" + DestinationDefault Destination = DestinationExport +) diff --git a/vendor/github.com/bitrise-io/go-xcode/plistutil/plistutil_test_file_content.go b/vendor/github.com/bitrise-io/go-xcode/plistutil/plistutil_test_file_content.go index 17f15038..ae6d45a5 100644 --- a/vendor/github.com/bitrise-io/go-xcode/plistutil/plistutil_test_file_content.go +++ b/vendor/github.com/bitrise-io/go-xcode/plistutil/plistutil_test_file_content.go @@ -186,61 +186,6 @@ const appStoreProfileContent = ` 1 ` -const adHocProfileContent = ` - - - - AppIDName - Bitrise Test - ApplicationIdentifierPrefix - - 9NS4 - - CreationDate - 2016-09-22T11:29:38Z - Platform - - iOS - - DeveloperCertificates - - - - Entitlements - - keychain-access-groups - - 9NS4.* - - get-task-allow - - application-identifier - 9NS4.* - com.apple.developer.team-identifier - 9NS4 - - ExpirationDate - 2017-09-21T13:20:06Z - Name - Bitrise Test Ad Hoc - ProvisionedDevices - - b138 - - TeamIdentifier - - 9NS4 - - TeamName - Some Dude - TimeToLive - 364 - UUID - 26668300 - Version - 1 -` - const enterpriseProfileContent = ` diff --git a/vendor/github.com/bitrise-io/go-xcode/profileutil/plist_data.go b/vendor/github.com/bitrise-io/go-xcode/profileutil/plist_data.go index 4a4c5d19..de9dafe1 100644 --- a/vendor/github.com/bitrise-io/go-xcode/profileutil/plist_data.go +++ b/vendor/github.com/bitrise-io/go-xcode/profileutil/plist_data.go @@ -9,10 +9,6 @@ import ( "howett.net/plist" ) -const ( - notValidParameterErrorMessage = "security: SecPolicySetValue: One or more parameters passed to a function were not valid." -) - // PlistData ... type PlistData plistutil.PlistData diff --git a/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/certificates.go b/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/certificates.go new file mode 100644 index 00000000..d916ce54 --- /dev/null +++ b/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/certificates.go @@ -0,0 +1,21 @@ +package exportoptionsgenerator + +import "github.com/bitrise-io/go-xcode/certificateutil" + +// CodesignIdentityProvider can list certificate infos. +type CodesignIdentityProvider interface { + ListCodesignIdentities() ([]certificateutil.CertificateInfoModel, error) +} + +// LocalCodesignIdentityProvider ... +type LocalCodesignIdentityProvider struct{} + +// ListCodesignIdentities ... +func (p LocalCodesignIdentityProvider) ListCodesignIdentities() ([]certificateutil.CertificateInfoModel, error) { + certs, err := certificateutil.InstalledCodesigningCertificateInfos() + if err != nil { + return nil, err + } + certInfo := certificateutil.FilterValidCertificateInfos(certs) + return append(certInfo.ValidCertificates, certInfo.DuplicatedCertificates...), nil +} diff --git a/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/exportoptionsgenerator.go b/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/exportoptionsgenerator.go index 108d3e57..28d2c652 100644 --- a/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/exportoptionsgenerator.go +++ b/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/exportoptionsgenerator.go @@ -2,15 +2,10 @@ package exportoptionsgenerator import ( "fmt" - "io" - "net/http" "os" - "path/filepath" - "github.com/bitrise-io/go-utils/pathutil" "github.com/bitrise-io/go-utils/sliceutil" "github.com/bitrise-io/go-utils/v2/log" - "github.com/bitrise-io/go-xcode/certificateutil" "github.com/bitrise-io/go-xcode/export" "github.com/bitrise-io/go-xcode/exportoptions" "github.com/bitrise-io/go-xcode/plistutil" @@ -20,10 +15,9 @@ import ( "github.com/bitrise-io/go-xcode/xcodeproject/xcscheme" ) -// const for AppClipProductType and manualSigningStyle const ( + // AppClipProductType ... AppClipProductType = "com.apple.product-type.application.on-demand-install-capable" - manualSigningStyle = "manual" ) // ExportOptionsGenerator generates an exportOptions.plist file. @@ -53,14 +47,57 @@ func New(xcodeProj *xcodeproj.XcodeProj, scheme *xcscheme.Scheme, configuration } // GenerateApplicationExportOptions generates exportOptions for an application export. -func (g ExportOptionsGenerator) GenerateApplicationExportOptions(exportMethod exportoptions.Method, containerEnvironment string, teamID string, uploadBitcode bool, compileBitcode bool, xcodeManaged bool, - xcodeMajorVersion int64) (exportoptions.ExportOptions, error) { +func (g ExportOptionsGenerator) GenerateApplicationExportOptions( + exportMethod exportoptions.Method, + containerEnvironment string, + teamID string, + uploadBitcode bool, + compileBitcode bool, + archivedWithXcodeManagedProfiles bool, + codeSigningStyle exportoptions.SigningStyle, + xcodeMajorVersion int64, +) (exportoptions.ExportOptions, error) { + mainTargetBundleID, entitlementsByBundleID, err := g.applicationTargetsAndEntitlements(exportMethod) + if err != nil { + return nil, err + } + + iCloudContainerEnvironment, err := determineIcloudContainerEnvironment(containerEnvironment, entitlementsByBundleID, exportMethod, xcodeMajorVersion) + if err != nil { + return nil, err + } + + exportOpts := generateBaseExportOptions(exportMethod, uploadBitcode, compileBitcode, iCloudContainerEnvironment) + + if xcodeMajorVersion >= 12 { + exportOpts = addDistributionBundleIdentifierFromXcode12(exportOpts, mainTargetBundleID) + } + + if xcodeMajorVersion >= 13 { + exportOpts = disableManagedBuildNumberFromXcode13(exportOpts) + } - g.logger.TDebugf("Generating application export options for: %s", exportMethod) + if codeSigningStyle == exportoptions.SigningStyleAutomatic { + exportOpts = addTeamID(exportOpts, teamID) + } else { + codeSignGroup, err := g.determineCodesignGroup(entitlementsByBundleID, exportMethod, teamID, archivedWithXcodeManagedProfiles) + if err != nil { + return nil, err + } + if codeSignGroup == nil { + return exportOpts, nil + } + + exportOpts = addManualSigningFields(exportOpts, codeSignGroup, archivedWithXcodeManagedProfiles, g.logger) + } + + return exportOpts, nil +} +func (g ExportOptionsGenerator) applicationTargetsAndEntitlements(exportMethod exportoptions.Method) (string, map[string]plistutil.PlistData, error) { mainTarget, err := ArchivableApplicationTarget(g.xcodeProj, g.scheme) if err != nil { - return nil, err + return "", nil, err } dependentTargets := filterApplicationBundleTargets( @@ -74,12 +111,12 @@ func (g ExportOptionsGenerator) GenerateApplicationExportOptions(exportMethod ex for i, target := range targets { bundleID, err := g.targetInfoProvider.TargetBundleID(target.Name, g.configuration) if err != nil { - return nil, fmt.Errorf("failed to get target (%s) bundle id: %s", target.Name, err) + return "", nil, fmt.Errorf("failed to get target (%s) bundle id: %s", target.Name, err) } entitlements, err := g.targetInfoProvider.TargetCodeSignEntitlements(target.Name, g.configuration) if err != nil && !serialized.IsKeyNotFoundError(err) { - return nil, fmt.Errorf("failed to get target (%s) bundle id: %s", target.Name, err) + return "", nil, fmt.Errorf("failed to get target (%s) bundle id: %s", target.Name, err) } entitlementsByBundleID[bundleID] = plistutil.PlistData(entitlements) @@ -89,177 +126,7 @@ func (g ExportOptionsGenerator) GenerateApplicationExportOptions(exportMethod ex } } - g.logger.TDebugf("Generated application export options plist for: %s", exportMethod) - - return g.generateExportOptions(exportMethod, containerEnvironment, teamID, uploadBitcode, compileBitcode, - xcodeManaged, entitlementsByBundleID, xcodeMajorVersion, mainTargetBundleID) -} - -// TargetInfoProvider can determine a target's bundle id and codesign entitlements. -type TargetInfoProvider interface { - TargetBundleID(target, configuration string) (string, error) - TargetCodeSignEntitlements(target, configuration string) (serialized.Object, error) -} - -// XcodebuildTargetInfoProvider implements TargetInfoProvider. -type XcodebuildTargetInfoProvider struct { - xcodeProj *xcodeproj.XcodeProj -} - -// TargetBundleID ... -func (b XcodebuildTargetInfoProvider) TargetBundleID(target, configuration string) (string, error) { - return b.xcodeProj.TargetBundleID(target, configuration) -} - -// TargetCodeSignEntitlements ... -func (b XcodebuildTargetInfoProvider) TargetCodeSignEntitlements(target, configuration string) (serialized.Object, error) { - return b.xcodeProj.TargetCodeSignEntitlements(target, configuration) -} - -// ArchivableApplicationTarget locate archivable app target from a given project and scheme -func ArchivableApplicationTarget(xcodeProj *xcodeproj.XcodeProj, scheme *xcscheme.Scheme) (*xcodeproj.Target, error) { - archiveEntry, ok := scheme.AppBuildActionEntry() - if !ok { - return nil, fmt.Errorf("archivable entry not found in project: %s for scheme: %s", xcodeProj.Path, scheme.Name) - } - - mainTarget, ok := xcodeProj.Proj.Target(archiveEntry.BuildableReference.BlueprintIdentifier) - if !ok { - return nil, fmt.Errorf("target not found: %s", archiveEntry.BuildableReference.BlueprintIdentifier) - } - - return &mainTarget, nil -} - -func filterApplicationBundleTargets(targets []xcodeproj.Target, exportMethod exportoptions.Method) (filteredTargets []xcodeproj.Target) { - fmt.Printf("Filtering %v application bundle targets", len(targets)) - - for _, target := range targets { - if !target.IsExecutableProduct() { - continue - } - - // App store exports contain App Clip too. App Clip provisioning profile has to be included in export options: - // .. - // provisioningProfiles - // - // io.bundle.id - // Development Application Profile - // io.bundle.id.AppClipID - // Development App Clip Profile - // - // .., - if exportMethod != exportoptions.MethodAppStore && target.IsAppClipProduct() { - continue - } - - filteredTargets = append(filteredTargets, target) - } - - fmt.Printf("Found %v application bundle targets", len(filteredTargets)) - - return -} - -// projectUsesCloudKit determines whether the project uses any CloudKit capability or not. -func projectUsesCloudKit(bundleIDEntitlementsMap map[string]plistutil.PlistData) bool { - fmt.Printf("Checking if project uses CloudKit") - - for _, entitlements := range bundleIDEntitlementsMap { - if entitlements == nil { - continue - } - - services, ok := entitlements.GetStringArray("com.apple.developer.icloud-services") - if !ok { - continue - } - - if sliceutil.IsStringInSlice("CloudKit", services) || sliceutil.IsStringInSlice("CloudDocuments", services) { - fmt.Printf("Project uses CloudKit") - - return true - } - } - return false -} - -// determineIcloudContainerEnvironment calculates the value of iCloudContainerEnvironment. -func determineIcloudContainerEnvironment(desiredIcloudContainerEnvironment string, bundleIDEntitlementsMap map[string]plistutil.PlistData, exportMethod exportoptions.Method, xcodeMajorVersion int64) (string, error) { - // iCloudContainerEnvironment: If the app is using CloudKit, this configures the "com.apple.developer.icloud-container-environment" entitlement. - // Available options vary depending on the type of provisioning profile used, but may include: Development and Production. - usesCloudKit := projectUsesCloudKit(bundleIDEntitlementsMap) - if !usesCloudKit { - return "", nil - } - - // From Xcode 9 iCloudContainerEnvironment is required for every export method, before that version only for non app-store exports. - if xcodeMajorVersion < 9 && exportMethod == exportoptions.MethodAppStore { - return "", nil - } - - if exportMethod == exportoptions.MethodAppStore { - return "Production", nil - } - - if desiredIcloudContainerEnvironment == "" { - return "", fmt.Errorf("Your project uses CloudKit but \"iCloud container environment\" input not specified.\n"+ - "Export method is: %s (For app-store export method Production container environment is implied.)", exportMethod) - } - - return desiredIcloudContainerEnvironment, nil -} - -// generateBaseExportOptions creates a default exportOptions introudced in Xcode 7. -func generateBaseExportOptions(exportMethod exportoptions.Method, cfgUploadBitcode, cfgCompileBitcode bool, iCloudContainerEnvironment string) exportoptions.ExportOptions { - if exportMethod == exportoptions.MethodAppStore { - appStoreOptions := exportoptions.NewAppStoreOptions() - appStoreOptions.UploadBitcode = cfgUploadBitcode - if iCloudContainerEnvironment != "" { - appStoreOptions.ICloudContainerEnvironment = exportoptions.ICloudContainerEnvironment(iCloudContainerEnvironment) - } - return appStoreOptions - } - - nonAppStoreOptions := exportoptions.NewNonAppStoreOptions(exportMethod) - nonAppStoreOptions.CompileBitcode = cfgCompileBitcode - - if iCloudContainerEnvironment != "" { - nonAppStoreOptions.ICloudContainerEnvironment = exportoptions.ICloudContainerEnvironment(iCloudContainerEnvironment) - } - - return nonAppStoreOptions -} - -// CodesignIdentityProvider can list certificate infos. -type CodesignIdentityProvider interface { - ListCodesignIdentities() ([]certificateutil.CertificateInfoModel, error) -} - -// LocalCodesignIdentityProvider ... -type LocalCodesignIdentityProvider struct{} - -// ListCodesignIdentities ... -func (p LocalCodesignIdentityProvider) ListCodesignIdentities() ([]certificateutil.CertificateInfoModel, error) { - certs, err := certificateutil.InstalledCodesigningCertificateInfos() - if err != nil { - return nil, err - } - certInfo := certificateutil.FilterValidCertificateInfos(certs) - return append(certInfo.ValidCertificates, certInfo.DuplicatedCertificates...), nil -} - -// ProvisioningProfileProvider can list profile infos. -type ProvisioningProfileProvider interface { - ListProvisioningProfiles() ([]profileutil.ProvisioningProfileInfoModel, error) -} - -// LocalProvisioningProfileProvider ... -type LocalProvisioningProfileProvider struct{} - -// ListProvisioningProfiles ... -func (p LocalProvisioningProfileProvider) ListProvisioningProfiles() ([]profileutil.ProvisioningProfileInfoModel, error) { - return profileutil.InstalledProvisioningProfileInfos(profileutil.ProfileTypeIos) + return mainTargetBundleID, entitlementsByBundleID, nil } // determineCodesignGroup finds the best codesign group (certificate + profiles) @@ -283,7 +150,7 @@ func (g ExportOptionsGenerator) determineCodesignGroup(bundleIDEntitlementsMap m certs, err := g.certificateProvider.ListCodesignIdentities() if err != nil { - return nil, fmt.Errorf("Failed to get installed certificates, error: %s", err) + return nil, fmt.Errorf("failed to get installed certificates: %w", err) } g.logger.Debugf("Installed certificates:") @@ -293,7 +160,7 @@ func (g ExportOptionsGenerator) determineCodesignGroup(bundleIDEntitlementsMap m profs, err := g.profileProvider.ListProvisioningProfiles() if err != nil { - return nil, fmt.Errorf("Failed to get installed provisioning profiles, error: %s", err) + return nil, fmt.Errorf("failed to get installed provisioning profiles: %w", err) } g.logger.Debugf("Installed profiles:") @@ -358,7 +225,7 @@ func (g ExportOptionsGenerator) determineCodesignGroup(bundleIDEntitlementsMap m defaultProfileURL := os.Getenv("BITRISE_DEFAULT_PROVISION_URL") if teamID == "" && defaultProfileURL != "" { - if defaultProfile, err := g.GetDefaultProvisioningProfile(); err == nil { + if defaultProfile, err := g.profileProvider.GetDefaultProvisioningProfile(); err == nil { g.logger.Debugf("\ndefault profile: %v\n", defaultProfile) filteredCodeSignGroups := export.FilterSelectableCodeSignGroups(codeSignGroups, export.CreateExcludeProfileNameSelectableCodeSignGroupFilter(defaultProfile.Name)) @@ -408,6 +275,76 @@ func (g ExportOptionsGenerator) determineCodesignGroup(bundleIDEntitlementsMap m return &iosCodeSignGroups[0], nil } +// determineIcloudContainerEnvironment calculates the value of iCloudContainerEnvironment. +func determineIcloudContainerEnvironment(desiredIcloudContainerEnvironment string, bundleIDEntitlementsMap map[string]plistutil.PlistData, exportMethod exportoptions.Method, xcodeMajorVersion int64) (string, error) { + // iCloudContainerEnvironment: If the app is using CloudKit, this configures the "com.apple.developer.icloud-container-environment" entitlement. + // Available options vary depending on the type of provisioning profile used, but may include: Development and Production. + usesCloudKit := projectUsesCloudKit(bundleIDEntitlementsMap) + if !usesCloudKit { + return "", nil + } + + // From Xcode 9 iCloudContainerEnvironment is required for every export method, before that version only for non app-store exports. + if xcodeMajorVersion < 9 && exportMethod == exportoptions.MethodAppStore { + return "", nil + } + + if exportMethod == exportoptions.MethodAppStore { + return "Production", nil + } + + if desiredIcloudContainerEnvironment == "" { + return "", fmt.Errorf("Your project uses CloudKit but \"iCloud container environment\" input not specified.\n"+ + "Export method is: %s (For app-store export method Production container environment is implied.)", exportMethod) + } + + return desiredIcloudContainerEnvironment, nil +} + +// projectUsesCloudKit determines whether the project uses any CloudKit capability or not. +func projectUsesCloudKit(bundleIDEntitlementsMap map[string]plistutil.PlistData) bool { + fmt.Printf("Checking if project uses CloudKit") + + for _, entitlements := range bundleIDEntitlementsMap { + if entitlements == nil { + continue + } + + services, ok := entitlements.GetStringArray("com.apple.developer.icloud-services") + if !ok { + continue + } + + if sliceutil.IsStringInSlice("CloudKit", services) || sliceutil.IsStringInSlice("CloudDocuments", services) { + fmt.Printf("Project uses CloudKit") + + return true + } + } + return false +} + +// generateBaseExportOptions creates a default exportOptions introduced in Xcode 7. +func generateBaseExportOptions(exportMethod exportoptions.Method, cfgUploadBitcode, cfgCompileBitcode bool, iCloudContainerEnvironment string) exportoptions.ExportOptions { + if exportMethod == exportoptions.MethodAppStore { + appStoreOptions := exportoptions.NewAppStoreOptions() + appStoreOptions.UploadBitcode = cfgUploadBitcode + if iCloudContainerEnvironment != "" { + appStoreOptions.ICloudContainerEnvironment = exportoptions.ICloudContainerEnvironment(iCloudContainerEnvironment) + } + return appStoreOptions + } + + nonAppStoreOptions := exportoptions.NewNonAppStoreOptions(exportMethod) + nonAppStoreOptions.CompileBitcode = cfgCompileBitcode + + if iCloudContainerEnvironment != "" { + nonAppStoreOptions.ICloudContainerEnvironment = exportoptions.ICloudContainerEnvironment(iCloudContainerEnvironment) + } + + return nonAppStoreOptions +} + func addDistributionBundleIdentifierFromXcode12(exportOpts exportoptions.ExportOptions, distributionBundleIdentifier string) exportoptions.ExportOptions { switch options := exportOpts.(type) { case exportoptions.AppStoreOptionsModel: @@ -432,66 +369,47 @@ func disableManagedBuildNumberFromXcode13(exportOpts exportoptions.ExportOptions return exportOpts } -// generateExportOptions generates an exportOptions based on the provided conditions. -func (g ExportOptionsGenerator) generateExportOptions(exportMethod exportoptions.Method, containerEnvironment string, teamID string, uploadBitcode bool, compileBitcode bool, xcodeManaged bool, - bundleIDEntitlementsMap map[string]plistutil.PlistData, xcodeMajorVersion int64, distributionBundleIdentifier string) (exportoptions.ExportOptions, error) { - g.logger.TDebugf("Generating export options") - - iCloudContainerEnvironment, err := determineIcloudContainerEnvironment(containerEnvironment, bundleIDEntitlementsMap, exportMethod, xcodeMajorVersion) - if err != nil { - return nil, err - } - - g.logger.Printf("Adding bundle id") - - exportOpts := generateBaseExportOptions(exportMethod, uploadBitcode, compileBitcode, iCloudContainerEnvironment) - if xcodeMajorVersion >= 12 { - exportOpts = addDistributionBundleIdentifierFromXcode12(exportOpts, distributionBundleIdentifier) - } - if xcodeMajorVersion >= 13 { - exportOpts = disableManagedBuildNumberFromXcode13(exportOpts) - } - - g.logger.TDebugf("Determining code signing group") - - codeSignGroup, err := g.determineCodesignGroup(bundleIDEntitlementsMap, exportMethod, teamID, xcodeManaged) - if err != nil { - return nil, err - } - if codeSignGroup == nil { - return exportOpts, nil +func addTeamID(exportOpts exportoptions.ExportOptions, teamID string) exportoptions.ExportOptions { + switch options := exportOpts.(type) { + case exportoptions.AppStoreOptionsModel: + options.TeamID = teamID + return options + case exportoptions.NonAppStoreOptionsModel: + options.TeamID = teamID + return options } + return exportOpts +} +func addManualSigningFields(exportOpts exportoptions.ExportOptions, codeSignGroup *export.IosCodeSignGroup, archivedWithXcodeManagedProfiles bool, logger log.Logger) exportoptions.ExportOptions { exportCodeSignStyle := "" exportProfileMapping := map[string]string{} - g.logger.TDebugf("Determining code signing style") - for bundleID, profileInfo := range codeSignGroup.BundleIDProfileMap() { exportProfileMapping[bundleID] = profileInfo.Name isXcodeManaged := profileutil.IsXcodeManaged(profileInfo.Name) if isXcodeManaged { if exportCodeSignStyle != "" && exportCodeSignStyle != "automatic" { - g.logger.Errorf("Both Xcode managed and NON Xcode managed profiles in code signing group") + logger.Errorf("Both Xcode managed and NON Xcode managed profiles in code signing group") } exportCodeSignStyle = "automatic" } else { - if exportCodeSignStyle != "" && exportCodeSignStyle != manualSigningStyle { - g.logger.Errorf("Both Xcode managed and NON Xcode managed profiles in code signing group") + if exportCodeSignStyle != "" && exportCodeSignStyle != string(exportoptions.SigningStyleManual) { + logger.Errorf("Both Xcode managed and NON Xcode managed profiles in code signing group") } - exportCodeSignStyle = manualSigningStyle + exportCodeSignStyle = string(exportoptions.SigningStyleManual) } } - shouldSetManualSigning := xcodeManaged && exportCodeSignStyle == manualSigningStyle + shouldSetManualSigning := archivedWithXcodeManagedProfiles && exportCodeSignStyle == string(exportoptions.SigningStyleManual) if shouldSetManualSigning { - g.logger.Warnf("App was signed with Xcode managed profile when archiving,") - g.logger.Warnf("ipa export uses manual code signing.") - g.logger.Warnf(`Setting "signingStyle" to "manual".`) + logger.Warnf("App was signed with Xcode managed profile when archiving,") + logger.Warnf("ipa export uses manual code signing.") + logger.Warnf(`Setting "signingStyle" to "manual".`) } - g.logger.TDebugf("Determined code signing style") + logger.TDebugf("Determined code signing style") switch options := exportOpts.(type) { case exportoptions.AppStoreOptionsModel: @@ -500,7 +418,7 @@ func (g ExportOptionsGenerator) generateExportOptions(exportMethod exportoptions options.TeamID = codeSignGroup.Certificate().TeamID if shouldSetManualSigning { - options.SigningStyle = manualSigningStyle + options.SigningStyle = exportoptions.SigningStyleManual } exportOpts = options case exportoptions.NonAppStoreOptionsModel: @@ -509,55 +427,10 @@ func (g ExportOptionsGenerator) generateExportOptions(exportMethod exportoptions options.TeamID = codeSignGroup.Certificate().TeamID if shouldSetManualSigning { - options.SigningStyle = manualSigningStyle + options.SigningStyle = exportoptions.SigningStyleManual } exportOpts = options } - return exportOpts, nil -} - -// GetDefaultProvisioningProfile ... -func (g ExportOptionsGenerator) GetDefaultProvisioningProfile() (profileutil.ProvisioningProfileInfoModel, error) { - defaultProfileURL := os.Getenv("BITRISE_DEFAULT_PROVISION_URL") - if defaultProfileURL == "" { - return profileutil.ProvisioningProfileInfoModel{}, nil - } - - tmpDir, err := pathutil.NormalizedOSTempDirPath("tmp_default_profile") - if err != nil { - return profileutil.ProvisioningProfileInfoModel{}, err - } - - tmpDst := filepath.Join(tmpDir, "default.mobileprovision") - tmpDstFile, err := os.Create(tmpDst) - if err != nil { - return profileutil.ProvisioningProfileInfoModel{}, err - } - defer func() { - if err := tmpDstFile.Close(); err != nil { - g.logger.Errorf("Failed to close file (%s), error: %s", tmpDst, err) - } - }() - - response, err := http.Get(defaultProfileURL) - if err != nil { - return profileutil.ProvisioningProfileInfoModel{}, err - } - defer func() { - if err := response.Body.Close(); err != nil { - g.logger.Errorf("Failed to close response body, error: %s", err) - } - }() - - if _, err := io.Copy(tmpDstFile, response.Body); err != nil { - return profileutil.ProvisioningProfileInfoModel{}, err - } - - defaultProfile, err := profileutil.NewProvisioningProfileInfoFromFile(tmpDst) - if err != nil { - return profileutil.ProvisioningProfileInfoModel{}, err - } - - return defaultProfile, nil + return exportOpts } diff --git a/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/profiles.go b/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/profiles.go new file mode 100644 index 00000000..e9b3928e --- /dev/null +++ b/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/profiles.go @@ -0,0 +1,73 @@ +package exportoptionsgenerator + +import ( + "io" + "net/http" + "os" + "path/filepath" + + "github.com/bitrise-io/go-utils/pathutil" + "github.com/bitrise-io/go-utils/v2/log" + "github.com/bitrise-io/go-xcode/profileutil" +) + +// ProvisioningProfileProvider can list profile infos. +type ProvisioningProfileProvider interface { + ListProvisioningProfiles() ([]profileutil.ProvisioningProfileInfoModel, error) + GetDefaultProvisioningProfile() (profileutil.ProvisioningProfileInfoModel, error) +} + +// LocalProvisioningProfileProvider ... +type LocalProvisioningProfileProvider struct { + logger log.Logger +} + +// ListProvisioningProfiles ... +func (p LocalProvisioningProfileProvider) ListProvisioningProfiles() ([]profileutil.ProvisioningProfileInfoModel, error) { + return profileutil.InstalledProvisioningProfileInfos(profileutil.ProfileTypeIos) +} + +// GetDefaultProvisioningProfile ... +func (p LocalProvisioningProfileProvider) GetDefaultProvisioningProfile() (profileutil.ProvisioningProfileInfoModel, error) { + defaultProfileURL := os.Getenv("BITRISE_DEFAULT_PROVISION_URL") + if defaultProfileURL == "" { + return profileutil.ProvisioningProfileInfoModel{}, nil + } + + tmpDir, err := pathutil.NormalizedOSTempDirPath("tmp_default_profile") + if err != nil { + return profileutil.ProvisioningProfileInfoModel{}, err + } + + tmpDst := filepath.Join(tmpDir, "default.mobileprovision") + tmpDstFile, err := os.Create(tmpDst) + if err != nil { + return profileutil.ProvisioningProfileInfoModel{}, err + } + defer func() { + if err := tmpDstFile.Close(); err != nil { + p.logger.Warnf("Failed to close file (%s), error: %s", tmpDst, err) + } + }() + + response, err := http.Get(defaultProfileURL) + if err != nil { + return profileutil.ProvisioningProfileInfoModel{}, err + } + defer func() { + if err := response.Body.Close(); err != nil { + p.logger.Warnf("Failed to close response body, error: %s", err) + } + }() + + if _, err := io.Copy(tmpDstFile, response.Body); err != nil { + return profileutil.ProvisioningProfileInfoModel{}, err + } + + defaultProfile, err := profileutil.NewProvisioningProfileInfoFromFile(tmpDst) + if err != nil { + return profileutil.ProvisioningProfileInfoModel{}, err + } + + return defaultProfile, nil +} diff --git a/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/targets.go b/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/targets.go new file mode 100644 index 00000000..fa2d9042 --- /dev/null +++ b/vendor/github.com/bitrise-io/go-xcode/v2/exportoptionsgenerator/targets.go @@ -0,0 +1,75 @@ +package exportoptionsgenerator + +import ( + "fmt" + "github.com/bitrise-io/go-xcode/exportoptions" + "github.com/bitrise-io/go-xcode/xcodeproject/serialized" + "github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj" + "github.com/bitrise-io/go-xcode/xcodeproject/xcscheme" +) + +// TargetInfoProvider can determine a target's bundle id and codesign entitlements. +type TargetInfoProvider interface { + TargetBundleID(target, configuration string) (string, error) + TargetCodeSignEntitlements(target, configuration string) (serialized.Object, error) +} + +// XcodebuildTargetInfoProvider implements TargetInfoProvider. +type XcodebuildTargetInfoProvider struct { + xcodeProj *xcodeproj.XcodeProj +} + +// TargetBundleID ... +func (b XcodebuildTargetInfoProvider) TargetBundleID(target, configuration string) (string, error) { + return b.xcodeProj.TargetBundleID(target, configuration) +} + +// TargetCodeSignEntitlements ... +func (b XcodebuildTargetInfoProvider) TargetCodeSignEntitlements(target, configuration string) (serialized.Object, error) { + return b.xcodeProj.TargetCodeSignEntitlements(target, configuration) +} + +// ArchivableApplicationTarget locate archivable app target from a given project and scheme +func ArchivableApplicationTarget(xcodeProj *xcodeproj.XcodeProj, scheme *xcscheme.Scheme) (*xcodeproj.Target, error) { + archiveEntry, ok := scheme.AppBuildActionEntry() + if !ok { + return nil, fmt.Errorf("archivable entry not found in project: %s for scheme: %s", xcodeProj.Path, scheme.Name) + } + + mainTarget, ok := xcodeProj.Proj.Target(archiveEntry.BuildableReference.BlueprintIdentifier) + if !ok { + return nil, fmt.Errorf("target not found: %s", archiveEntry.BuildableReference.BlueprintIdentifier) + } + + return &mainTarget, nil +} + +func filterApplicationBundleTargets(targets []xcodeproj.Target, exportMethod exportoptions.Method) (filteredTargets []xcodeproj.Target) { + fmt.Printf("Filtering %v application bundle targets", len(targets)) + + for _, target := range targets { + if !target.IsExecutableProduct() { + continue + } + + // App store exports contain App Clip too. App Clip provisioning profile has to be included in export options: + // .. + // provisioningProfiles + // + // io.bundle.id + // Development Application Profile + // io.bundle.id.AppClipID + // Development App Clip Profile + // + // .., + if exportMethod != exportoptions.MethodAppStore && target.IsAppClipProduct() { + continue + } + + filteredTargets = append(filteredTargets, target) + } + + fmt.Printf("Found %v application bundle targets", len(filteredTargets)) + + return +} diff --git a/vendor/github.com/bitrise-io/go-xcode/xcarchive/ios.go b/vendor/github.com/bitrise-io/go-xcode/xcarchive/ios.go index e9787037..4c98987f 100644 --- a/vendor/github.com/bitrise-io/go-xcode/xcarchive/ios.go +++ b/vendor/github.com/bitrise-io/go-xcode/xcarchive/ios.go @@ -26,7 +26,7 @@ func (app IosBaseApplication) BundleIdentifier() string { // NewIosBaseApplication ... func NewIosBaseApplication(path string) (IosBaseApplication, error) { - infoPlist := plistutil.PlistData{} + var infoPlist plistutil.PlistData { infoPlistPath := filepath.Join(path, "Info.plist") if exist, err := pathutil.IsPathExists(infoPlistPath); err != nil { @@ -41,7 +41,7 @@ func NewIosBaseApplication(path string) (IosBaseApplication, error) { infoPlist = plist } - provisioningProfile := profileutil.ProvisioningProfileInfoModel{} + var provisioningProfile profileutil.ProvisioningProfileInfoModel { provisioningProfilePath := filepath.Join(path, "embedded.mobileprovision") if exist, err := pathutil.IsPathExists(provisioningProfilePath); err != nil { @@ -222,7 +222,7 @@ type IosArchive struct { // NewIosArchive ... func NewIosArchive(path string) (IosArchive, error) { - infoPlist := plistutil.PlistData{} + var infoPlist plistutil.PlistData { infoPlistPath := filepath.Join(path, "Info.plist") if exist, err := pathutil.IsPathExists(infoPlistPath); err != nil { @@ -237,7 +237,7 @@ func NewIosArchive(path string) (IosArchive, error) { infoPlist = plist } - application := IosApplication{} + var application IosApplication { appPath := "" if appRelativePathToProducts, found := applicationFromPlist(infoPlist); found { diff --git a/vendor/github.com/bitrise-io/go-xcode/xcarchive/macos.go b/vendor/github.com/bitrise-io/go-xcode/xcarchive/macos.go index 27e81e58..929a6ce4 100644 --- a/vendor/github.com/bitrise-io/go-xcode/xcarchive/macos.go +++ b/vendor/github.com/bitrise-io/go-xcode/xcarchive/macos.go @@ -24,7 +24,7 @@ func (app macosBaseApplication) BundleIdentifier() string { } func newMacosBaseApplication(path string) (macosBaseApplication, error) { - infoPlist := plistutil.PlistData{} + var infoPlist plistutil.PlistData { infoPlistPath := filepath.Join(path, "Contents/Info.plist") if exist, err := pathutil.IsPathExists(infoPlistPath); err != nil { @@ -129,7 +129,7 @@ type MacosArchive struct { // NewMacosArchive ... func NewMacosArchive(path string) (MacosArchive, error) { - infoPlist := plistutil.PlistData{} + var infoPlist plistutil.PlistData { infoPlistPath := filepath.Join(path, "Info.plist") if exist, err := pathutil.IsPathExists(infoPlistPath); err != nil { @@ -144,7 +144,7 @@ func NewMacosArchive(path string) (MacosArchive, error) { infoPlist = plist } - application := MacosApplication{} + var application MacosApplication { pattern := filepath.Join(pathutil.EscapeGlobPath(path), "Products/Applications/*.app") pths, err := filepath.Glob(pattern) diff --git a/vendor/github.com/bitrise-io/go-xcode/xcodebuild/show_build_settings.go b/vendor/github.com/bitrise-io/go-xcode/xcodebuild/show_build_settings.go index 71b6d7bf..31cda3bb 100644 --- a/vendor/github.com/bitrise-io/go-xcode/xcodebuild/show_build_settings.go +++ b/vendor/github.com/bitrise-io/go-xcode/xcodebuild/show_build_settings.go @@ -114,7 +114,7 @@ func parseBuildSettings(out string) (serialized.Object, error) { buffer.WriteString(lineFragment) // isPrefix is set to false once a full line has been read - if isPrefix == false { + if !isPrefix { line := strings.TrimSpace(buffer.String()) if split := strings.Split(line, "="); len(split) > 1 { diff --git a/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/plist.go b/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/plist.go index dfac9a4a..e94fb73d 100644 --- a/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/plist.go +++ b/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/plist.go @@ -1,7 +1,7 @@ package xcodeproj import ( - "io/ioutil" + "os" plist "github.com/bitrise-io/go-plist" "github.com/bitrise-io/go-utils/fileutil" @@ -49,5 +49,5 @@ func WritePlistFile(path string, entitlements serialized.Object, format int) err return err } - return ioutil.WriteFile(path, marshalled, 0644) + return os.WriteFile(path, marshalled, 0644) } diff --git a/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/recreate_schemes.go b/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/recreate_schemes.go index 527d7d35..6a5ed12a 100644 --- a/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/recreate_schemes.go +++ b/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/recreate_schemes.go @@ -2,7 +2,6 @@ package xcodeproj import ( "fmt" - "io/ioutil" "os" "path" "path/filepath" @@ -35,7 +34,7 @@ func (p XcodeProj) SaveSharedScheme(scheme xcscheme.Scheme) error { return fmt.Errorf("failed to create directory: %v", err) } - if err := ioutil.WriteFile(path, contents, 0600); err != nil { + if err := os.WriteFile(path, contents, 0600); err != nil { return fmt.Errorf("failed to write Scheme file (%s): %v", path, err) } diff --git a/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/resources_build_phase.go b/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/resources_build_phase.go index 260d403d..93e59cd4 100644 --- a/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/resources_build_phase.go +++ b/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/resources_build_phase.go @@ -189,9 +189,8 @@ func findInProjectTree(target string, currentID string, object serialized.Object return nil, fmt.Errorf("object not found, id: %s, error: %s", currentID, err) } - entryPath, err := entry.String("path") - if err != nil { - } + entryPath, _ := entry.String("path") + sourceTreeRaw, err := entry.String("sourceTree") if err != nil { return nil, err diff --git a/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/xcodeproj.go b/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/xcodeproj.go index 0361e9bd..a6e9f336 100644 --- a/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/xcodeproj.go +++ b/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj/xcodeproj.go @@ -3,7 +3,7 @@ package xcodeproj import ( "errors" "fmt" - "io/ioutil" + "os" "path" "path/filepath" "reflect" @@ -233,7 +233,7 @@ func (p XcodeProj) TargetBundleID(target, configuration string) (string, error) func resolve(bundleID string, buildSettings serialized.Object) (string, error) { resolvedBundleIDs := map[string]bool{} resolved := bundleID - for true { + for { if !strings.Contains(resolved, "$") { return resolved, nil } @@ -250,7 +250,6 @@ func resolve(bundleID string, buildSettings serialized.Object) (string, error) { } resolvedBundleIDs[resolved] = true } - return "", fmt.Errorf("failed to resolve bundle id: %s", bundleID) } func expand(bundleID string, buildSettings serialized.Object) (string, error) { @@ -537,7 +536,7 @@ func (p XcodeProj) savePBXProj() error { pth := path.Join(p.Path, "project.pbxproj") newContent, merr := p.perObjectModify() if merr == nil { - return ioutil.WriteFile(pth, newContent, 0644) + return os.WriteFile(pth, newContent, 0644) } // merr != nil log.Warnf("failed to modify project in-place: %v", merr) @@ -547,7 +546,7 @@ func (p XcodeProj) savePBXProj() error { return fmt.Errorf("failed to marshal .pbxproj: %v", err) } - return ioutil.WriteFile(pth, newContent, 0644) + return os.WriteFile(pth, newContent, 0644) } const ( diff --git a/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcscheme/xcscheme.go b/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcscheme/xcscheme.go index f19ed067..43990e34 100644 --- a/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcscheme/xcscheme.go +++ b/vendor/github.com/bitrise-io/go-xcode/xcodeproject/xcscheme/xcscheme.go @@ -224,13 +224,12 @@ func parse(reader io.Reader) (scheme Scheme, err error) { type XMLToken int const ( - invalid XMLToken = iota // XMLStart ... - XMLStart + XMLStart XMLToken = 1 // XMLEnd ... - XMLEnd + XMLEnd XMLToken = 2 // XMLAttribute ... - XMLAttribute + XMLAttribute XMLToken = 3 ) // Marshal ... diff --git a/vendor/github.com/stretchr/objx/README.md b/vendor/github.com/stretchr/objx/README.md index 736e1eb5..78dc1f8b 100644 --- a/vendor/github.com/stretchr/objx/README.md +++ b/vendor/github.com/stretchr/objx/README.md @@ -74,7 +74,7 @@ To update Objx to the latest version, run: go get -u github.com/stretchr/objx ### Supported go versions -We currently support the most recent major Go versions from 1.13 onward. +We currently support the three recent major Go versions. ## Contributing Please feel free to submit issues, fork the repository and send pull requests! diff --git a/vendor/github.com/stretchr/objx/Taskfile.yml b/vendor/github.com/stretchr/objx/Taskfile.yml index 39f49d5a..8a79e8d6 100644 --- a/vendor/github.com/stretchr/objx/Taskfile.yml +++ b/vendor/github.com/stretchr/objx/Taskfile.yml @@ -1,4 +1,4 @@ -version: '2' +version: '3' tasks: default: diff --git a/vendor/github.com/stretchr/testify/assert/assertion_compare.go b/vendor/github.com/stretchr/testify/assert/assertion_compare.go index b774da88..4d4b4aad 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_compare.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_compare.go @@ -28,6 +28,8 @@ var ( uint32Type = reflect.TypeOf(uint32(1)) uint64Type = reflect.TypeOf(uint64(1)) + uintptrType = reflect.TypeOf(uintptr(1)) + float32Type = reflect.TypeOf(float32(1)) float64Type = reflect.TypeOf(float64(1)) @@ -308,11 +310,11 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) { case reflect.Struct: { // All structs enter here. We're not interested in most types. - if !canConvert(obj1Value, timeType) { + if !obj1Value.CanConvert(timeType) { break } - // time.Time can compared! + // time.Time can be compared! timeObj1, ok := obj1.(time.Time) if !ok { timeObj1 = obj1Value.Convert(timeType).Interface().(time.Time) @@ -328,7 +330,7 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) { case reflect.Slice: { // We only care about the []byte type. - if !canConvert(obj1Value, bytesType) { + if !obj1Value.CanConvert(bytesType) { break } @@ -345,6 +347,26 @@ func compare(obj1, obj2 interface{}, kind reflect.Kind) (CompareType, bool) { return CompareType(bytes.Compare(bytesObj1, bytesObj2)), true } + case reflect.Uintptr: + { + uintptrObj1, ok := obj1.(uintptr) + if !ok { + uintptrObj1 = obj1Value.Convert(uintptrType).Interface().(uintptr) + } + uintptrObj2, ok := obj2.(uintptr) + if !ok { + uintptrObj2 = obj2Value.Convert(uintptrType).Interface().(uintptr) + } + if uintptrObj1 > uintptrObj2 { + return compareGreater, true + } + if uintptrObj1 == uintptrObj2 { + return compareEqual, true + } + if uintptrObj1 < uintptrObj2 { + return compareLess, true + } + } } return compareEqual, false diff --git a/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go b/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go deleted file mode 100644 index da867903..00000000 --- a/vendor/github.com/stretchr/testify/assert/assertion_compare_can_convert.go +++ /dev/null @@ -1,16 +0,0 @@ -//go:build go1.17 -// +build go1.17 - -// TODO: once support for Go 1.16 is dropped, this file can be -// merged/removed with assertion_compare_go1.17_test.go and -// assertion_compare_legacy.go - -package assert - -import "reflect" - -// Wrapper around reflect.Value.CanConvert, for compatibility -// reasons. -func canConvert(value reflect.Value, to reflect.Type) bool { - return value.CanConvert(to) -} diff --git a/vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go b/vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go deleted file mode 100644 index 1701af2a..00000000 --- a/vendor/github.com/stretchr/testify/assert/assertion_compare_legacy.go +++ /dev/null @@ -1,16 +0,0 @@ -//go:build !go1.17 -// +build !go1.17 - -// TODO: once support for Go 1.16 is dropped, this file can be -// merged/removed with assertion_compare_go1.17_test.go and -// assertion_compare_can_convert.go - -package assert - -import "reflect" - -// Older versions of Go does not have the reflect.Value.CanConvert -// method. -func canConvert(value reflect.Value, to reflect.Type) bool { - return false -} diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go b/vendor/github.com/stretchr/testify/assert/assertion_format.go index 84dbd6c7..3ddab109 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_format.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_format.go @@ -1,7 +1,4 @@ -/* -* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen -* THIS FILE MUST NOT BE EDITED BY HAND - */ +// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT. package assert @@ -107,7 +104,7 @@ func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, return EqualExportedValues(t, expected, actual, append([]interface{}{msg}, args...)...) } -// EqualValuesf asserts that two objects are equal or convertable to the same types +// EqualValuesf asserts that two objects are equal or convertible to the same types // and equal. // // assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted") @@ -616,6 +613,16 @@ func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interf return NotErrorIs(t, err, target, append([]interface{}{msg}, args...)...) } +// NotImplementsf asserts that an object does not implement the specified interface. +// +// assert.NotImplementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted") +func NotImplementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NotImplements(t, interfaceObject, object, append([]interface{}{msg}, args...)...) +} + // NotNilf asserts that the specified object is not nil. // // assert.NotNilf(t, err, "error message %s", "formatted") @@ -660,10 +667,12 @@ func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, return NotSame(t, expected, actual, append([]interface{}{msg}, args...)...) } -// NotSubsetf asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). +// NotSubsetf asserts that the specified list(array, slice...) or map does NOT +// contain all elements given in the specified subset list(array, slice...) or +// map. // -// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") +// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "error message %s", "formatted") +// assert.NotSubsetf(t, {"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted") func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() @@ -747,10 +756,11 @@ func Samef(t TestingT, expected interface{}, actual interface{}, msg string, arg return Same(t, expected, actual, append([]interface{}{msg}, args...)...) } -// Subsetf asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). +// Subsetf asserts that the specified list(array, slice...) or map contains all +// elements given in the specified subset list(array, slice...) or map. // -// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") +// assert.Subsetf(t, [1, 2, 3], [1, 2], "error message %s", "formatted") +// assert.Subsetf(t, {"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted") func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go b/vendor/github.com/stretchr/testify/assert/assertion_forward.go index b1d94aec..a84e09bd 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_forward.go @@ -1,7 +1,4 @@ -/* -* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen -* THIS FILE MUST NOT BE EDITED BY HAND - */ +// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT. package assert @@ -189,7 +186,7 @@ func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface return EqualExportedValuesf(a.t, expected, actual, msg, args...) } -// EqualValues asserts that two objects are equal or convertable to the same types +// EqualValues asserts that two objects are equal or convertible to the same types // and equal. // // a.EqualValues(uint32(123), int32(123)) @@ -200,7 +197,7 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn return EqualValues(a.t, expected, actual, msgAndArgs...) } -// EqualValuesf asserts that two objects are equal or convertable to the same types +// EqualValuesf asserts that two objects are equal or convertible to the same types // and equal. // // a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted") @@ -1221,6 +1218,26 @@ func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...in return NotErrorIsf(a.t, err, target, msg, args...) } +// NotImplements asserts that an object does not implement the specified interface. +// +// a.NotImplements((*MyInterface)(nil), new(MyObject)) +func (a *Assertions) NotImplements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotImplements(a.t, interfaceObject, object, msgAndArgs...) +} + +// NotImplementsf asserts that an object does not implement the specified interface. +// +// a.NotImplementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted") +func (a *Assertions) NotImplementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotImplementsf(a.t, interfaceObject, object, msg, args...) +} + // NotNil asserts that the specified object is not nil. // // a.NotNil(err) @@ -1309,10 +1326,12 @@ func (a *Assertions) NotSamef(expected interface{}, actual interface{}, msg stri return NotSamef(a.t, expected, actual, msg, args...) } -// NotSubset asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). +// NotSubset asserts that the specified list(array, slice...) or map does NOT +// contain all elements given in the specified subset list(array, slice...) or +// map. // -// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") +// a.NotSubset([1, 3, 4], [1, 2]) +// a.NotSubset({"x": 1, "y": 2}, {"z": 3}) func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1320,10 +1339,12 @@ func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs return NotSubset(a.t, list, subset, msgAndArgs...) } -// NotSubsetf asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). +// NotSubsetf asserts that the specified list(array, slice...) or map does NOT +// contain all elements given in the specified subset list(array, slice...) or +// map. // -// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") +// a.NotSubsetf([1, 3, 4], [1, 2], "error message %s", "formatted") +// a.NotSubsetf({"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted") func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1483,10 +1504,11 @@ func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, return Samef(a.t, expected, actual, msg, args...) } -// Subset asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). +// Subset asserts that the specified list(array, slice...) or map contains all +// elements given in the specified subset list(array, slice...) or map. // -// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") +// a.Subset([1, 2, 3], [1, 2]) +// a.Subset({"x": 1, "y": 2}, {"x": 1}) func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1494,10 +1516,11 @@ func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ... return Subset(a.t, list, subset, msgAndArgs...) } -// Subsetf asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). +// Subsetf asserts that the specified list(array, slice...) or map contains all +// elements given in the specified subset list(array, slice...) or map. // -// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") +// a.Subsetf([1, 2, 3], [1, 2], "error message %s", "formatted") +// a.Subsetf({"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted") func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool { if h, ok := a.t.(tHelper); ok { h.Helper() diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go index a55d1bba..0b7570f2 100644 --- a/vendor/github.com/stretchr/testify/assert/assertions.go +++ b/vendor/github.com/stretchr/testify/assert/assertions.go @@ -19,7 +19,7 @@ import ( "github.com/davecgh/go-spew/spew" "github.com/pmezard/go-difflib/difflib" - yaml "gopkg.in/yaml.v3" + "gopkg.in/yaml.v3" ) //go:generate sh -c "cd ../_codegen && go build && cd - && ../_codegen/_codegen -output-package=assert -template=assertion_format.go.tmpl" @@ -110,7 +110,12 @@ func copyExportedFields(expected interface{}) interface{} { return result.Interface() case reflect.Array, reflect.Slice: - result := reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len()) + var result reflect.Value + if expectedKind == reflect.Array { + result = reflect.New(reflect.ArrayOf(expectedValue.Len(), expectedType.Elem())).Elem() + } else { + result = reflect.MakeSlice(expectedType, expectedValue.Len(), expectedValue.Len()) + } for i := 0; i < expectedValue.Len(); i++ { index := expectedValue.Index(i) if isNil(index) { @@ -140,6 +145,8 @@ func copyExportedFields(expected interface{}) interface{} { // structures. // // This function does no assertion of any kind. +// +// Deprecated: Use [EqualExportedValues] instead. func ObjectsExportedFieldsAreEqual(expected, actual interface{}) bool { expectedCleaned := copyExportedFields(expected) actualCleaned := copyExportedFields(actual) @@ -153,17 +160,40 @@ func ObjectsAreEqualValues(expected, actual interface{}) bool { return true } - actualType := reflect.TypeOf(actual) - if actualType == nil { + expectedValue := reflect.ValueOf(expected) + actualValue := reflect.ValueOf(actual) + if !expectedValue.IsValid() || !actualValue.IsValid() { return false } - expectedValue := reflect.ValueOf(expected) - if expectedValue.IsValid() && expectedValue.Type().ConvertibleTo(actualType) { + + expectedType := expectedValue.Type() + actualType := actualValue.Type() + if !expectedType.ConvertibleTo(actualType) { + return false + } + + if !isNumericType(expectedType) || !isNumericType(actualType) { // Attempt comparison after type conversion - return reflect.DeepEqual(expectedValue.Convert(actualType).Interface(), actual) + return reflect.DeepEqual( + expectedValue.Convert(actualType).Interface(), actual, + ) } - return false + // If BOTH values are numeric, there are chances of false positives due + // to overflow or underflow. So, we need to make sure to always convert + // the smaller type to a larger type before comparing. + if expectedType.Size() >= actualType.Size() { + return actualValue.Convert(expectedType).Interface() == expected + } + + return expectedValue.Convert(actualType).Interface() == actual +} + +// isNumericType returns true if the type is one of: +// int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64, +// float32, float64, complex64, complex128 +func isNumericType(t reflect.Type) bool { + return t.Kind() >= reflect.Int && t.Kind() <= reflect.Complex128 } /* CallerInfo is necessary because the assert functions use the testing object @@ -266,7 +296,7 @@ func messageFromMsgAndArgs(msgAndArgs ...interface{}) string { // Aligns the provided message so that all lines after the first line start at the same location as the first line. // Assumes that the first line starts at the correct location (after carriage return, tab, label, spacer and tab). -// The longestLabelLen parameter specifies the length of the longest label in the output (required becaues this is the +// The longestLabelLen parameter specifies the length of the longest label in the output (required because this is the // basis on which the alignment occurs). func indentMessageLines(message string, longestLabelLen int) string { outBuf := new(bytes.Buffer) @@ -382,6 +412,25 @@ func Implements(t TestingT, interfaceObject interface{}, object interface{}, msg return true } +// NotImplements asserts that an object does not implement the specified interface. +// +// assert.NotImplements(t, (*MyInterface)(nil), new(MyObject)) +func NotImplements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + interfaceType := reflect.TypeOf(interfaceObject).Elem() + + if object == nil { + return Fail(t, fmt.Sprintf("Cannot check if nil does not implement %v", interfaceType), msgAndArgs...) + } + if reflect.TypeOf(object).Implements(interfaceType) { + return Fail(t, fmt.Sprintf("%T implements %v", object, interfaceType), msgAndArgs...) + } + + return true +} + // IsType asserts that the specified objects are of the same type. func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool { if h, ok := t.(tHelper); ok { @@ -496,7 +545,7 @@ func samePointers(first, second interface{}) bool { // representations appropriate to be presented to the user. // // If the values are not of like type, the returned strings will be prefixed -// with the type name, and the value will be enclosed in parenthesis similar +// with the type name, and the value will be enclosed in parentheses similar // to a type conversion in the Go grammar. func formatUnequalValues(expected, actual interface{}) (e string, a string) { if reflect.TypeOf(expected) != reflect.TypeOf(actual) { @@ -523,7 +572,7 @@ func truncatingFormat(data interface{}) string { return value } -// EqualValues asserts that two objects are equal or convertable to the same types +// EqualValues asserts that two objects are equal or convertible to the same types // and equal. // // assert.EqualValues(t, uint32(123), int32(123)) @@ -566,12 +615,19 @@ func EqualExportedValues(t TestingT, expected, actual interface{}, msgAndArgs .. return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...) } + if aType.Kind() == reflect.Ptr { + aType = aType.Elem() + } + if bType.Kind() == reflect.Ptr { + bType = bType.Elem() + } + if aType.Kind() != reflect.Struct { - return Fail(t, fmt.Sprintf("Types expected to both be struct \n\t%v != %v", aType.Kind(), reflect.Struct), msgAndArgs...) + return Fail(t, fmt.Sprintf("Types expected to both be struct or pointer to struct \n\t%v != %v", aType.Kind(), reflect.Struct), msgAndArgs...) } if bType.Kind() != reflect.Struct { - return Fail(t, fmt.Sprintf("Types expected to both be struct \n\t%v != %v", bType.Kind(), reflect.Struct), msgAndArgs...) + return Fail(t, fmt.Sprintf("Types expected to both be struct or pointer to struct \n\t%v != %v", bType.Kind(), reflect.Struct), msgAndArgs...) } expected = copyExportedFields(expected) @@ -620,17 +676,6 @@ func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { return Fail(t, "Expected value not to be nil.", msgAndArgs...) } -// containsKind checks if a specified kind in the slice of kinds. -func containsKind(kinds []reflect.Kind, kind reflect.Kind) bool { - for i := 0; i < len(kinds); i++ { - if kind == kinds[i] { - return true - } - } - - return false -} - // isNil checks if a specified object is nil or not, without Failing. func isNil(object interface{}) bool { if object == nil { @@ -638,16 +683,13 @@ func isNil(object interface{}) bool { } value := reflect.ValueOf(object) - kind := value.Kind() - isNilableKind := containsKind( - []reflect.Kind{ - reflect.Chan, reflect.Func, - reflect.Interface, reflect.Map, - reflect.Ptr, reflect.Slice, reflect.UnsafePointer}, - kind) - - if isNilableKind && value.IsNil() { - return true + switch value.Kind() { + case + reflect.Chan, reflect.Func, + reflect.Interface, reflect.Map, + reflect.Ptr, reflect.Slice, reflect.UnsafePointer: + + return value.IsNil() } return false @@ -731,16 +773,14 @@ func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { } -// getLen try to get length of object. -// return (false, 0) if impossible. -func getLen(x interface{}) (ok bool, length int) { +// getLen tries to get the length of an object. +// It returns (0, false) if impossible. +func getLen(x interface{}) (length int, ok bool) { v := reflect.ValueOf(x) defer func() { - if e := recover(); e != nil { - ok = false - } + ok = recover() == nil }() - return true, v.Len() + return v.Len(), true } // Len asserts that the specified object has specific length. @@ -751,13 +791,13 @@ func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) if h, ok := t.(tHelper); ok { h.Helper() } - ok, l := getLen(object) + l, ok := getLen(object) if !ok { - return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", object), msgAndArgs...) + return Fail(t, fmt.Sprintf("\"%v\" could not be applied builtin len()", object), msgAndArgs...) } if l != length { - return Fail(t, fmt.Sprintf("\"%s\" should have %d item(s), but has %d", object, length, l), msgAndArgs...) + return Fail(t, fmt.Sprintf("\"%v\" should have %d item(s), but has %d", object, length, l), msgAndArgs...) } return true } @@ -919,10 +959,11 @@ func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) } -// Subset asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). +// Subset asserts that the specified list(array, slice...) or map contains all +// elements given in the specified subset list(array, slice...) or map. // -// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") +// assert.Subset(t, [1, 2, 3], [1, 2]) +// assert.Subset(t, {"x": 1, "y": 2}, {"x": 1}) func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) { if h, ok := t.(tHelper); ok { h.Helper() @@ -975,10 +1016,12 @@ func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok return true } -// NotSubset asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). +// NotSubset asserts that the specified list(array, slice...) or map does NOT +// contain all elements given in the specified subset list(array, slice...) or +// map. // -// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") +// assert.NotSubset(t, [1, 3, 4], [1, 2]) +// assert.NotSubset(t, {"x": 1, "y": 2}, {"z": 3}) func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1439,7 +1482,7 @@ func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAnd h.Helper() } if math.IsNaN(epsilon) { - return Fail(t, "epsilon must not be NaN") + return Fail(t, "epsilon must not be NaN", msgAndArgs...) } actualEpsilon, err := calcRelativeError(expected, actual) if err != nil { @@ -1458,19 +1501,26 @@ func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, m if h, ok := t.(tHelper); ok { h.Helper() } - if expected == nil || actual == nil || - reflect.TypeOf(actual).Kind() != reflect.Slice || - reflect.TypeOf(expected).Kind() != reflect.Slice { + + if expected == nil || actual == nil { return Fail(t, "Parameters must be slice", msgAndArgs...) } - actualSlice := reflect.ValueOf(actual) expectedSlice := reflect.ValueOf(expected) + actualSlice := reflect.ValueOf(actual) - for i := 0; i < actualSlice.Len(); i++ { - result := InEpsilon(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), epsilon) - if !result { - return result + if expectedSlice.Type().Kind() != reflect.Slice { + return Fail(t, "Expected value must be slice", msgAndArgs...) + } + + expectedLen := expectedSlice.Len() + if !IsType(t, expected, actual) || !Len(t, actual, expectedLen) { + return false + } + + for i := 0; i < expectedLen; i++ { + if !InEpsilon(t, expectedSlice.Index(i).Interface(), actualSlice.Index(i).Interface(), epsilon, "at index %d", i) { + return false } } @@ -1870,23 +1920,18 @@ func (c *CollectT) Errorf(format string, args ...interface{}) { } // FailNow panics. -func (c *CollectT) FailNow() { +func (*CollectT) FailNow() { panic("Assertion failed") } -// Reset clears the collected errors. -func (c *CollectT) Reset() { - c.errors = nil +// Deprecated: That was a method for internal usage that should not have been published. Now just panics. +func (*CollectT) Reset() { + panic("Reset() is deprecated") } -// Copy copies the collected errors to the supplied t. -func (c *CollectT) Copy(t TestingT) { - if tt, ok := t.(tHelper); ok { - tt.Helper() - } - for _, err := range c.errors { - t.Errorf("%v", err) - } +// Deprecated: That was a method for internal usage that should not have been published. Now just panics. +func (*CollectT) Copy(TestingT) { + panic("Copy() is deprecated") } // EventuallyWithT asserts that given condition will be met in waitFor time, @@ -1912,8 +1957,8 @@ func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time h.Helper() } - collect := new(CollectT) - ch := make(chan bool, 1) + var lastFinishedTickErrs []error + ch := make(chan []error, 1) timer := time.NewTimer(waitFor) defer timer.Stop() @@ -1924,19 +1969,25 @@ func EventuallyWithT(t TestingT, condition func(collect *CollectT), waitFor time for tick := ticker.C; ; { select { case <-timer.C: - collect.Copy(t) + for _, err := range lastFinishedTickErrs { + t.Errorf("%v", err) + } return Fail(t, "Condition never satisfied", msgAndArgs...) case <-tick: tick = nil - collect.Reset() go func() { + collect := new(CollectT) + defer func() { + ch <- collect.errors + }() condition(collect) - ch <- len(collect.errors) == 0 }() - case v := <-ch: - if v { + case errs := <-ch: + if len(errs) == 0 { return true } + // Keep the errors from the last ended condition, so that they can be copied to t if timeout is reached. + lastFinishedTickErrs = errs tick = ticker.C } } diff --git a/vendor/github.com/stretchr/testify/assert/http_assertions.go b/vendor/github.com/stretchr/testify/assert/http_assertions.go index d8038c28..861ed4b7 100644 --- a/vendor/github.com/stretchr/testify/assert/http_assertions.go +++ b/vendor/github.com/stretchr/testify/assert/http_assertions.go @@ -12,7 +12,7 @@ import ( // an error if building a new request fails. func httpCode(handler http.HandlerFunc, method, url string, values url.Values) (int, error) { w := httptest.NewRecorder() - req, err := http.NewRequest(method, url, nil) + req, err := http.NewRequest(method, url, http.NoBody) if err != nil { return -1, err } @@ -32,12 +32,12 @@ func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, value } code, err := httpCode(handler, method, url, values) if err != nil { - Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) + Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err), msgAndArgs...) } isSuccessCode := code >= http.StatusOK && code <= http.StatusPartialContent if !isSuccessCode { - Fail(t, fmt.Sprintf("Expected HTTP success status code for %q but received %d", url+"?"+values.Encode(), code)) + Fail(t, fmt.Sprintf("Expected HTTP success status code for %q but received %d", url+"?"+values.Encode(), code), msgAndArgs...) } return isSuccessCode @@ -54,12 +54,12 @@ func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, valu } code, err := httpCode(handler, method, url, values) if err != nil { - Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) + Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err), msgAndArgs...) } isRedirectCode := code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect if !isRedirectCode { - Fail(t, fmt.Sprintf("Expected HTTP redirect status code for %q but received %d", url+"?"+values.Encode(), code)) + Fail(t, fmt.Sprintf("Expected HTTP redirect status code for %q but received %d", url+"?"+values.Encode(), code), msgAndArgs...) } return isRedirectCode @@ -76,12 +76,12 @@ func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values } code, err := httpCode(handler, method, url, values) if err != nil { - Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) + Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err), msgAndArgs...) } isErrorCode := code >= http.StatusBadRequest if !isErrorCode { - Fail(t, fmt.Sprintf("Expected HTTP error status code for %q but received %d", url+"?"+values.Encode(), code)) + Fail(t, fmt.Sprintf("Expected HTTP error status code for %q but received %d", url+"?"+values.Encode(), code), msgAndArgs...) } return isErrorCode @@ -98,12 +98,12 @@ func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method, url string, va } code, err := httpCode(handler, method, url, values) if err != nil { - Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) + Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err), msgAndArgs...) } successful := code == statuscode if !successful { - Fail(t, fmt.Sprintf("Expected HTTP status code %d for %q but received %d", statuscode, url+"?"+values.Encode(), code)) + Fail(t, fmt.Sprintf("Expected HTTP status code %d for %q but received %d", statuscode, url+"?"+values.Encode(), code), msgAndArgs...) } return successful @@ -113,7 +113,10 @@ func HTTPStatusCode(t TestingT, handler http.HandlerFunc, method, url string, va // empty string if building a new request fails. func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) string { w := httptest.NewRecorder() - req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) + if len(values) > 0 { + url += "?" + values.Encode() + } + req, err := http.NewRequest(method, url, http.NoBody) if err != nil { return "" } @@ -135,7 +138,7 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, contains := strings.Contains(body, fmt.Sprint(str)) if !contains { - Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) + Fail(t, fmt.Sprintf("Expected response body for \"%s\" to contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body), msgAndArgs...) } return contains @@ -155,7 +158,7 @@ func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url strin contains := strings.Contains(body, fmt.Sprint(str)) if contains { - Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) + Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body), msgAndArgs...) } return !contains diff --git a/vendor/github.com/stretchr/testify/mock/mock.go b/vendor/github.com/stretchr/testify/mock/mock.go index f4b42e44..213bde2e 100644 --- a/vendor/github.com/stretchr/testify/mock/mock.go +++ b/vendor/github.com/stretchr/testify/mock/mock.go @@ -18,6 +18,9 @@ import ( "github.com/stretchr/testify/assert" ) +// regex for GCCGO functions +var gccgoRE = regexp.MustCompile(`\.pN\d+_`) + // TestingT is an interface wrapper around *testing.T type TestingT interface { Logf(format string, args ...interface{}) @@ -111,7 +114,7 @@ func (c *Call) Return(returnArguments ...interface{}) *Call { return c } -// Panic specifies if the functon call should fail and the panic message +// Panic specifies if the function call should fail and the panic message // // Mock.On("DoSomething").Panic("test panic") func (c *Call) Panic(msg string) *Call { @@ -123,21 +126,21 @@ func (c *Call) Panic(msg string) *Call { return c } -// Once indicates that that the mock should only return the value once. +// Once indicates that the mock should only return the value once. // // Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Once() func (c *Call) Once() *Call { return c.Times(1) } -// Twice indicates that that the mock should only return the value twice. +// Twice indicates that the mock should only return the value twice. // // Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Twice() func (c *Call) Twice() *Call { return c.Times(2) } -// Times indicates that that the mock should only return the indicated number +// Times indicates that the mock should only return the indicated number // of times. // // Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Times(5) @@ -455,9 +458,8 @@ func (m *Mock) Called(arguments ...interface{}) Arguments { // For Ex: github_com_docker_libkv_store_mock.WatchTree.pN39_github_com_docker_libkv_store_mock.Mock // uses interface information unlike golang github.com/docker/libkv/store/mock.(*Mock).WatchTree // With GCCGO we need to remove interface information starting from pN
. - re := regexp.MustCompile("\\.pN\\d+_") - if re.MatchString(functionPath) { - functionPath = re.Split(functionPath, -1)[0] + if gccgoRE.MatchString(functionPath) { + functionPath = gccgoRE.Split(functionPath, -1)[0] } parts := strings.Split(functionPath, ".") functionName := parts[len(parts)-1] @@ -474,7 +476,7 @@ func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Argumen found, call := m.findExpectedCall(methodName, arguments...) if found < 0 { - // expected call found but it has already been called with repeatable times + // expected call found, but it has already been called with repeatable times if call != nil { m.mutex.Unlock() m.fail("\nassert: mock: The method has been called over %d times.\n\tEither do one more Mock.On(\"%s\").Return(...), or remove extra call.\n\tThis call was unexpected:\n\t\t%s\n\tat: %s", call.totalCalls, methodName, callString(methodName, arguments, true), assert.CallerInfo()) @@ -563,7 +565,7 @@ func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Argumen Assertions */ -type assertExpectationser interface { +type assertExpectationiser interface { AssertExpectations(TestingT) bool } @@ -580,7 +582,7 @@ func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool { t.Logf("Deprecated mock.AssertExpectationsForObjects(myMock.Mock) use mock.AssertExpectationsForObjects(myMock)") obj = m } - m := obj.(assertExpectationser) + m := obj.(assertExpectationiser) if !m.AssertExpectations(t) { t.Logf("Expectations didn't match for Mock: %+v", reflect.TypeOf(m)) return false @@ -592,6 +594,9 @@ func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool { // AssertExpectations asserts that everything specified with On and Return was // in fact called as expected. Calls may have occurred in any order. func (m *Mock) AssertExpectations(t TestingT) bool { + if s, ok := t.(interface{ Skipped() bool }); ok && s.Skipped() { + return true + } if h, ok := t.(tHelper); ok { h.Helper() } @@ -606,8 +611,8 @@ func (m *Mock) AssertExpectations(t TestingT) bool { satisfied, reason := m.checkExpectation(expectedCall) if !satisfied { failedExpectations++ + t.Logf(reason) } - t.Logf(reason) } if failedExpectations != 0 { @@ -758,25 +763,33 @@ const ( Anything = "mock.Anything" ) -// AnythingOfTypeArgument is a string that contains the type of an argument +// AnythingOfTypeArgument contains the type of an argument +// for use when type checking. Used in Diff and Assert. +// +// Deprecated: this is an implementation detail that must not be used. Use [AnythingOfType] instead. +type AnythingOfTypeArgument = anythingOfTypeArgument + +// anythingOfTypeArgument is a string that contains the type of an argument // for use when type checking. Used in Diff and Assert. -type AnythingOfTypeArgument string +type anythingOfTypeArgument string -// AnythingOfType returns an AnythingOfTypeArgument object containing the -// name of the type to check for. Used in Diff and Assert. +// AnythingOfType returns a special value containing the +// name of the type to check for. The type name will be matched against the type name returned by [reflect.Type.String]. +// +// Used in Diff and Assert. // // For example: // // Assert(t, AnythingOfType("string"), AnythingOfType("int")) func AnythingOfType(t string) AnythingOfTypeArgument { - return AnythingOfTypeArgument(t) + return anythingOfTypeArgument(t) } // IsTypeArgument is a struct that contains the type of an argument // for use when type checking. This is an alternative to AnythingOfType. // Used in Diff and Assert. type IsTypeArgument struct { - t interface{} + t reflect.Type } // IsType returns an IsTypeArgument object containing the type to check for. @@ -786,7 +799,7 @@ type IsTypeArgument struct { // For example: // Assert(t, IsType(""), IsType(0)) func IsType(t interface{}) *IsTypeArgument { - return &IsTypeArgument{t: t} + return &IsTypeArgument{t: reflect.TypeOf(t)} } // FunctionalOptionsArgument is a struct that contains the type and value of an functional option argument @@ -950,53 +963,55 @@ func (args Arguments) Diff(objects []interface{}) (string, int) { differences++ output = fmt.Sprintf("%s\t%d: FAIL: %s not matched by %s\n", output, i, actualFmt, matcher) } - } else if reflect.TypeOf(expected) == reflect.TypeOf((*AnythingOfTypeArgument)(nil)).Elem() { - // type checking - if reflect.TypeOf(actual).Name() != string(expected.(AnythingOfTypeArgument)) && reflect.TypeOf(actual).String() != string(expected.(AnythingOfTypeArgument)) { - // not match - differences++ - output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, expected, reflect.TypeOf(actual).Name(), actualFmt) - } - } else if reflect.TypeOf(expected) == reflect.TypeOf((*IsTypeArgument)(nil)) { - t := expected.(*IsTypeArgument).t - if reflect.TypeOf(t) != reflect.TypeOf(actual) { - differences++ - output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, reflect.TypeOf(t).Name(), reflect.TypeOf(actual).Name(), actualFmt) - } - } else if reflect.TypeOf(expected) == reflect.TypeOf((*FunctionalOptionsArgument)(nil)) { - t := expected.(*FunctionalOptionsArgument).value + } else { + switch expected := expected.(type) { + case anythingOfTypeArgument: + // type checking + if reflect.TypeOf(actual).Name() != string(expected) && reflect.TypeOf(actual).String() != string(expected) { + // not match + differences++ + output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, expected, reflect.TypeOf(actual).Name(), actualFmt) + } + case *IsTypeArgument: + actualT := reflect.TypeOf(actual) + if actualT != expected.t { + differences++ + output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, expected.t.Name(), actualT.Name(), actualFmt) + } + case *FunctionalOptionsArgument: + t := expected.value - var name string - tValue := reflect.ValueOf(t) - if tValue.Len() > 0 { - name = "[]" + reflect.TypeOf(tValue.Index(0).Interface()).String() - } + var name string + tValue := reflect.ValueOf(t) + if tValue.Len() > 0 { + name = "[]" + reflect.TypeOf(tValue.Index(0).Interface()).String() + } - tName := reflect.TypeOf(t).Name() - if name != reflect.TypeOf(actual).String() && tValue.Len() != 0 { - differences++ - output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, tName, reflect.TypeOf(actual).Name(), actualFmt) - } else { - if ef, af := assertOpts(t, actual); ef == "" && af == "" { + tName := reflect.TypeOf(t).Name() + if name != reflect.TypeOf(actual).String() && tValue.Len() != 0 { + differences++ + output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, tName, reflect.TypeOf(actual).Name(), actualFmt) + } else { + if ef, af := assertOpts(t, actual); ef == "" && af == "" { + // match + output = fmt.Sprintf("%s\t%d: PASS: %s == %s\n", output, i, tName, tName) + } else { + // not match + differences++ + output = fmt.Sprintf("%s\t%d: FAIL: %s != %s\n", output, i, af, ef) + } + } + + default: + if assert.ObjectsAreEqual(expected, Anything) || assert.ObjectsAreEqual(actual, Anything) || assert.ObjectsAreEqual(actual, expected) { // match - output = fmt.Sprintf("%s\t%d: PASS: %s == %s\n", output, i, tName, tName) + output = fmt.Sprintf("%s\t%d: PASS: %s == %s\n", output, i, actualFmt, expectedFmt) } else { // not match differences++ - output = fmt.Sprintf("%s\t%d: FAIL: %s != %s\n", output, i, af, ef) + output = fmt.Sprintf("%s\t%d: FAIL: %s != %s\n", output, i, actualFmt, expectedFmt) } } - } else { - // normal checking - - if assert.ObjectsAreEqual(expected, Anything) || assert.ObjectsAreEqual(actual, Anything) || assert.ObjectsAreEqual(actual, expected) { - // match - output = fmt.Sprintf("%s\t%d: PASS: %s == %s\n", output, i, actualFmt, expectedFmt) - } else { - // not match - differences++ - output = fmt.Sprintf("%s\t%d: FAIL: %s != %s\n", output, i, actualFmt, expectedFmt) - } } } diff --git a/vendor/github.com/stretchr/testify/require/require.go b/vendor/github.com/stretchr/testify/require/require.go index 63f85214..506a82f8 100644 --- a/vendor/github.com/stretchr/testify/require/require.go +++ b/vendor/github.com/stretchr/testify/require/require.go @@ -1,7 +1,4 @@ -/* -* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen -* THIS FILE MUST NOT BE EDITED BY HAND - */ +// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT. package require @@ -235,7 +232,7 @@ func EqualExportedValuesf(t TestingT, expected interface{}, actual interface{}, t.FailNow() } -// EqualValues asserts that two objects are equal or convertable to the same types +// EqualValues asserts that two objects are equal or convertible to the same types // and equal. // // assert.EqualValues(t, uint32(123), int32(123)) @@ -249,7 +246,7 @@ func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArg t.FailNow() } -// EqualValuesf asserts that two objects are equal or convertable to the same types +// EqualValuesf asserts that two objects are equal or convertible to the same types // and equal. // // assert.EqualValuesf(t, uint32(123), int32(123), "error message %s", "formatted") @@ -1546,6 +1543,32 @@ func NotErrorIsf(t TestingT, err error, target error, msg string, args ...interf t.FailNow() } +// NotImplements asserts that an object does not implement the specified interface. +// +// assert.NotImplements(t, (*MyInterface)(nil), new(MyObject)) +func NotImplements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.NotImplements(t, interfaceObject, object, msgAndArgs...) { + return + } + t.FailNow() +} + +// NotImplementsf asserts that an object does not implement the specified interface. +// +// assert.NotImplementsf(t, (*MyInterface)(nil), new(MyObject), "error message %s", "formatted") +func NotImplementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if assert.NotImplementsf(t, interfaceObject, object, msg, args...) { + return + } + t.FailNow() +} + // NotNil asserts that the specified object is not nil. // // assert.NotNil(t, err) @@ -1658,10 +1681,12 @@ func NotSamef(t TestingT, expected interface{}, actual interface{}, msg string, t.FailNow() } -// NotSubset asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). +// NotSubset asserts that the specified list(array, slice...) or map does NOT +// contain all elements given in the specified subset list(array, slice...) or +// map. // -// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") +// assert.NotSubset(t, [1, 3, 4], [1, 2]) +// assert.NotSubset(t, {"x": 1, "y": 2}, {"z": 3}) func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1672,10 +1697,12 @@ func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...i t.FailNow() } -// NotSubsetf asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). +// NotSubsetf asserts that the specified list(array, slice...) or map does NOT +// contain all elements given in the specified subset list(array, slice...) or +// map. // -// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") +// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "error message %s", "formatted") +// assert.NotSubsetf(t, {"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted") func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1880,10 +1907,11 @@ func Samef(t TestingT, expected interface{}, actual interface{}, msg string, arg t.FailNow() } -// Subset asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). +// Subset asserts that the specified list(array, slice...) or map contains all +// elements given in the specified subset list(array, slice...) or map. // -// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") +// assert.Subset(t, [1, 2, 3], [1, 2]) +// assert.Subset(t, {"x": 1, "y": 2}, {"x": 1}) func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() @@ -1894,10 +1922,11 @@ func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...inte t.FailNow() } -// Subsetf asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). +// Subsetf asserts that the specified list(array, slice...) or map contains all +// elements given in the specified subset list(array, slice...) or map. // -// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") +// assert.Subsetf(t, [1, 2, 3], [1, 2], "error message %s", "formatted") +// assert.Subsetf(t, {"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted") func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { if h, ok := t.(tHelper); ok { h.Helper() diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go b/vendor/github.com/stretchr/testify/require/require_forward.go index 3b5b0933..eee8310a 100644 --- a/vendor/github.com/stretchr/testify/require/require_forward.go +++ b/vendor/github.com/stretchr/testify/require/require_forward.go @@ -1,7 +1,4 @@ -/* -* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen -* THIS FILE MUST NOT BE EDITED BY HAND - */ +// Code generated with github.com/stretchr/testify/_codegen; DO NOT EDIT. package require @@ -190,7 +187,7 @@ func (a *Assertions) EqualExportedValuesf(expected interface{}, actual interface EqualExportedValuesf(a.t, expected, actual, msg, args...) } -// EqualValues asserts that two objects are equal or convertable to the same types +// EqualValues asserts that two objects are equal or convertible to the same types // and equal. // // a.EqualValues(uint32(123), int32(123)) @@ -201,7 +198,7 @@ func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAn EqualValues(a.t, expected, actual, msgAndArgs...) } -// EqualValuesf asserts that two objects are equal or convertable to the same types +// EqualValuesf asserts that two objects are equal or convertible to the same types // and equal. // // a.EqualValuesf(uint32(123), int32(123), "error message %s", "formatted") @@ -1222,6 +1219,26 @@ func (a *Assertions) NotErrorIsf(err error, target error, msg string, args ...in NotErrorIsf(a.t, err, target, msg, args...) } +// NotImplements asserts that an object does not implement the specified interface. +// +// a.NotImplements((*MyInterface)(nil), new(MyObject)) +func (a *Assertions) NotImplements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotImplements(a.t, interfaceObject, object, msgAndArgs...) +} + +// NotImplementsf asserts that an object does not implement the specified interface. +// +// a.NotImplementsf((*MyInterface)(nil), new(MyObject), "error message %s", "formatted") +func (a *Assertions) NotImplementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotImplementsf(a.t, interfaceObject, object, msg, args...) +} + // NotNil asserts that the specified object is not nil. // // a.NotNil(err) @@ -1310,10 +1327,12 @@ func (a *Assertions) NotSamef(expected interface{}, actual interface{}, msg stri NotSamef(a.t, expected, actual, msg, args...) } -// NotSubset asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). +// NotSubset asserts that the specified list(array, slice...) or map does NOT +// contain all elements given in the specified subset list(array, slice...) or +// map. // -// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") +// a.NotSubset([1, 3, 4], [1, 2]) +// a.NotSubset({"x": 1, "y": 2}, {"z": 3}) func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1321,10 +1340,12 @@ func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs NotSubset(a.t, list, subset, msgAndArgs...) } -// NotSubsetf asserts that the specified list(array, slice...) contains not all -// elements given in the specified subset(array, slice...). +// NotSubsetf asserts that the specified list(array, slice...) or map does NOT +// contain all elements given in the specified subset list(array, slice...) or +// map. // -// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") +// a.NotSubsetf([1, 3, 4], [1, 2], "error message %s", "formatted") +// a.NotSubsetf({"x": 1, "y": 2}, {"z": 3}, "error message %s", "formatted") func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1484,10 +1505,11 @@ func (a *Assertions) Samef(expected interface{}, actual interface{}, msg string, Samef(a.t, expected, actual, msg, args...) } -// Subset asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). +// Subset asserts that the specified list(array, slice...) or map contains all +// elements given in the specified subset list(array, slice...) or map. // -// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") +// a.Subset([1, 2, 3], [1, 2]) +// a.Subset({"x": 1, "y": 2}, {"x": 1}) func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() @@ -1495,10 +1517,11 @@ func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ... Subset(a.t, list, subset, msgAndArgs...) } -// Subsetf asserts that the specified list(array, slice...) contains all -// elements given in the specified subset(array, slice...). +// Subsetf asserts that the specified list(array, slice...) or map contains all +// elements given in the specified subset list(array, slice...) or map. // -// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") +// a.Subsetf([1, 2, 3], [1, 2], "error message %s", "formatted") +// a.Subsetf({"x": 1, "y": 2}, {"x": 1}, "error message %s", "formatted") func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) { if h, ok := a.t.(tHelper); ok { h.Helper() diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index fdcaa974..4ed2e488 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -263,6 +263,7 @@ struct ltchars { #include #include #include +#include #include #include #include @@ -549,6 +550,7 @@ ccflags="$@" $2 !~ "NLA_TYPE_MASK" && $2 !~ /^RTC_VL_(ACCURACY|BACKUP|DATA)/ && $2 ~ /^(NETLINK|NLM|NLMSG|NLA|IFA|IFAN|RT|RTC|RTCF|RTN|RTPROT|RTNH|ARPHRD|ETH_P|NETNSA)_/ || + $2 ~ /^SOCK_|SK_DIAG_|SKNLGRP_$/ || $2 ~ /^FIORDCHK$/ || $2 ~ /^SIOC/ || $2 ~ /^TIOC/ || diff --git a/vendor/golang.org/x/sys/unix/mremap.go b/vendor/golang.org/x/sys/unix/mremap.go index fd45fe52..3a5e776f 100644 --- a/vendor/golang.org/x/sys/unix/mremap.go +++ b/vendor/golang.org/x/sys/unix/mremap.go @@ -50,3 +50,8 @@ func (m *mremapMmapper) Mremap(oldData []byte, newLength int, flags int) (data [ func Mremap(oldData []byte, newLength int, flags int) (data []byte, err error) { return mapper.Mremap(oldData, newLength, flags) } + +func MremapPtr(oldAddr unsafe.Pointer, oldSize uintptr, newAddr unsafe.Pointer, newSize uintptr, flags int) (ret unsafe.Pointer, err error) { + xaddr, err := mapper.mremap(uintptr(oldAddr), oldSize, newSize, flags, uintptr(newAddr)) + return unsafe.Pointer(xaddr), err +} diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index 59542a89..4cc7b005 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -542,6 +542,18 @@ func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) { } } +//sys pthread_chdir_np(path string) (err error) + +func PthreadChdir(path string) (err error) { + return pthread_chdir_np(path) +} + +//sys pthread_fchdir_np(fd int) (err error) + +func PthreadFchdir(fd int) (err error) { + return pthread_fchdir_np(fd) +} + //sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) //sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error) diff --git a/vendor/golang.org/x/sys/unix/syscall_unix.go b/vendor/golang.org/x/sys/unix/syscall_unix.go index 77081de8..4e92e5aa 100644 --- a/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -154,6 +154,15 @@ func Munmap(b []byte) (err error) { return mapper.Munmap(b) } +func MmapPtr(fd int, offset int64, addr unsafe.Pointer, length uintptr, prot int, flags int) (ret unsafe.Pointer, err error) { + xaddr, err := mapper.mmap(uintptr(addr), length, prot, flags, fd, offset) + return unsafe.Pointer(xaddr), err +} + +func MunmapPtr(addr unsafe.Pointer, length uintptr) (err error) { + return mapper.munmap(uintptr(addr), length) +} + func Read(fd int, p []byte) (n int, err error) { n, err = read(fd, p) if raceenabled { diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 93a38a97..877a62b4 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -502,6 +502,7 @@ const ( BPF_IMM = 0x0 BPF_IND = 0x40 BPF_JA = 0x0 + BPF_JCOND = 0xe0 BPF_JEQ = 0x10 BPF_JGE = 0x30 BPF_JGT = 0x20 @@ -657,6 +658,9 @@ const ( CAN_NPROTO = 0x8 CAN_RAW = 0x1 CAN_RAW_FILTER_MAX = 0x200 + CAN_RAW_XL_VCID_RX_FILTER = 0x4 + CAN_RAW_XL_VCID_TX_PASS = 0x2 + CAN_RAW_XL_VCID_TX_SET = 0x1 CAN_RTR_FLAG = 0x40000000 CAN_SFF_ID_BITS = 0xb CAN_SFF_MASK = 0x7ff @@ -1339,6 +1343,7 @@ const ( F_OFD_SETLK = 0x25 F_OFD_SETLKW = 0x26 F_OK = 0x0 + F_SEAL_EXEC = 0x20 F_SEAL_FUTURE_WRITE = 0x10 F_SEAL_GROW = 0x4 F_SEAL_SEAL = 0x1 @@ -1627,6 +1632,7 @@ const ( IP_FREEBIND = 0xf IP_HDRINCL = 0x3 IP_IPSEC_POLICY = 0x10 + IP_LOCAL_PORT_RANGE = 0x33 IP_MAXPACKET = 0xffff IP_MAX_MEMBERSHIPS = 0x14 IP_MF = 0x2000 @@ -1653,6 +1659,7 @@ const ( IP_PMTUDISC_OMIT = 0x5 IP_PMTUDISC_PROBE = 0x3 IP_PMTUDISC_WANT = 0x1 + IP_PROTOCOL = 0x34 IP_RECVERR = 0xb IP_RECVERR_RFC4884 = 0x1a IP_RECVFRAGSIZE = 0x19 @@ -2169,7 +2176,7 @@ const ( NFT_SECMARK_CTX_MAXLEN = 0x100 NFT_SET_MAXNAMELEN = 0x100 NFT_SOCKET_MAX = 0x3 - NFT_TABLE_F_MASK = 0x3 + NFT_TABLE_F_MASK = 0x7 NFT_TABLE_MAXNAMELEN = 0x100 NFT_TRACETYPE_MAX = 0x3 NFT_TUNNEL_F_MASK = 0x7 @@ -2403,6 +2410,7 @@ const ( PERF_RECORD_MISC_USER = 0x2 PERF_SAMPLE_BRANCH_PLM_ALL = 0x7 PERF_SAMPLE_WEIGHT_TYPE = 0x1004000 + PID_FS_MAGIC = 0x50494446 PIPEFS_MAGIC = 0x50495045 PPPIOCGNPMODE = 0xc008744c PPPIOCNEWUNIT = 0xc004743e @@ -2896,8 +2904,9 @@ const ( RWF_APPEND = 0x10 RWF_DSYNC = 0x2 RWF_HIPRI = 0x1 + RWF_NOAPPEND = 0x20 RWF_NOWAIT = 0x8 - RWF_SUPPORTED = 0x1f + RWF_SUPPORTED = 0x3f RWF_SYNC = 0x4 RWF_WRITE_LIFE_NOT_SET = 0x0 SCHED_BATCH = 0x3 @@ -2918,7 +2927,9 @@ const ( SCHED_RESET_ON_FORK = 0x40000000 SCHED_RR = 0x2 SCM_CREDENTIALS = 0x2 + SCM_PIDFD = 0x4 SCM_RIGHTS = 0x1 + SCM_SECURITY = 0x3 SCM_TIMESTAMP = 0x1d SC_LOG_FLUSH = 0x100000 SECCOMP_ADDFD_FLAG_SEND = 0x2 @@ -3051,6 +3062,8 @@ const ( SIOCSMIIREG = 0x8949 SIOCSRARP = 0x8962 SIOCWANDEV = 0x894a + SK_DIAG_BPF_STORAGE_MAX = 0x3 + SK_DIAG_BPF_STORAGE_REQ_MAX = 0x1 SMACK_MAGIC = 0x43415d53 SMART_AUTOSAVE = 0xd2 SMART_AUTO_OFFLINE = 0xdb @@ -3071,6 +3084,8 @@ const ( SOCKFS_MAGIC = 0x534f434b SOCK_BUF_LOCK_MASK = 0x3 SOCK_DCCP = 0x6 + SOCK_DESTROY = 0x15 + SOCK_DIAG_BY_FAMILY = 0x14 SOCK_IOC_TYPE = 0x89 SOCK_PACKET = 0xa SOCK_RAW = 0x3 @@ -3260,6 +3275,7 @@ const ( TCP_MAX_WINSHIFT = 0xe TCP_MD5SIG = 0xe TCP_MD5SIG_EXT = 0x20 + TCP_MD5SIG_FLAG_IFINDEX = 0x2 TCP_MD5SIG_FLAG_PREFIX = 0x1 TCP_MD5SIG_MAXKEYLEN = 0x50 TCP_MSS = 0x200 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index 42ff8c3c..e4bc0bd5 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -118,6 +118,7 @@ const ( IXOFF = 0x1000 IXON = 0x400 MAP_32BIT = 0x40 + MAP_ABOVE4G = 0x80 MAP_ANON = 0x20 MAP_ANONYMOUS = 0x20 MAP_DENYWRITE = 0x800 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index dca43600..689317af 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -118,6 +118,7 @@ const ( IXOFF = 0x1000 IXON = 0x400 MAP_32BIT = 0x40 + MAP_ABOVE4G = 0x80 MAP_ANON = 0x20 MAP_ANONYMOUS = 0x20 MAP_DENYWRITE = 0x800 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index d8cae6d1..14270508 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -87,6 +87,7 @@ const ( FICLONE = 0x40049409 FICLONERANGE = 0x4020940d FLUSHO = 0x1000 + FPMR_MAGIC = 0x46504d52 FPSIMD_MAGIC = 0x46508001 FS_IOC_ENABLE_VERITY = 0x40806685 FS_IOC_GETFLAGS = 0x80086601 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index ccb02f24..07642c30 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -760,6 +760,39 @@ var libc_sysctl_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pthread_chdir_np(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_pthread_chdir_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pthread_chdir_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pthread_chdir_np pthread_chdir_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pthread_fchdir_np(fd int) (err error) { + _, _, e1 := syscall_syscall(libc_pthread_fchdir_np_trampoline_addr, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pthread_fchdir_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pthread_fchdir_np pthread_fchdir_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) { _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags)) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index 8b8bb284..923e08cb 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -228,6 +228,16 @@ TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_sysctl_trampoline_addr(SB)/8, $libc_sysctl_trampoline<>(SB) +TEXT libc_pthread_chdir_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pthread_chdir_np(SB) +GLOBL ·libc_pthread_chdir_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pthread_chdir_np_trampoline_addr(SB)/8, $libc_pthread_chdir_np_trampoline<>(SB) + +TEXT libc_pthread_fchdir_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pthread_fchdir_np(SB) +GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB) + TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sendfile(SB) GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 1b40b997..7d73dda6 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -760,6 +760,39 @@ var libc_sysctl_trampoline_addr uintptr // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func pthread_chdir_np(path string) (err error) { + var _p0 *byte + _p0, err = BytePtrFromString(path) + if err != nil { + return + } + _, _, e1 := syscall_syscall(libc_pthread_chdir_np_trampoline_addr, uintptr(unsafe.Pointer(_p0)), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pthread_chdir_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pthread_chdir_np pthread_chdir_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + +func pthread_fchdir_np(fd int) (err error) { + _, _, e1 := syscall_syscall(libc_pthread_fchdir_np_trampoline_addr, uintptr(fd), 0, 0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +var libc_pthread_fchdir_np_trampoline_addr uintptr + +//go:cgo_import_dynamic libc_pthread_fchdir_np pthread_fchdir_np "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) { _, _, e1 := syscall_syscall6(libc_sendfile_trampoline_addr, uintptr(infd), uintptr(outfd), uintptr(offset), uintptr(unsafe.Pointer(len)), uintptr(hdtr), uintptr(flags)) if e1 != 0 { diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index 08362c1a..05770011 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -228,6 +228,16 @@ TEXT libc_sysctl_trampoline<>(SB),NOSPLIT,$0-0 GLOBL ·libc_sysctl_trampoline_addr(SB), RODATA, $8 DATA ·libc_sysctl_trampoline_addr(SB)/8, $libc_sysctl_trampoline<>(SB) +TEXT libc_pthread_chdir_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pthread_chdir_np(SB) +GLOBL ·libc_pthread_chdir_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pthread_chdir_np_trampoline_addr(SB)/8, $libc_pthread_chdir_np_trampoline<>(SB) + +TEXT libc_pthread_fchdir_np_trampoline<>(SB),NOSPLIT,$0-0 + JMP libc_pthread_fchdir_np(SB) +GLOBL ·libc_pthread_fchdir_np_trampoline_addr(SB), RODATA, $8 +DATA ·libc_pthread_fchdir_np_trampoline_addr(SB)/8, $libc_pthread_fchdir_np_trampoline<>(SB) + TEXT libc_sendfile_trampoline<>(SB),NOSPLIT,$0-0 JMP libc_sendfile(SB) GLOBL ·libc_sendfile_trampoline_addr(SB), RODATA, $8 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 0036746e..4740b834 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -4605,7 +4605,7 @@ const ( NL80211_ATTR_MAC_HINT = 0xc8 NL80211_ATTR_MAC_MASK = 0xd7 NL80211_ATTR_MAX_AP_ASSOC_STA = 0xca - NL80211_ATTR_MAX = 0x149 + NL80211_ATTR_MAX = 0x14a NL80211_ATTR_MAX_CRIT_PROT_DURATION = 0xb4 NL80211_ATTR_MAX_CSA_COUNTERS = 0xce NL80211_ATTR_MAX_MATCH_SETS = 0x85 @@ -5209,7 +5209,7 @@ const ( NL80211_FREQUENCY_ATTR_GO_CONCURRENT = 0xf NL80211_FREQUENCY_ATTR_INDOOR_ONLY = 0xe NL80211_FREQUENCY_ATTR_IR_CONCURRENT = 0xf - NL80211_FREQUENCY_ATTR_MAX = 0x1f + NL80211_FREQUENCY_ATTR_MAX = 0x20 NL80211_FREQUENCY_ATTR_MAX_TX_POWER = 0x6 NL80211_FREQUENCY_ATTR_NO_10MHZ = 0x11 NL80211_FREQUENCY_ATTR_NO_160MHZ = 0xc @@ -5703,7 +5703,7 @@ const ( NL80211_STA_FLAG_ASSOCIATED = 0x7 NL80211_STA_FLAG_AUTHENTICATED = 0x5 NL80211_STA_FLAG_AUTHORIZED = 0x1 - NL80211_STA_FLAG_MAX = 0x7 + NL80211_STA_FLAG_MAX = 0x8 NL80211_STA_FLAG_MAX_OLD_API = 0x6 NL80211_STA_FLAG_MFP = 0x4 NL80211_STA_FLAG_SHORT_PREAMBLE = 0x2 @@ -6001,3 +6001,34 @@ type CachestatRange struct { Off uint64 Len uint64 } + +const ( + SK_MEMINFO_RMEM_ALLOC = 0x0 + SK_MEMINFO_RCVBUF = 0x1 + SK_MEMINFO_WMEM_ALLOC = 0x2 + SK_MEMINFO_SNDBUF = 0x3 + SK_MEMINFO_FWD_ALLOC = 0x4 + SK_MEMINFO_WMEM_QUEUED = 0x5 + SK_MEMINFO_OPTMEM = 0x6 + SK_MEMINFO_BACKLOG = 0x7 + SK_MEMINFO_DROPS = 0x8 + SK_MEMINFO_VARS = 0x9 + SKNLGRP_NONE = 0x0 + SKNLGRP_INET_TCP_DESTROY = 0x1 + SKNLGRP_INET_UDP_DESTROY = 0x2 + SKNLGRP_INET6_TCP_DESTROY = 0x3 + SKNLGRP_INET6_UDP_DESTROY = 0x4 + SK_DIAG_BPF_STORAGE_REQ_NONE = 0x0 + SK_DIAG_BPF_STORAGE_REQ_MAP_FD = 0x1 + SK_DIAG_BPF_STORAGE_REP_NONE = 0x0 + SK_DIAG_BPF_STORAGE = 0x1 + SK_DIAG_BPF_STORAGE_NONE = 0x0 + SK_DIAG_BPF_STORAGE_PAD = 0x1 + SK_DIAG_BPF_STORAGE_MAP_ID = 0x2 + SK_DIAG_BPF_STORAGE_MAP_VALUE = 0x3 +) + +type SockDiagReq struct { + Family uint8 + Protocol uint8 +} diff --git a/vendor/golang.org/x/sys/windows/security_windows.go b/vendor/golang.org/x/sys/windows/security_windows.go index 26be94a8..97651b5b 100644 --- a/vendor/golang.org/x/sys/windows/security_windows.go +++ b/vendor/golang.org/x/sys/windows/security_windows.go @@ -68,6 +68,7 @@ type UserInfo10 struct { //sys NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) = netapi32.NetUserGetInfo //sys NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (neterr error) = netapi32.NetGetJoinInformation //sys NetApiBufferFree(buf *byte) (neterr error) = netapi32.NetApiBufferFree +//sys NetUserEnum(serverName *uint16, level uint32, filter uint32, buf **byte, prefMaxLen uint32, entriesRead *uint32, totalEntries *uint32, resumeHandle *uint32) (neterr error) = netapi32.NetUserEnum const ( // do not reorder @@ -893,7 +894,7 @@ type ACL struct { aclRevision byte sbz1 byte aclSize uint16 - aceCount uint16 + AceCount uint16 sbz2 uint16 } @@ -1086,6 +1087,27 @@ type EXPLICIT_ACCESS struct { Trustee TRUSTEE } +// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-ace_header +type ACE_HEADER struct { + AceType uint8 + AceFlags uint8 + AceSize uint16 +} + +// https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-access_allowed_ace +type ACCESS_ALLOWED_ACE struct { + Header ACE_HEADER + Mask ACCESS_MASK + SidStart uint32 +} + +const ( + // Constants for AceType + // https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-ace_header + ACCESS_ALLOWED_ACE_TYPE = 0 + ACCESS_DENIED_ACE_TYPE = 1 +) + // This type is the union inside of TRUSTEE and must be created using one of the TrusteeValueFrom* functions. type TrusteeValue uintptr @@ -1157,6 +1179,7 @@ type OBJECTS_AND_NAME struct { //sys makeSelfRelativeSD(absoluteSD *SECURITY_DESCRIPTOR, selfRelativeSD *SECURITY_DESCRIPTOR, selfRelativeSDSize *uint32) (err error) = advapi32.MakeSelfRelativeSD //sys setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCESS, oldACL *ACL, newACL **ACL) (ret error) = advapi32.SetEntriesInAclW +//sys GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) = advapi32.GetAce // Control returns the security descriptor control bits. func (sd *SECURITY_DESCRIPTOR) Control() (control SECURITY_DESCRIPTOR_CONTROL, revision uint32, err error) { diff --git a/vendor/golang.org/x/sys/windows/zsyscall_windows.go b/vendor/golang.org/x/sys/windows/zsyscall_windows.go index 5c6035dd..eba76101 100644 --- a/vendor/golang.org/x/sys/windows/zsyscall_windows.go +++ b/vendor/golang.org/x/sys/windows/zsyscall_windows.go @@ -91,6 +91,7 @@ var ( procEnumServicesStatusExW = modadvapi32.NewProc("EnumServicesStatusExW") procEqualSid = modadvapi32.NewProc("EqualSid") procFreeSid = modadvapi32.NewProc("FreeSid") + procGetAce = modadvapi32.NewProc("GetAce") procGetLengthSid = modadvapi32.NewProc("GetLengthSid") procGetNamedSecurityInfoW = modadvapi32.NewProc("GetNamedSecurityInfoW") procGetSecurityDescriptorControl = modadvapi32.NewProc("GetSecurityDescriptorControl") @@ -401,6 +402,7 @@ var ( procTransmitFile = modmswsock.NewProc("TransmitFile") procNetApiBufferFree = modnetapi32.NewProc("NetApiBufferFree") procNetGetJoinInformation = modnetapi32.NewProc("NetGetJoinInformation") + procNetUserEnum = modnetapi32.NewProc("NetUserEnum") procNetUserGetInfo = modnetapi32.NewProc("NetUserGetInfo") procNtCreateFile = modntdll.NewProc("NtCreateFile") procNtCreateNamedPipeFile = modntdll.NewProc("NtCreateNamedPipeFile") @@ -1223,6 +1225,14 @@ func setEntriesInAcl(countExplicitEntries uint32, explicitEntries *EXPLICIT_ACCE return } +func GetAce(acl *ACL, aceIndex uint32, pAce **ACCESS_ALLOWED_ACE) (ret error) { + r0, _, _ := syscall.Syscall(procGetAce.Addr(), 3, uintptr(unsafe.Pointer(acl)), uintptr(aceIndex), uintptr(unsafe.Pointer(pAce))) + if r0 == 0 { + ret = GetLastError() + } + return +} + func SetKernelObjectSecurity(handle Handle, securityInformation SECURITY_INFORMATION, securityDescriptor *SECURITY_DESCRIPTOR) (err error) { r1, _, e1 := syscall.Syscall(procSetKernelObjectSecurity.Addr(), 3, uintptr(handle), uintptr(securityInformation), uintptr(unsafe.Pointer(securityDescriptor))) if r1 == 0 { @@ -3486,6 +3496,14 @@ func NetGetJoinInformation(server *uint16, name **uint16, bufType *uint32) (nete return } +func NetUserEnum(serverName *uint16, level uint32, filter uint32, buf **byte, prefMaxLen uint32, entriesRead *uint32, totalEntries *uint32, resumeHandle *uint32) (neterr error) { + r0, _, _ := syscall.Syscall9(procNetUserEnum.Addr(), 8, uintptr(unsafe.Pointer(serverName)), uintptr(level), uintptr(filter), uintptr(unsafe.Pointer(buf)), uintptr(prefMaxLen), uintptr(unsafe.Pointer(entriesRead)), uintptr(unsafe.Pointer(totalEntries)), uintptr(unsafe.Pointer(resumeHandle)), 0) + if r0 != 0 { + neterr = syscall.Errno(r0) + } + return +} + func NetUserGetInfo(serverName *uint16, userName *uint16, level uint32, buf **byte) (neterr error) { r0, _, _ := syscall.Syscall6(procNetUserGetInfo.Addr(), 4, uintptr(unsafe.Pointer(serverName)), uintptr(unsafe.Pointer(userName)), uintptr(level), uintptr(unsafe.Pointer(buf)), 0, 0) if r0 != 0 { diff --git a/vendor/modules.txt b/vendor/modules.txt index 7ab202d0..7b43a883 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -31,7 +31,7 @@ github.com/bitrise-io/go-utils/retry github.com/bitrise-io/go-utils/sliceutil github.com/bitrise-io/go-utils/stringutil github.com/bitrise-io/go-utils/ziputil -# github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.20 +# github.com/bitrise-io/go-utils/v2 v2.0.0-alpha.23 ## explicit; go 1.17 github.com/bitrise-io/go-utils/v2/command github.com/bitrise-io/go-utils/v2/env @@ -40,7 +40,7 @@ github.com/bitrise-io/go-utils/v2/log github.com/bitrise-io/go-utils/v2/log/colorstring github.com/bitrise-io/go-utils/v2/pathutil github.com/bitrise-io/go-utils/v2/retryhttp -# github.com/bitrise-io/go-xcode v1.0.19 +# github.com/bitrise-io/go-xcode v1.1.1 ## explicit; go 1.20 github.com/bitrise-io/go-xcode/appleauth github.com/bitrise-io/go-xcode/certificateutil @@ -60,7 +60,7 @@ github.com/bitrise-io/go-xcode/xcodeproject/xcodeproj github.com/bitrise-io/go-xcode/xcodeproject/xcscheme github.com/bitrise-io/go-xcode/xcodeproject/xcworkspace github.com/bitrise-io/go-xcode/xcpretty -# github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.45 +# github.com/bitrise-io/go-xcode/v2 v2.0.0-alpha.47 ## explicit; go 1.20 github.com/bitrise-io/go-xcode/v2/autocodesign github.com/bitrise-io/go-xcode/v2/autocodesign/certdownloader @@ -114,11 +114,11 @@ github.com/pmezard/go-difflib/difflib # github.com/ryanuber/go-glob v1.0.0 ## explicit github.com/ryanuber/go-glob -# github.com/stretchr/objx v0.5.1 -## explicit; go 1.13 -github.com/stretchr/objx -# github.com/stretchr/testify v1.8.4 +# github.com/stretchr/objx v0.5.2 ## explicit; go 1.20 +github.com/stretchr/objx +# github.com/stretchr/testify v1.9.0 +## explicit; go 1.17 github.com/stretchr/testify/assert github.com/stretchr/testify/mock github.com/stretchr/testify/require @@ -126,7 +126,7 @@ github.com/stretchr/testify/require ## explicit; go 1.18 golang.org/x/crypto/pbkdf2 golang.org/x/crypto/ssh/terminal -# golang.org/x/sys v0.20.0 +# golang.org/x/sys v0.22.0 ## explicit; go 1.18 golang.org/x/sys/plan9 golang.org/x/sys/unix