diff --git a/go.mod b/go.mod index 8d494d7..ac1b6fa 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/go-openapi/validate v0.19.12 github.com/golang/mock v1.4.4 github.com/mitchellh/go-homedir v1.1.0 - github.com/oracle/oci-go-sdk/v28 v28.0.0 + github.com/oracle/oci-go-sdk/v48 v48.0.0 github.com/stretchr/testify v1.6.1 golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 golang.org/x/net v0.0.0-20201110031124-69a78807bb2b diff --git a/go.sum b/go.sum index ebc5745..adbc72d 100644 --- a/go.sum +++ b/go.sum @@ -159,8 +159,8 @@ github.com/mitchellh/mapstructure v1.3.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RR github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/oracle/oci-go-sdk/v28 v28.0.0 h1:19QPbl+gCbgU3hFGwOS4hRNpM3A+86Xf9mPLdu/wUlk= -github.com/oracle/oci-go-sdk/v28 v28.0.0/go.mod h1:wpcs8ZqLlnn+SisD7SV959mncC58IZOMKAEM7yUlFPQ= +github.com/oracle/oci-go-sdk/v48 v48.0.0 h1:ux/bkBFIHOPWhcCxx/c67jTIr/TDGJGRKn5rW6zqy1s= +github.com/oracle/oci-go-sdk/v48 v48.0.0/go.mod h1:eCa0yXKSofRr/J5fv8pqnxX72yTG2FkbBkL5vC2RXuQ= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.4.0/go.mod h1:PN7xzY2wHTK0K9p34ErDQMlFxa51Fk0OUruD3k1mMwo= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= diff --git a/provider/oracle/cloudshell_provider.go b/provider/oracle/cloudshell_provider.go index ea9b9f3..3a7f73a 100644 --- a/provider/oracle/cloudshell_provider.go +++ b/provider/oracle/cloudshell_provider.go @@ -2,14 +2,14 @@ package oracle import ( "fmt" - "github.com/oracle/oci-go-sdk/v28/functions" + "github.com/oracle/oci-go-sdk/v48/functions" "io/ioutil" "net/http" "os" "github.com/fnproject/fn_go/provider" - oci "github.com/oracle/oci-go-sdk/v28/common" - "github.com/oracle/oci-go-sdk/v28/common/auth" + oci "github.com/oracle/oci-go-sdk/v48/common" + "github.com/oracle/oci-go-sdk/v48/common/auth" ) const ( @@ -122,12 +122,13 @@ func NewCSProvider(configSource provider.ConfigSource, passphraseSource provider ociClient.Host = apiUrl.String() return &OracleProvider{ - FnApiUrl: apiUrl, - Signer: signer, - Interceptor: interceptor, - DisableCerts: disableCerts, - CompartmentID: compartmentID, - ociClient: ociClient, + FnApiUrl: apiUrl, + Signer: signer, + Interceptor: interceptor, + DisableCerts: disableCerts, + CompartmentID: compartmentID, + ConfigurationProvider: configProvider, + ociClient: ociClient, }, nil } diff --git a/provider/oracle/ip_provider.go b/provider/oracle/ip_provider.go index 4f274ac..7b3a0ae 100644 --- a/provider/oracle/ip_provider.go +++ b/provider/oracle/ip_provider.go @@ -2,13 +2,13 @@ package oracle import ( "fmt" - "github.com/oracle/oci-go-sdk/v28/functions" + "github.com/oracle/oci-go-sdk/v48/functions" "io/ioutil" "net/http" "net/url" - "github.com/oracle/oci-go-sdk/v28/common" - "github.com/oracle/oci-go-sdk/v28/common/auth" + "github.com/oracle/oci-go-sdk/v48/common" + "github.com/oracle/oci-go-sdk/v48/common/auth" "github.com/fnproject/fn_go/provider" ) @@ -68,11 +68,12 @@ func NewIPProvider(configSource provider.ConfigSource, passphraseSource provider } return &OracleProvider{ - FnApiUrl: apiUrl, - Signer: common.DefaultRequestSigner(configProvider), - Interceptor: nil, - DisableCerts: disableCerts, - CompartmentID: compartmentID, - ociClient: ociClient, + FnApiUrl: apiUrl, + Signer: common.DefaultRequestSigner(configProvider), + Interceptor: nil, + DisableCerts: disableCerts, + CompartmentID: compartmentID, + ConfigurationProvider: configProvider, + ociClient: ociClient, }, nil } diff --git a/provider/oracle/oracle_common.go b/provider/oracle/oracle_common.go index ff26363..26a696d 100644 --- a/provider/oracle/oracle_common.go +++ b/provider/oracle/oracle_common.go @@ -4,7 +4,7 @@ import ( "crypto/tls" "fmt" "github.com/fnproject/fn_go/provider/oracle/shim" - "github.com/oracle/oci-go-sdk/v28/functions" + "github.com/oracle/oci-go-sdk/v48/functions" "io/ioutil" "net/http" "net/url" @@ -16,7 +16,7 @@ import ( "github.com/fnproject/fn_go/provider" openapi "github.com/go-openapi/runtime/client" "github.com/go-openapi/strfmt" - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" ) const ( @@ -72,6 +72,9 @@ type OracleProvider struct { // CompartmentID is the ocid of the functions compartment ID for a given function CompartmentID string + // ConfigurationProvider is the OCI configuration provider for signing requests + ConfigurationProvider common.ConfigurationProvider + ociClient functions.FunctionsManagementClient } diff --git a/provider/oracle/shim/apps.go b/provider/oracle/shim/apps.go index 95022a2..21cf17e 100644 --- a/provider/oracle/shim/apps.go +++ b/provider/oracle/shim/apps.go @@ -7,7 +7,7 @@ import ( "github.com/fnproject/fn_go/provider/oracle/shim/client" "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/oracle/oci-go-sdk/v28/functions" + "github.com/oracle/oci-go-sdk/v48/functions" ) const ( diff --git a/provider/oracle/shim/client/client.go b/provider/oracle/shim/client/client.go index 223f97e..88278b9 100644 --- a/provider/oracle/shim/client/client.go +++ b/provider/oracle/shim/client/client.go @@ -2,7 +2,7 @@ package client import ( "context" - "github.com/oracle/oci-go-sdk/v28/functions" + "github.com/oracle/oci-go-sdk/v48/functions" ) // Interface extracted from Go SDK FunctionsManagementClient for mockability diff --git a/provider/oracle/shim/client/client_mock.go b/provider/oracle/shim/client/client_mock.go index e3241a3..2da4f45 100644 --- a/provider/oracle/shim/client/client_mock.go +++ b/provider/oracle/shim/client/client_mock.go @@ -4,8 +4,8 @@ import ( "context" "fmt" "github.com/golang/mock/gomock" - "github.com/oracle/oci-go-sdk/v28/common" - "github.com/oracle/oci-go-sdk/v28/functions" + "github.com/oracle/oci-go-sdk/v48/common" + "github.com/oracle/oci-go-sdk/v48/functions" "time" ) diff --git a/provider/oracle/shim/client/client_mockgen.go b/provider/oracle/shim/client/client_mockgen.go index 56ffaee..3bddde0 100644 --- a/provider/oracle/shim/client/client_mockgen.go +++ b/provider/oracle/shim/client/client_mockgen.go @@ -7,7 +7,7 @@ package client import ( context "context" gomock "github.com/golang/mock/gomock" - functions "github.com/oracle/oci-go-sdk/v28/functions" + functions "github.com/oracle/oci-go-sdk/v48/functions" reflect "reflect" ) diff --git a/provider/oracle/shim/fns.go b/provider/oracle/shim/fns.go index dda6ef3..52b9f4b 100644 --- a/provider/oracle/shim/fns.go +++ b/provider/oracle/shim/fns.go @@ -7,7 +7,7 @@ import ( "github.com/fnproject/fn_go/provider/oracle/shim/client" "github.com/go-openapi/runtime" "github.com/go-openapi/strfmt" - "github.com/oracle/oci-go-sdk/v28/functions" + "github.com/oracle/oci-go-sdk/v48/functions" ) const ( diff --git a/provider/oracle/user_provider.go b/provider/oracle/user_provider.go index aaf8c19..1b00464 100644 --- a/provider/oracle/user_provider.go +++ b/provider/oracle/user_provider.go @@ -5,7 +5,7 @@ import ( "encoding/pem" "errors" "fmt" - "github.com/oracle/oci-go-sdk/v28/functions" + "github.com/oracle/oci-go-sdk/v48/functions" "io/ioutil" "net/http" "net/url" @@ -14,7 +14,7 @@ import ( "github.com/fnproject/fn_go/provider" homedir "github.com/mitchellh/go-homedir" - oci "github.com/oracle/oci-go-sdk/v28/common" + oci "github.com/oracle/oci-go-sdk/v48/common" ) const ( @@ -67,12 +67,13 @@ func NewFromConfig(configSource provider.ConfigSource, passphraseSource provider } return &OracleProvider{ - FnApiUrl: apiUrl, - Signer: oci.DefaultRequestSigner(configProvider), - Interceptor: nil, - DisableCerts: disableCerts, - CompartmentID: compartmentID, - ociClient: ociClient, + FnApiUrl: apiUrl, + Signer: oci.DefaultRequestSigner(configProvider), + Interceptor: nil, + DisableCerts: disableCerts, + CompartmentID: compartmentID, + ConfigurationProvider: configProvider, + ociClient: ociClient, }, nil } diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/retry.go b/vendor/github.com/oracle/oci-go-sdk/v28/common/retry.go deleted file mode 100644 index e5fd47d..0000000 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/retry.go +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. -// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. - -package common - -import ( - "context" - "fmt" - "math/rand" - "runtime" - "time" -) - -const ( - // UnlimitedNumAttemptsValue is the value for indicating unlimited attempts for reaching success - UnlimitedNumAttemptsValue = uint(0) - - // number of characters contained in the generated retry token - generatedRetryTokenLength = 32 -) - -// OCIRetryableRequest represents a request that can be reissued according to the specified policy. -type OCIRetryableRequest interface { - // Any retryable request must implement the OCIRequest interface - OCIRequest - - // Each operation specifies default retry behavior. By passing no arguments to this method, the default retry - // behavior, as determined on a per-operation-basis, will be honored. Variadic retry policy option arguments - // passed to this method will override the default behavior. - RetryPolicy() *RetryPolicy -} - -// OCIOperationResponse represents the output of an OCIOperation, with additional context of error message -// and operation attempt number. -type OCIOperationResponse struct { - // Response from OCI Operation - Response OCIResponse - - // Error from OCI Operation - Error error - - // Operation Attempt Number (one-based) - AttemptNumber uint -} - -// NewOCIOperationResponse assembles an OCI Operation Response object. -func NewOCIOperationResponse(response OCIResponse, err error, attempt uint) OCIOperationResponse { - return OCIOperationResponse{ - Response: response, - Error: err, - AttemptNumber: attempt, - } -} - -// RetryPolicy is the class that holds all relevant information for retrying operations. -type RetryPolicy struct { - // MaximumNumberAttempts is the maximum number of times to retry a request. Zero indicates an unlimited - // number of attempts. - MaximumNumberAttempts uint - - // ShouldRetryOperation inspects the http response, error, and operation attempt number, and - // - returns true if we should retry the operation - // - returns false otherwise - ShouldRetryOperation func(OCIOperationResponse) bool - - // GetNextDuration computes the duration to pause between operation retries. - NextDuration func(OCIOperationResponse) time.Duration -} - -// NoRetryPolicy is a helper method that assembles and returns a return policy that indicates an operation should -// never be retried (the operation is performed exactly once). -func NoRetryPolicy() RetryPolicy { - dontRetryOperation := func(OCIOperationResponse) bool { return false } - zeroNextDuration := func(OCIOperationResponse) time.Duration { return 0 * time.Second } - return NewRetryPolicy(uint(1), dontRetryOperation, zeroNextDuration) -} - -// NewRetryPolicy is a helper method for assembling a Retry Policy object. -func NewRetryPolicy(attempts uint, retryOperation func(OCIOperationResponse) bool, nextDuration func(OCIOperationResponse) time.Duration) RetryPolicy { - return RetryPolicy{ - MaximumNumberAttempts: attempts, - ShouldRetryOperation: retryOperation, - NextDuration: nextDuration, - } -} - -// shouldContinueIssuingRequests returns true if we should continue retrying a request, based on the current attempt -// number and the maximum number of attempts specified, or false otherwise. -func shouldContinueIssuingRequests(current, maximum uint) bool { - return maximum == UnlimitedNumAttemptsValue || current <= maximum -} - -// RetryToken generates a retry token that must be included on any request passed to the Retry method. -func RetryToken() string { - alphanumericChars := []rune("abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") - retryToken := make([]rune, generatedRetryTokenLength) - for i := range retryToken { - retryToken[i] = alphanumericChars[rand.Intn(len(alphanumericChars))] - } - return string(retryToken) -} - -// Retry is a package-level operation that executes the retryable request using the specified operation and retry policy. -func Retry(ctx context.Context, request OCIRetryableRequest, operation OCIOperation, policy RetryPolicy) (OCIResponse, error) { - - type retrierResult struct { - response OCIResponse - err error - } - - var response OCIResponse - var err error - retrierChannel := make(chan retrierResult) - - go func() { - - // Deal with panics more graciously - defer func() { - if r := recover(); r != nil { - stackBuffer := make([]byte, 1024) - bytesWritten := runtime.Stack(stackBuffer, false) - stack := string(stackBuffer[:bytesWritten]) - retrierChannel <- retrierResult{nil, fmt.Errorf("panicked while retrying operation. Panic was: %s\nStack: %s", r, stack)} - } - }() - - // use a one-based counter because it's easier to think about operation retry in terms of attempt numbering - for currentOperationAttempt := uint(1); shouldContinueIssuingRequests(currentOperationAttempt, policy.MaximumNumberAttempts); currentOperationAttempt++ { - Debugln(fmt.Sprintf("operation attempt #%v", currentOperationAttempt)) - response, err = operation(ctx, request) - operationResponse := NewOCIOperationResponse(response, err, currentOperationAttempt) - - if !policy.ShouldRetryOperation(operationResponse) { - // we should NOT retry operation based on response and/or error => return - retrierChannel <- retrierResult{response, err} - return - } - - duration := policy.NextDuration(operationResponse) - //The following condition is kept for backwards compatibility reasons - if deadline, ok := ctx.Deadline(); ok && time.Now().Add(duration).After(deadline) { - // we want to retry the operation, but the policy is telling us to wait for a duration that exceeds - // the specified overall deadline for the operation => instead of waiting for however long that - // time period is and then aborting, abort now and save the cycles - retrierChannel <- retrierResult{response, DeadlineExceededByBackoff} - return - } - Debugln(fmt.Sprintf("waiting %v before retrying operation", duration)) - // sleep before retrying the operation - <-time.After(duration) - } - - retrierChannel <- retrierResult{response, err} - }() - - select { - case <-ctx.Done(): - return response, ctx.Err() - case result := <-retrierChannel: - return result.response, result.err - } -} diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/LICENSE.txt b/vendor/github.com/oracle/oci-go-sdk/v48/LICENSE.txt similarity index 100% rename from vendor/github.com/oracle/oci-go-sdk/v28/LICENSE.txt rename to vendor/github.com/oracle/oci-go-sdk/v48/LICENSE.txt diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/NOTICE.txt b/vendor/github.com/oracle/oci-go-sdk/v48/NOTICE.txt similarity index 100% rename from vendor/github.com/oracle/oci-go-sdk/v28/NOTICE.txt rename to vendor/github.com/oracle/oci-go-sdk/v48/NOTICE.txt diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/certificate_retriever.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/certificate_retriever.go similarity index 98% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/auth/certificate_retriever.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/auth/certificate_retriever.go index fee83c2..e8f09d8 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/certificate_retriever.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/certificate_retriever.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package auth @@ -9,7 +9,7 @@ import ( "crypto/x509" "encoding/pem" "fmt" - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "sync" ) diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/configuration.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/configuration.go similarity index 97% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/auth/configuration.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/auth/configuration.go index f80fdfb..9a0cd3d 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/configuration.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/configuration.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package auth @@ -6,7 +6,7 @@ package auth import ( "crypto/rsa" "fmt" - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" ) type instancePrincipalConfigurationProvider struct { diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/dispatcher_modifier.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/dispatcher_modifier.go similarity index 93% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/auth/dispatcher_modifier.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/auth/dispatcher_modifier.go index 80b3003..346fb0c 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/dispatcher_modifier.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/dispatcher_modifier.go @@ -1,9 +1,9 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package auth -import "github.com/oracle/oci-go-sdk/v28/common" +import "github.com/oracle/oci-go-sdk/v48/common" //dispatcherModifier gives ability to modify a HTTPRequestDispatcher before use. type dispatcherModifier struct { diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/federation_client.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/federation_client.go similarity index 99% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/auth/federation_client.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/auth/federation_client.go index d8ce52d..721800b 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/federation_client.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/federation_client.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Package auth provides supporting functions and structs for authentication @@ -12,7 +12,7 @@ import ( "encoding/pem" "errors" "fmt" - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "io/ioutil" "net/http" "os" diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/instance_principal_delegation_token_provider.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/instance_principal_delegation_token_provider.go similarity index 96% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/auth/instance_principal_delegation_token_provider.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/auth/instance_principal_delegation_token_provider.go index b359696..bda0b7e 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/instance_principal_delegation_token_provider.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/instance_principal_delegation_token_provider.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package auth @@ -6,7 +6,7 @@ package auth import ( "crypto/rsa" "fmt" - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" ) type instancePrincipalDelegationTokenConfigurationProvider struct { diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/instance_principal_key_provider.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/instance_principal_key_provider.go similarity index 90% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/auth/instance_principal_key_provider.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/auth/instance_principal_key_provider.go index d2635e8..5043557 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/instance_principal_key_provider.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/instance_principal_key_provider.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package auth @@ -7,9 +7,11 @@ import ( "bytes" "crypto/rsa" "fmt" - "github.com/oracle/oci-go-sdk/v28/common" "net/http" "strings" + "time" + + "github.com/oracle/oci-go-sdk/v48/common" ) const ( @@ -94,15 +96,21 @@ func newInstancePrincipalKeyProvider(modifier func(common.HTTPRequestDispatcher) func getRegionForFederationClient(dispatcher common.HTTPRequestDispatcher, url string) (r common.Region, err error) { var body bytes.Buffer var statusCode int - if body, statusCode, err = httpGet(dispatcher, url); err != nil { + MaxRetriesFederationClient := 3 + for currTry := 0; currTry < MaxRetriesFederationClient; currTry++ { + body, statusCode, err = httpGet(dispatcher, url) + if err == nil && statusCode == 200 { + return common.StringToRegion(body.String()), nil + } + common.Logf("Error in getting region from url: %s, Status code: %v, Error: %s", url, statusCode, err.Error()) if statusCode == 404 && strings.Compare(url, metadataBaseURL+regionPath) == 0 { - common.Logf("Falling back to http://169.254.169.254/opc/v1 to try again...\n") + common.Logf("Falling back to http://169.254.169.254/opc/v1 to try again...") updateX509CertRetrieverURLParas(metadataFallbackURL) - return getRegionForFederationClient(dispatcher, regionURL) + url = regionURL } - return + time.Sleep(1 * time.Second) } - return common.StringToRegion(body.String()), nil + return } func updateX509CertRetrieverURLParas(baseURL string) { diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/jwt.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/jwt.go similarity index 94% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/auth/jwt.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/auth/jwt.go index 9c0cc59..badcf83 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/jwt.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/jwt.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package auth @@ -8,7 +8,7 @@ import ( "encoding/base64" "encoding/json" "fmt" - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "strings" "time" ) diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/resouce_principal_key_provider.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/resouce_principal_key_provider.go similarity index 98% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/auth/resouce_principal_key_provider.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/auth/resouce_principal_key_provider.go index f85d7c0..9170b18 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/resouce_principal_key_provider.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/resouce_principal_key_provider.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package auth @@ -7,7 +7,7 @@ import ( "crypto/rsa" "errors" "fmt" - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "os" "path" ) diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/resource_principal_token_path_provider.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/resource_principal_token_path_provider.go similarity index 97% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/auth/resource_principal_token_path_provider.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/auth/resource_principal_token_path_provider.go index 1779461..5bc58cc 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/resource_principal_token_path_provider.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/resource_principal_token_path_provider.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package auth @@ -10,7 +10,7 @@ import ( ) const ( - imdsPathTemplate = "/20190101/resourcePrincipalToken/{id}" + imdsPathTemplate = "/20180711/resourcePrincipalToken/{id}" instanceIDURL = `http://169.254.169.254/opc/v2/instance/id` //ResourcePrincipalTokenPath path for retrieving the Resource Principal Token diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/resource_principals_v1.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/resource_principals_v1.go similarity index 99% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/auth/resource_principals_v1.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/auth/resource_principals_v1.go index 396d273..c4c8651 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/resource_principals_v1.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/resource_principals_v1.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package auth @@ -7,7 +7,7 @@ import ( "context" "crypto/rsa" "fmt" - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" "net/url" diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/utils.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/utils.go similarity index 96% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/auth/utils.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/auth/utils.go index 2a91a09..d82f97b 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/auth/utils.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/auth/utils.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package auth @@ -8,7 +8,7 @@ import ( "crypto/sha1" "crypto/x509" "fmt" - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" "net/http/httputil" "strings" diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/client.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/client.go similarity index 81% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/client.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/client.go index 9bc1a2d..1fc29b9 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/client.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/client.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Package common provides supporting functions and structs used by service packages @@ -11,14 +11,17 @@ import ( "io" "io/ioutil" "math/rand" + "net" "net/http" "net/http/httputil" "net/url" "os" "os/user" "path" + "reflect" "runtime" "strings" + "sync" "sync/atomic" "time" ) @@ -39,6 +42,9 @@ const ( // requestHeaderContentType The key for passing a header to indicate Content Type requestHeaderContentType = "Content-Type" + // requestHeaderExpect The key for passing a header to indicate Expect/100-Continue + requestHeaderExpect = "Expect" + // requestHeaderDate The key for passing a header to indicate Date requestHeaderDate = "Date" @@ -70,6 +76,7 @@ const ( defaultScheme = "https" defaultSDKMarker = "Oracle-GoSDK" defaultUserAgentTemplate = "%s/%s (%s/%s; go/%s)" //SDK/SDKVersion (OS/OSVersion; Lang/LangVersion) + // http.Client.Timeout includes Dial, TLSHandshake, Request, Response header and body defaultTimeout = 60 * time.Second defaultConfigFileName = "config" defaultConfigDirName = ".oci" @@ -126,7 +133,7 @@ func (client *BaseClient) RetryPolicy() *RetryPolicy { return client.Configuration.RetryPolicy } -// Endpoint returns the enpoint configured for client +// Endpoint returns the endpoint configured for client func (client *BaseClient) Endpoint() string { host := client.Host if !strings.Contains(host, "http") && @@ -138,6 +145,10 @@ func (client *BaseClient) Endpoint() string { func defaultUserAgent() string { userAgent := fmt.Sprintf(defaultUserAgentTemplate, defaultSDKMarker, Version(), runtime.GOOS, runtime.GOARCH, runtime.Version()) + appendUA := os.Getenv("OCI_SDK_APPEND_USER_AGENT") + if appendUA != "" { + userAgent = fmt.Sprintf("%s %s", userAgent, appendUA) + } return userAgent } @@ -159,8 +170,30 @@ func newBaseClient(signer HTTPRequestSigner, dispatcher HTTPRequestDispatcher) B } func defaultHTTPDispatcher() http.Client { - httpClient := http.Client{ - Timeout: defaultTimeout, + var httpClient http.Client + + if isExpectHeaderDisabled := IsEnvVarFalse(UsingExpectHeaderEnvVar); !isExpectHeaderDisabled { + var tp http.RoundTripper = &http.Transport{ + Proxy: http.ProxyFromEnvironment, + DialContext: (&net.Dialer{ + Timeout: 30 * time.Second, + KeepAlive: 30 * time.Second, + DualStack: true, + }).DialContext, + ForceAttemptHTTP2: true, + MaxIdleConns: 100, + IdleConnTimeout: 90 * time.Second, + TLSHandshakeTimeout: 10 * time.Second, + ExpectContinueTimeout: 3 * time.Second, + } + httpClient = http.Client{ + Transport: tp, + Timeout: defaultTimeout, + } + } else { + httpClient = http.Client{ + Timeout: defaultTimeout, + } } return httpClient } @@ -395,7 +428,7 @@ func checkBodyLengthExceedLimit(contentLength int64) bool { // OCIRequest is any request made to an OCI service. type OCIRequest interface { // HTTPRequest assembles an HTTP request. - HTTPRequest(method, path string) (http.Request, error) + HTTPRequest(method, path string, binaryRequestBody *OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) } // RequestMetadata is metadata about an OCIRequest. This structure represents the behavior exhibited by the SDK when @@ -406,6 +439,76 @@ type RequestMetadata struct { RetryPolicy *RetryPolicy } +// OCIReadSeekCloser is a thread-safe io.ReadSeekCloser to prevent racing with retrying binary requests +type OCIReadSeekCloser struct { + rc io.ReadCloser + lock sync.Mutex + isClosed bool +} + +// NewOCIReadSeekCloser constructs OCIReadSeekCloser, the only input is binary request body +func NewOCIReadSeekCloser(rc io.ReadCloser) *OCIReadSeekCloser { + rsc := OCIReadSeekCloser{} + rsc.rc = rc + return &rsc +} + +// Seek is a thread-safe operation, it implements io.seek() interface, if the original request body implements io.seek() +// interface, or implements "well-known" data type like os.File, io.SectionReader, or wrapped by ioutil.NopCloser can be supported +func (rsc *OCIReadSeekCloser) Seek(offset int64, whence int) (int64, error) { + rsc.lock.Lock() + defer rsc.lock.Unlock() + + if _, ok := rsc.rc.(io.Seeker); ok { + return rsc.rc.(io.Seeker).Seek(offset, whence) + } + // once the binary request body is wrapped with ioutil.NopCloser: + if reflect.TypeOf(rsc.rc) == reflect.TypeOf(ioutil.NopCloser(nil)) { + unwrappedInterface := reflect.ValueOf(rsc.rc).Field(0).Interface() + if _, ok := unwrappedInterface.(io.Seeker); ok { + return unwrappedInterface.(io.Seeker).Seek(offset, whence) + } + } + return 0, fmt.Errorf("current binary request body type is not seekable, if want to use retry feature, please make sure the request body implements seek() method") +} + +// Close is a thread-safe operation, it closes the instance of the OCIReadSeekCloser's access to the underlying io.ReadCloser. +func (rsc *OCIReadSeekCloser) Close() error { + rsc.lock.Lock() + defer rsc.lock.Unlock() + rsc.isClosed = true + return nil +} + +// Read is a thread-safe operation, it implements io.Read() interface +func (rsc *OCIReadSeekCloser) Read(p []byte) (n int, err error) { + rsc.lock.Lock() + defer rsc.lock.Unlock() + + if rsc.isClosed { + return 0, io.EOF + } + + return rsc.rc.Read(p) +} + +// Seekable is used for check if the binary request body can be seek or no +func (rsc *OCIReadSeekCloser) Seekable() bool { + if rsc == nil { + return false + } + if _, ok := rsc.rc.(io.Seeker); ok { + return true + } + // once the binary request body is wrapped with ioutil.NopCloser: + if reflect.TypeOf(rsc.rc) == reflect.TypeOf(ioutil.NopCloser(nil)) { + if _, ok := reflect.ValueOf(rsc.rc).Field(0).Interface().(io.Seeker); ok { + return true + } + } + return false +} + // OCIResponse is the response from issuing a request to an OCI service. type OCIResponse interface { // HTTPResponse returns the raw HTTP response. @@ -413,7 +516,7 @@ type OCIResponse interface { } // OCIOperation is the generalization of a request-response cycle undergone by an OCI service. -type OCIOperation func(context.Context, OCIRequest) (OCIResponse, error) +type OCIOperation func(context.Context, OCIRequest, *OCIReadSeekCloser, map[string]string) (OCIResponse, error) //ClientCallDetails a set of settings used by the a single Call operation of the http Client type ClientCallDetails struct { @@ -425,10 +528,10 @@ func (client BaseClient) Call(ctx context.Context, request *http.Request) (respo return client.CallWithDetails(ctx, request, ClientCallDetails{Signer: client.Signer}) } -// CallWithDetails executes the http request, the given context using details specified in the paremeters, this function +// CallWithDetails executes the http request, the given context using details specified in the parameters, this function // provides a way to override some settings present in the client func (client BaseClient) CallWithDetails(ctx context.Context, request *http.Request, details ClientCallDetails) (response *http.Response, err error) { - Debugln("Atempting to call downstream service") + Debugln("Attempting to call downstream service") request = request.WithContext(ctx) err = client.prepareRequest(request) diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/common.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/common.go similarity index 73% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/common.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/common.go index bccac05..d1f296a 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/common.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/common.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package common @@ -21,75 +21,6 @@ type Region string const ( instanceMetadataRegionInfoURLV2 = "http://169.254.169.254/opc/v2/instance/regionInfo" - //RegionSEA region SEA - RegionSEA Region = "sea" - //RegionCAToronto1 region for Toronto - RegionCAToronto1 Region = "ca-toronto-1" - //RegionCAMontreal1 region for Montreal - RegionCAMontreal1 Region = "ca-montreal-1" - //RegionPHX region PHX - RegionPHX Region = "us-phoenix-1" - //RegionIAD region IAD - RegionIAD Region = "us-ashburn-1" - //RegionSJC1 region SJC - RegionSJC1 Region = "us-sanjose-1" - - //RegionFRA region FRA - RegionFRA Region = "eu-frankfurt-1" - - //RegionUKCardiff1 region for Cardiff - RegionUKCardiff1 Region = "uk-cardiff-1" - //RegionLHR region LHR - RegionLHR Region = "uk-london-1" - - //RegionAPTokyo1 region for Tokyo - RegionAPTokyo1 Region = "ap-tokyo-1" - //RegionAPOsaka1 region for Osaka - RegionAPOsaka1 Region = "ap-osaka-1" - //RegionAPChiyoda1 region for Chiyoda - RegionAPChiyoda1 Region = "ap-chiyoda-1" - //RegionAPSeoul1 region for Seoul - RegionAPSeoul1 Region = "ap-seoul-1" - //RegionAPChuncheon1 region for Chuncheon - RegionAPChuncheon1 Region = "ap-chuncheon-1" - //RegionAPMumbai1 region for Mumbai - RegionAPMumbai1 Region = "ap-mumbai-1" - //RegionAPHyderabad1 region for Hyderabad - RegionAPHyderabad1 Region = "ap-hyderabad-1" - //RegionAPMelbourne1 region for Melbourne - RegionAPMelbourne1 Region = "ap-melbourne-1" - //RegionAPSydney1 region for Sydney - RegionAPSydney1 Region = "ap-sydney-1" - - //RegionMEJeddah1 region for Jeddah - RegionMEJeddah1 Region = "me-jeddah-1" - //RegionMEDubai1 region for Dubai - RegionMEDubai1 Region = "me-dubai-1" - - //RegionEUZurich1 region for Zurich - RegionEUZurich1 Region = "eu-zurich-1" - //RegionEUAmsterdam1 region for Amsterdam - RegionEUAmsterdam1 Region = "eu-amsterdam-1" - - //RegionSASaopaulo1 region for Sao Paulo - RegionSASaopaulo1 Region = "sa-saopaulo-1" - - //RegionUSLangley1 region for Langley - RegionUSLangley1 Region = "us-langley-1" - //RegionUSLuke1 region for Luke - RegionUSLuke1 Region = "us-luke-1" - - //RegionUSGovAshburn1 gov region Ashburn - RegionUSGovAshburn1 Region = "us-gov-ashburn-1" - //RegionUSGovChicago1 gov region Chicago - RegionUSGovChicago1 Region = "us-gov-chicago-1" - //RegionUSGovPhoenix1 region for Phoenix - RegionUSGovPhoenix1 Region = "us-gov-phoenix-1" - //RegionUKGovLondon1 gov region London - RegionUKGovLondon1 Region = "uk-gov-london-1" - //RegionUKGovCardiff1 gov region Cardiff - RegionUKGovCardiff1 Region = "uk-gov-cardiff-1" - // Region Metadata Configuration File regionMetadataCfgDirName = ".oci" regionMetadataCfgFileName = "regions-config.json" @@ -104,83 +35,6 @@ const ( regionKeyPropertyName = "regionKey" // e.g. "SYD" ) -var shortNameRegion = map[string]Region{ - "sea": RegionSEA, - "phx": RegionPHX, - "iad": RegionIAD, - "fra": RegionFRA, - "lhr": RegionLHR, - "cwl": RegionUKCardiff1, - "ams": RegionEUAmsterdam1, - "zrh": RegionEUZurich1, - "mel": RegionAPMelbourne1, - "bom": RegionAPMumbai1, - "hyd": RegionAPHyderabad1, - "icn": RegionAPSeoul1, - "yny": RegionAPChuncheon1, - "nrt": RegionAPTokyo1, - "kix": RegionAPOsaka1, - "nja": RegionAPChiyoda1, - "jed": RegionMEJeddah1, - "dxb": RegionMEDubai1, - "syd": RegionAPSydney1, - "yul": RegionCAMontreal1, - "yyz": RegionCAToronto1, - "sjc": RegionSJC1, - "gru": RegionSASaopaulo1, - "ltn": RegionUKGovLondon1, - "brs": RegionUKGovCardiff1, -} - -var realm = map[string]string{ - "oc1": "oraclecloud.com", - "oc2": "oraclegovcloud.com", - "oc3": "oraclegovcloud.com", - "oc4": "oraclegovcloud.uk", - "oc8": "oraclecloud8.com", -} - -var regionRealm = map[Region]string{ - RegionPHX: "oc1", - RegionIAD: "oc1", - RegionFRA: "oc1", - RegionLHR: "oc1", - RegionSJC1: "oc1", - - RegionUKCardiff1: "oc1", - - RegionCAToronto1: "oc1", - RegionCAMontreal1: "oc1", - - RegionAPTokyo1: "oc1", - RegionAPOsaka1: "oc1", - RegionAPSeoul1: "oc1", - RegionAPChuncheon1: "oc1", - RegionAPSydney1: "oc1", - RegionAPMumbai1: "oc1", - RegionAPHyderabad1: "oc1", - RegionAPMelbourne1: "oc1", - - RegionMEJeddah1: "oc1", - RegionMEDubai1: "oc1", - - RegionEUZurich1: "oc1", - RegionEUAmsterdam1: "oc1", - - RegionSASaopaulo1: "oc1", - - RegionUSLangley1: "oc2", - RegionUSLuke1: "oc2", - - RegionUSGovAshburn1: "oc3", - RegionUSGovChicago1: "oc3", - RegionUSGovPhoenix1: "oc3", - RegionUKGovCardiff1: "oc4", - RegionUKGovLondon1: "oc4", - - RegionAPChiyoda1: "oc8", -} - // External region metadata info flag, used to control adding these metadata region info only once. var readCfgFile, readEnvVar, visitIMDS bool = true, true, false @@ -221,6 +75,15 @@ func (region Region) secondLevelDomain() string { return realm["oc1"] } +// RealmID is used for getting realmID from region, if no region found, directly throw error +func (region Region) RealmID() (string, error) { + if realmID, ok := regionRealm[region]; ok { + return realmID, nil + } + + return "", fmt.Errorf("cannot find realm for region : %s", region) +} + //StringToRegion convert a string to Region type func StringToRegion(stringRegion string) (r Region) { regionStr := strings.ToLower(stringRegion) diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/configuration.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/configuration.go similarity index 99% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/configuration.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/configuration.go index 80aa2fc..90019f7 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/configuration.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/configuration.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package common diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/errors.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/errors.go similarity index 78% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/errors.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/errors.go index 46f27c9..7ae9834 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/errors.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/errors.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package common @@ -7,6 +7,7 @@ import ( "encoding/json" "fmt" "io/ioutil" + "net" "net/http" ) @@ -97,3 +98,24 @@ func (deadlineExceededByBackoffError) Error() string { // force the user to wait past the request deadline before re-issuing a request. This enables us to exit early, since // we cannot succeed based on the configured retry policy. var DeadlineExceededByBackoff error = deadlineExceededByBackoffError{} + +// NonSeekableRequestRetryFailure is the error returned when the request is with binary request body, and is configured +// retry, but the request body is not retryable +type NonSeekableRequestRetryFailure struct { + err error +} + +func (ne NonSeekableRequestRetryFailure) Error() string { + if ne.err == nil { + return fmt.Sprintf("Unable to perform Retry on this request body type, which did not implement seek() interface") + } + return fmt.Sprintf("%s. Unable to perform Retry on this request body type, which did not implement seek() interface", ne.err.Error()) +} + +// IsNetworkError validatas if an error is a net.Error and check if it's temporary or timeout +func IsNetworkError(err error) bool { + if r, ok := err.(net.Error); ok && (r.Temporary() || r.Timeout()) { + return true + } + return false +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/helpers.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/helpers.go similarity index 95% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/helpers.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/helpers.go index 2ae0886..952a2a2 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/helpers.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/helpers.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package common @@ -10,6 +10,7 @@ import ( "encoding/pem" "fmt" "net/textproto" + "os" "reflect" "strconv" "strings" @@ -282,3 +283,11 @@ func makeACopy(original []string) []string { copy(tmp, original) return tmp } + +// IsEnvVarFalse is used for checking if an environment variable is explicitly set to false, otherwise would set it true by default +func IsEnvVarFalse(envVarKey string) bool { + if val, existed := os.LookupEnv(envVarKey); existed && strings.ToLower(val) == "false" { + return true + } + return false +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/http.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/http.go similarity index 89% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/http.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/http.go index 76af45f..a88e46f 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/http.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/http.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package common @@ -11,6 +11,7 @@ import ( "io/ioutil" "net/http" "net/url" + "os" "reflect" "regexp" "strconv" @@ -18,6 +19,11 @@ import ( "time" ) +const ( + //UsingExpectHeaderEnvVar is the key to determine whether expect 100-continue is enabled or not + UsingExpectHeaderEnvVar = "OCI_GOSDK_USING_EXPECT_HEADER" +) + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //Request Marshaling @@ -75,7 +81,7 @@ func addBinaryBody(request *http.Request, value reflect.Value, field reflect.Str } if isMandatory && !ok { - e = fmt.Errorf("body of the request is mandatory and needs to be an io.ReadCloser interface. Can not marshal body of binary request") + e = fmt.Errorf("body of the request is mandatory and needs to be an io.ReadCloser interface. Can not marshal body of binary request") return } @@ -249,7 +255,7 @@ func removeNilFieldsInJSONWithTaggedStruct(rawJSON []byte, value reflect.Value) return json.Marshal(fixedMap) } -func addToBody(request *http.Request, value reflect.Value, field reflect.StructField) (e error) { +func addToBody(request *http.Request, value reflect.Value, field reflect.StructField, binaryBodySpecified *bool) (e error) { Debugln("Marshaling to body from field:", field.Name) if request.Body != nil { Logf("The body of the request is already set. Structure: %s will overwrite it\n", field.Name) @@ -258,6 +264,7 @@ func addToBody(request *http.Request, value reflect.Value, field reflect.StructF encoding := tag.Get("encoding") if encoding == "binary" { + *binaryBodySpecified = true return addBinaryBody(request, value, field) } @@ -288,6 +295,43 @@ func addToBody(request *http.Request, value reflect.Value, field reflect.StructF return } +func checkBinaryBodyLength(request *http.Request) (contentLen int64, err error) { + if reflect.TypeOf(request.Body) == reflect.TypeOf(ioutil.NopCloser(nil)) { + ioReader := reflect.ValueOf(request.Body).Field(0).Interface().(io.Reader) + switch t := ioReader.(type) { + case *bytes.Reader: + return int64(t.Len()), nil + case *bytes.Buffer: + return int64(t.Len()), nil + case *strings.Reader: + return int64(t.Len()), nil + default: + return getNormalBinaryBodyLength(request) + } + } + if reflect.TypeOf(request.Body) == reflect.TypeOf((*os.File)(nil)) { + fi, err := (request.Body.(*os.File)).Stat() + if err != nil { + return contentLen, err + } + return fi.Size(), nil + } + return getNormalBinaryBodyLength(request) +} + +func getNormalBinaryBodyLength(request *http.Request) (contentLen int64, err error) { + dumpRequestBody := ioutil.NopCloser(bytes.NewBuffer(nil)) + if dumpRequestBody, request.Body, err = drainBody(request.Body); err != nil { + dumpRequestBody = ioutil.NopCloser(bytes.NewBuffer(nil)) + return contentLen, err + } + contentBody, err := ioutil.ReadAll(dumpRequestBody) + if err != nil { + return contentLen, err + } + return int64(len(contentBody)), nil +} + func addToQuery(request *http.Request, value reflect.Value, field reflect.StructField) (e error) { Debugln("Marshaling to query from field: ", field.Name) if request.URL == nil { @@ -404,7 +448,7 @@ func addToPath(request *http.Request, value reflect.Value, field reflect.StructF return } -func setWellKnownHeaders(request *http.Request, headerName, headerValue string) (e error) { +func setWellKnownHeaders(request *http.Request, headerName, headerValue string, contentLenSpecified *bool) (e error) { switch strings.ToLower(headerName) { case "content-length": var len int @@ -413,11 +457,12 @@ func setWellKnownHeaders(request *http.Request, headerName, headerValue string) return } request.ContentLength = int64(len) + *contentLenSpecified = true } return nil } -func addToHeader(request *http.Request, value reflect.Value, field reflect.StructField) (e error) { +func addToHeader(request *http.Request, value reflect.Value, field reflect.StructField, contentLenSpecified *bool) (e error) { Debugln("Marshaling to header from field: ", field.Name) if request.Header == nil { request.Header = http.Header{} @@ -448,7 +493,7 @@ func addToHeader(request *http.Request, value reflect.Value, field reflect.Struc return } - if e = setWellKnownHeaders(request, headerName, headerValue); e != nil { + if e = setWellKnownHeaders(request, headerName, headerValue, contentLenSpecified); e != nil { return } @@ -529,6 +574,8 @@ func checkForValidRequestStruct(s interface{}) (*reflect.Value, error) { // nested structs are followed recursively depth-first. func structToRequestPart(request *http.Request, val reflect.Value) (err error) { typ := val.Type() + contentLenSpecified := false + binaryBodySpecified := false for i := 0; i < typ.NumField(); i++ { if err != nil { return @@ -544,7 +591,7 @@ func structToRequestPart(request *http.Request, val reflect.Value) (err error) { tag := sf.Tag.Get("contributesTo") switch tag { case "header": - err = addToHeader(request, sv, sf) + err = addToHeader(request, sv, sf, &contentLenSpecified) case "header-collection": err = addToHeaderCollection(request, sv, sf) case "path": @@ -552,7 +599,7 @@ func structToRequestPart(request *http.Request, val reflect.Value) (err error) { case "query": err = addToQuery(request, sv, sf) case "body": - err = addToBody(request, sv, sf) + err = addToBody(request, sv, sf, &binaryBodySpecified) case "": Debugln(sf.Name, " does not contain contributes tag. Skipping.") default: @@ -560,16 +607,24 @@ func structToRequestPart(request *http.Request, val reflect.Value) (err error) { } } - //If headers are and the content type was not set, we default to application/json - if request.Header != nil && request.Header.Get(requestHeaderContentType) == "" { - request.Header.Set(requestHeaderContentType, "application/json") + // if content-length is not specified but with binary body, calculate the content length according to request body + if !contentLenSpecified && binaryBodySpecified && request.Body != nil && request.Body != http.NoBody { + contentLen, err := checkBinaryBodyLength(request) + if err == nil { + request.Header.Set(requestHeaderContentLength, strconv.FormatInt(contentLen, 10)) + request.ContentLength = contentLen + } } //If content length is zero, to avoid sending transfer-coding: chunked header, need to explicitly set the body to nil/Nobody. if request.Header != nil && request.Body != nil && request.Body != http.NoBody && - parseContentLength(request.Header.Get("Content-Length")) == 0 { + parseContentLength(request.Header.Get(requestHeaderContentLength)) == 0 { request.Body = http.NoBody } + //If headers are and the content type was not set, we default to application/json + if request.Header != nil && request.Header.Get(requestHeaderContentType) == "" { + request.Header.Set(requestHeaderContentType, "application/json") + } return } @@ -621,6 +676,30 @@ func MakeDefaultHTTPRequest(method, path string) (httpRequest http.Request) { func MakeDefaultHTTPRequestWithTaggedStruct(method, path string, requestStruct interface{}) (httpRequest http.Request, err error) { httpRequest = MakeDefaultHTTPRequest(method, path) err = HTTPRequestMarshaller(requestStruct, &httpRequest) + if err != nil { + return + } + + return +} + +// MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders creates an http request from an struct with tagged fields, see HTTPRequestMarshaller +// for more information +func MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path string, requestStruct interface{}, extraHeaders map[string]string) (httpRequest http.Request, err error) { + httpRequest, err = MakeDefaultHTTPRequestWithTaggedStruct(method, path, requestStruct) + for key, val := range extraHeaders { + httpRequest.Header.Set(key, val) + } + return +} + +// UpdateRequestBinaryBody updates the http request's body once it is binary request and the request body is seekable +// if the content length is zero, no need to update request body(since it's already been set to http.Nody) +func UpdateRequestBinaryBody(httpRequest *http.Request, rsc *OCIReadSeekCloser) { + if parseContentLength(httpRequest.Header.Get(requestHeaderContentLength)) == 0 { + return + } + httpRequest.Body = rsc return } @@ -822,9 +901,9 @@ func valueFromJSONBody(response *http.Response, value *reflect.Value, unmarshale } func addFromBody(response *http.Response, value *reflect.Value, field reflect.StructField, unmarshaler PolymorphicJSONUnmarshaler) (err error) { - Debugln("Unmarshaling from body to field: ", field.Name) + Debugln("Unmarshalling from body to field: ", field.Name) if response.Body == nil { - Debugln("Unmarshaling body skipped due to nil body content for field: ", field.Name) + Debugln("Unmarshalling body skipped due to nil body content for field: ", field.Name) return nil } diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/http_signer.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/http_signer.go similarity index 99% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/http_signer.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/http_signer.go index 573bdff..f678e17 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/http_signer.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/http_signer.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package common diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/log.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/log.go similarity index 99% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/log.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/log.go index 768be44..b9578fa 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/log.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/log.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. package common diff --git a/vendor/github.com/oracle/oci-go-sdk/v48/common/regions.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/regions.go new file mode 100644 index 0000000..c1539c1 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/regions.go @@ -0,0 +1,160 @@ +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. + +package common + +const ( + //RegionSEA region SEA + RegionSEA Region = "sea" + //RegionCAToronto1 region for Toronto + RegionCAToronto1 Region = "ca-toronto-1" + //RegionCAMontreal1 region for Montreal + RegionCAMontreal1 Region = "ca-montreal-1" + //RegionPHX region PHX + RegionPHX Region = "us-phoenix-1" + //RegionIAD region IAD + RegionIAD Region = "us-ashburn-1" + //RegionSJC1 region SJC + RegionSJC1 Region = "us-sanjose-1" + + //RegionFRA region FRA + RegionFRA Region = "eu-frankfurt-1" + + //RegionUKCardiff1 region for Cardiff + RegionUKCardiff1 Region = "uk-cardiff-1" + //RegionLHR region LHR + RegionLHR Region = "uk-london-1" + + //RegionAPTokyo1 region for Tokyo + RegionAPTokyo1 Region = "ap-tokyo-1" + //RegionAPOsaka1 region for Osaka + RegionAPOsaka1 Region = "ap-osaka-1" + //RegionAPChiyoda1 region for Chiyoda + RegionAPChiyoda1 Region = "ap-chiyoda-1" + //RegionAPSeoul1 region for Seoul + RegionAPSeoul1 Region = "ap-seoul-1" + //RegionAPChuncheon1 region for Chuncheon + RegionAPChuncheon1 Region = "ap-chuncheon-1" + //RegionAPMumbai1 region for Mumbai + RegionAPMumbai1 Region = "ap-mumbai-1" + //RegionAPHyderabad1 region for Hyderabad + RegionAPHyderabad1 Region = "ap-hyderabad-1" + //RegionAPMelbourne1 region for Melbourne + RegionAPMelbourne1 Region = "ap-melbourne-1" + //RegionAPSydney1 region for Sydney + RegionAPSydney1 Region = "ap-sydney-1" + + //RegionMEJeddah1 region for Jeddah + RegionMEJeddah1 Region = "me-jeddah-1" + //RegionMEDubai1 region for Dubai + RegionMEDubai1 Region = "me-dubai-1" + + //RegionEUZurich1 region for Zurich + RegionEUZurich1 Region = "eu-zurich-1" + //RegionEUAmsterdam1 region for Amsterdam + RegionEUAmsterdam1 Region = "eu-amsterdam-1" + + //RegionSASaopaulo1 region for Sao Paulo + RegionSASaopaulo1 Region = "sa-saopaulo-1" + //RegionSASantiago1 region for santiago + RegionSASantiago1 Region = "sa-santiago-1" + //RegionSAVinhedo1 region for vinhedo + RegionSAVinhedo1 Region = "sa-vinhedo-1" + + //RegionUSLangley1 region for Langley + RegionUSLangley1 Region = "us-langley-1" + //RegionUSLuke1 region for Luke + RegionUSLuke1 Region = "us-luke-1" + + //RegionUSGovAshburn1 gov region Ashburn + RegionUSGovAshburn1 Region = "us-gov-ashburn-1" + //RegionUSGovChicago1 gov region Chicago + RegionUSGovChicago1 Region = "us-gov-chicago-1" + //RegionUSGovPhoenix1 region for Phoenix + RegionUSGovPhoenix1 Region = "us-gov-phoenix-1" + //RegionUKGovLondon1 gov region London + RegionUKGovLondon1 Region = "uk-gov-london-1" + //RegionUKGovCardiff1 gov region Cardiff + RegionUKGovCardiff1 Region = "uk-gov-cardiff-1" +) + +var shortNameRegion = map[string]Region{ + "sea": RegionSEA, + "phx": RegionPHX, + "iad": RegionIAD, + "fra": RegionFRA, + "lhr": RegionLHR, + "cwl": RegionUKCardiff1, + "ams": RegionEUAmsterdam1, + "zrh": RegionEUZurich1, + "mel": RegionAPMelbourne1, + "bom": RegionAPMumbai1, + "hyd": RegionAPHyderabad1, + "icn": RegionAPSeoul1, + "yny": RegionAPChuncheon1, + "nrt": RegionAPTokyo1, + "kix": RegionAPOsaka1, + "nja": RegionAPChiyoda1, + "jed": RegionMEJeddah1, + "dxb": RegionMEDubai1, + "syd": RegionAPSydney1, + "yul": RegionCAMontreal1, + "yyz": RegionCAToronto1, + "sjc": RegionSJC1, + "gru": RegionSASaopaulo1, + "scl": RegionSASantiago1, + "vcp": RegionSAVinhedo1, + "ltn": RegionUKGovLondon1, + "brs": RegionUKGovCardiff1, +} + +var realm = map[string]string{ + "oc1": "oraclecloud.com", + "oc2": "oraclegovcloud.com", + "oc3": "oraclegovcloud.com", + "oc4": "oraclegovcloud.uk", + "oc8": "oraclecloud8.com", +} + +var regionRealm = map[Region]string{ + RegionPHX: "oc1", + RegionIAD: "oc1", + RegionFRA: "oc1", + RegionLHR: "oc1", + RegionSJC1: "oc1", + + RegionUKCardiff1: "oc1", + + RegionCAToronto1: "oc1", + RegionCAMontreal1: "oc1", + + RegionAPTokyo1: "oc1", + RegionAPOsaka1: "oc1", + RegionAPSeoul1: "oc1", + RegionAPChuncheon1: "oc1", + RegionAPSydney1: "oc1", + RegionAPMumbai1: "oc1", + RegionAPHyderabad1: "oc1", + RegionAPMelbourne1: "oc1", + + RegionMEJeddah1: "oc1", + RegionMEDubai1: "oc1", + + RegionEUZurich1: "oc1", + RegionEUAmsterdam1: "oc1", + + RegionSASaopaulo1: "oc1", + RegionSASantiago1: "oc1", + RegionSAVinhedo1: "oc1", + + RegionUSLangley1: "oc2", + RegionUSLuke1: "oc2", + + RegionUSGovAshburn1: "oc3", + RegionUSGovChicago1: "oc3", + RegionUSGovPhoenix1: "oc3", + RegionUKGovCardiff1: "oc4", + RegionUKGovLondon1: "oc4", + + RegionAPChiyoda1: "oc8", +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v48/common/regions.json b/vendor/github.com/oracle/oci-go-sdk/v48/common/regions.json new file mode 100644 index 0000000..2e58959 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/regions.json @@ -0,0 +1,188 @@ +[ + { + "regionKey": "yny", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "ap-chuncheon-1", + "realmKey": "oc1" + }, + { + "regionKey": "hyd", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "ap-hyderabad-1", + "realmKey": "oc1" + }, + { + "regionKey": "mel", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "ap-melbourne-1", + "realmKey": "oc1" + }, + { + "regionKey": "bom", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "ap-mumbai-1", + "realmKey": "oc1" + }, + { + "regionKey": "kix", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "ap-osaka-1", + "realmKey": "oc1" + }, + { + "regionKey": "icn", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "ap-seoul-1", + "realmKey": "oc1" + }, + { + "regionKey": "syd", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "ap-sydney-1", + "realmKey": "oc1" + }, + { + "regionKey": "nrt", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "ap-tokyo-1", + "realmKey": "oc1" + }, + { + "regionKey": "yul", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "ca-montreal-1", + "realmKey": "oc1" + }, + { + "regionKey": "yyz", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "ca-toronto-1", + "realmKey": "oc1" + }, + { + "regionKey": "ams", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "eu-amsterdam-1", + "realmKey": "oc1" + }, + { + "regionKey": "fra", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "eu-frankfurt-1", + "realmKey": "oc1" + }, + { + "regionKey": "zrh", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "eu-zurich-1", + "realmKey": "oc1" + }, + { + "regionKey": "jed", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "me-jeddah-1", + "realmKey": "oc1" + }, + { + "regionKey": "dxb", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "me-dubai-1", + "realmKey": "oc1" + }, + { + "regionKey": "gru", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "sa-saopaulo-1", + "realmKey": "oc1" + }, + { + "regionKey": "cwl", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "uk-cardiff-1", + "realmKey": "oc1" + }, + { + "regionKey": "lhr", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "uk-london-1", + "realmKey": "oc1" + }, + { + "regionKey": "iad", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "us-ashburn-1", + "realmKey": "oc1" + }, + { + "regionKey": "phx", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "us-phoenix-1", + "realmKey": "oc1" + }, + { + "regionKey": "sjc", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "us-sanjose-1", + "realmKey": "oc1" + }, + { + "regionKey": "vcp", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "sa-vinhedo-1", + "realmKey": "oc1" + }, + { + "regionKey": "scl", + "realmDomainComponent": "oraclecloud.com", + "regionIdentifier": "sa-santiago-1", + "realmKey": "oc1" + }, + { + "regionKey": "lfi", + "realmDomainComponent": "oraclegovcloud.com", + "regionIdentifier": "us-langley-1", + "realmKey": "oc2" + }, + { + "regionKey": "luf", + "realmDomainComponent": "oraclegovcloud.com", + "regionIdentifier": "us-luke-1", + "realmKey": "oc2" + }, + { + "regionKey": "ric", + "realmDomainComponent": "oraclegovcloud.com", + "regionIdentifier": "us-gov-ashburn-1", + "realmKey": "oc3" + }, + { + "regionKey": "pia", + "realmDomainComponent": "oraclegovcloud.com", + "regionIdentifier": "us-gov-chicago-1", + "realmKey": "oc3" + }, + { + "regionKey": "tus", + "realmDomainComponent": "oraclegovcloud.com", + "regionIdentifier": "us-gov-phoenix-1", + "realmKey": "oc3" + }, + { + "regionKey": "ltn", + "realmDomainComponent": "oraclegovcloud.uk", + "regionIdentifier": "uk-gov-london-1", + "realmKey": "oc4" + }, + { + "regionKey": "brs", + "realmDomainComponent": "oraclegovcloud.uk", + "regionIdentifier": "uk-gov-cardiff-1", + "realmKey": "oc4" + }, + { + "regionKey": "nja", + "realmDomainComponent": "oraclecloud8.com", + "regionIdentifier": "ap-chiyoda-1", + "realmKey": "oc8" + } +] \ No newline at end of file diff --git a/vendor/github.com/oracle/oci-go-sdk/v48/common/retry.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/retry.go new file mode 100644 index 0000000..9cb370f --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/retry.go @@ -0,0 +1,956 @@ +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. + +package common + +import ( + "context" + "errors" + "fmt" + "io" + "math" + "math/rand" + "runtime" + "strings" + "sync" + "sync/atomic" + "time" +) + +const ( + // UnlimitedNumAttemptsValue is the value for indicating unlimited attempts for reaching success + UnlimitedNumAttemptsValue = uint(0) + + // number of characters contained in the generated retry token + generatedRetryTokenLength = 32 +) + +// OCIRetryableRequest represents a request that can be reissued according to the specified policy. +type OCIRetryableRequest interface { + // Any retryable request must implement the OCIRequest interface + OCIRequest + + // Each operation should implement this method, if has binary body, return OCIReadSeekCloser and true, otherwise return nil, false + BinaryRequestBody() (*OCIReadSeekCloser, bool) + + // Each operation specifies default retry behavior. By passing no arguments to this method, the default retry + // behavior, as determined on a per-operation-basis, will be honored. Variadic retry policy option arguments + // passed to this method will override the default behavior. + RetryPolicy() *RetryPolicy +} + +// OCIOperationResponse represents the output of an OCIOperation, with additional context of error message +// and operation attempt number. +type OCIOperationResponse struct { + // Response from OCI Operation + Response OCIResponse + + // Error from OCI Operation + Error error + + // Operation Attempt Number (one-based) + AttemptNumber uint + + // End of eventually consistent effects, or nil if no such effects + EndOfWindowTime *time.Time + + // Backoff scaling factor (only used for dealing with eventual consistency) + BackoffScalingFactor float64 + + // Time of the initial attempt + InitialAttemptTime time.Time +} + +// EventuallyConsistentContext contains the information about the end of the eventually consistent window. +type EventuallyConsistentContext struct { + endOfWindow atomic.Value + lock sync.Mutex + timeNowProvider func() time.Time +} + +// GetEndOfWindow returns the end time an eventually consistent window, +// or nil if no eventually consistent requests were made +func (e *EventuallyConsistentContext) GetEndOfWindow() *time.Time { + untyped := e.endOfWindow.Load() // returns nil if there has been no call to Store for this Value + if untyped == nil { + return (*time.Time)(nil) + } + t := untyped.(*time.Time) + return t +} + +// UpdateEndOfWindow sets the end time of the eventually consistent window the specified +// duration into the future +func (e *EventuallyConsistentContext) UpdateEndOfWindow(windowSize time.Duration) *time.Time { + e.lock.Lock() // synchronize with other potential writers + defer e.lock.Unlock() + currentEndOfWindowTime := e.GetEndOfWindow() + var newEndOfWindowTime = e.timeNowProvider().Add(windowSize) + if currentEndOfWindowTime == nil || newEndOfWindowTime.After(*currentEndOfWindowTime) { + e.endOfWindow.Store(&newEndOfWindowTime) // atomically replace the current object with the new one + return &newEndOfWindowTime + } + return currentEndOfWindowTime +} + +// setEndTimeOfEventuallyConsistentWindow sets the last time an eventually consistent request was made +// to the specified time +func (e *EventuallyConsistentContext) setEndOfWindow(newTime *time.Time) *time.Time { + e.lock.Lock() // synchronize with other potential writers + defer e.lock.Unlock() + e.endOfWindow.Store(newTime) // atomically replace the current object with the new one + return newTime +} + +// EcContext contains the information about the end of the eventually consistent window for this process. +var EcContext = EventuallyConsistentContext{ + timeNowProvider: func() time.Time { return time.Now() }, +} + +type httpStatus struct { + code int + message string +} + +const ( + defaultMaximumNumberAttempts = uint(8) + defaultExponentialBackoffBase = 2.0 + defaultMinSleepBetween = 0.0 + defaultMaxSleepBetween = 30.0 + + ecMaximumNumberAttempts = uint(9) + ecExponentialBackoffBase = 3.52 + ecMinSleepBetween = 0.0 + ecMaxSleepBetween = 45.0 +) + +var ( + defaultRetryStatusCodeMap = map[httpStatus]bool{ + {409, "IncorrectState"}: true, + {429, "TooManyRequests"}: true, + + {501, "MethodNotImplemented"}: false, + } + affectedByEventualConsistencyRetryStatusCodeMap = map[httpStatus]bool{ + {400, "RelatedResourceNotAuthorizedOrNotFound"}: true, + {404, "NotAuthorizedOrNotFound"}: true, + {409, "NotAuthorizedOrResourceAlreadyExists"}: true, + } +) + +// IsErrorAffectedByEventualConsistency returns true if the error is affected by eventual consistency. +func IsErrorAffectedByEventualConsistency(Error error) bool { + if err, ok := IsServiceError(Error); ok { + return affectedByEventualConsistencyRetryStatusCodeMap[httpStatus{err.GetHTTPStatusCode(), err.GetCode()}] + } + return false +} + +// IsErrorRetryableByDefault returns true if the error is retryable by OCI default retry policy +func IsErrorRetryableByDefault(Error error) bool { + if Error == nil { + return false + } + + if IsNetworkError(Error) { + return true + } + + if err, ok := IsServiceError(Error); ok { + if shouldRetry, ok := defaultRetryStatusCodeMap[httpStatus{err.GetHTTPStatusCode(), err.GetCode()}]; ok { + return shouldRetry + } + + return 500 <= err.GetHTTPStatusCode() && err.GetHTTPStatusCode() < 600 + } + + return false +} + +// NewOCIOperationResponse assembles an OCI Operation Response object. +// Note that InitialAttemptTime is not set, nor is EndOfWindowTime, and BackoffScalingFactor is set to 1.0. +// EndOfWindowTime and BackoffScalingFactor are only important for eventual consistency. +// InitialAttemptTime can be useful for time-based (as opposed to count-based) retry policies. +func NewOCIOperationResponse(response OCIResponse, err error, attempt uint) OCIOperationResponse { + return OCIOperationResponse{ + Response: response, + Error: err, + AttemptNumber: attempt, + BackoffScalingFactor: 1.0, + } +} + +// NewOCIOperationResponseExtended assembles an OCI Operation Response object, with the value for the EndOfWindowTime, BackoffScalingFactor, and InitialAttemptTime set. +// EndOfWindowTime and BackoffScalingFactor are only important for eventual consistency. +// InitialAttemptTime can be useful for time-based (as opposed to count-based) retry policies. +func NewOCIOperationResponseExtended(response OCIResponse, err error, attempt uint, endOfWindowTime *time.Time, backoffScalingFactor float64, + initialAttemptTime time.Time) OCIOperationResponse { + return OCIOperationResponse{ + Response: response, + Error: err, + AttemptNumber: attempt, + EndOfWindowTime: endOfWindowTime, + BackoffScalingFactor: backoffScalingFactor, + InitialAttemptTime: initialAttemptTime, + } +} + +// +// RetryPolicy +// + +// RetryPolicy is the class that holds all relevant information for retrying operations. +type RetryPolicy struct { + // MaximumNumberAttempts is the maximum number of times to retry a request. Zero indicates an unlimited + // number of attempts. + MaximumNumberAttempts uint + + // ShouldRetryOperation inspects the http response, error, and operation attempt number, and + // - returns true if we should retry the operation + // - returns false otherwise + ShouldRetryOperation func(OCIOperationResponse) bool + + // GetNextDuration computes the duration to pause between operation retries. + NextDuration func(OCIOperationResponse) time.Duration + + // minimum sleep between attempts in seconds + MinSleepBetween float64 + + // maximum sleep between attempts in seconds + MaxSleepBetween float64 + + // the base for the exponential backoff + ExponentialBackoffBase float64 + + // DeterminePolicyToUse may modify the policy to handle eventual consistency; the return values are + // the retry policy to use, the end of the eventually consistent time window, and the backoff scaling factor + // If eventual consistency is not considered, this function should return the unmodified policy that was + // provided as input, along with (*time.Time)(nil) (no time window), and 1.0 (unscaled backoff). + DeterminePolicyToUse func(policy RetryPolicy) (RetryPolicy, *time.Time, float64) + + // if the retry policy considers eventual consistency, but there is no eventual consistency present + // the retries will fall back to the policy specified here; recommendation is to set this to DefaultRetryPolicyWithoutEventualConsistency() + NonEventuallyConsistentPolicy *RetryPolicy + + // Stores the maximum cumulative backoff in seconds. This can usually be calculated using + // MaximumNumberAttempts, MinSleepBetween, MaxSleepBetween, and ExponentialBackoffBase, + // but if MaximumNumberAttempts is 0 (unlimited attempts), then this needs to be set explicitly + // for Eventual Consistency retries to work. + MaximumCumulativeBackoffWithoutJitter float64 +} + +// RetryPolicyOption is the type of the options for NewRetryPolicy. +type RetryPolicyOption func(rp *RetryPolicy) + +// Convert retry policy to human-readable string representation +func (rp RetryPolicy) String() string { + return fmt.Sprintf("{MaximumNumberAttempts=%v, MinSleepBetween=%v, MaxSleepBetween=%v, ExponentialBackoffBase=%v, NonEventuallyConsistentPolicy=%v}", + rp.MaximumNumberAttempts, rp.MinSleepBetween, rp.MaxSleepBetween, rp.ExponentialBackoffBase, rp.NonEventuallyConsistentPolicy) +} + +// Validate returns true if the RetryPolicy is valid; if not, it also returns an error. +func (rp *RetryPolicy) validate() (success bool, err error) { + var errorStrings []string + if rp.ShouldRetryOperation == nil { + errorStrings = append(errorStrings, "ShouldRetryOperation may not be nil") + } + if rp.NextDuration == nil { + errorStrings = append(errorStrings, "NextDuration may not be nil") + } + if rp.NonEventuallyConsistentPolicy != nil { + if rp.MaximumNumberAttempts == 0 && rp.MaximumCumulativeBackoffWithoutJitter <= 0 { + errorStrings = append(errorStrings, "If eventual consistency is handled, and the MaximumNumberAttempts of the EC retry policy is 0 (unlimited attempts), then the MaximumCumulativeBackoffWithoutJitter of the EC retry policy must be positive; used WithUnlimitedAttempts instead") + } + nonEcRp := rp.NonEventuallyConsistentPolicy + if nonEcRp.MaximumNumberAttempts == 0 && nonEcRp.MaximumCumulativeBackoffWithoutJitter <= 0 { + errorStrings = append(errorStrings, "If eventual consistency is handled, and the MaximumNumberAttempts of the non-EC retry policy is 0 (unlimited attempts), then the MaximumCumulativeBackoffWithoutJitter of the non-EC retry policy must be positive; used WithUnlimitedAttempts instead") + } + } + if len(errorStrings) > 0 { + return false, errors.New(strings.Join(errorStrings, ", ")) + } + + // some legacy code constructing RetryPolicy instances directly may not have set DeterminePolicyToUse. + // In that case, just assume that it doesn't handle eventual consistency. + if rp.DeterminePolicyToUse == nil { + rp.DeterminePolicyToUse = returnSamePolicy + } + + return true, nil +} + +// GetMaximumCumulativeBackoffWithoutJitter returns the maximum cumulative backoff the retry policy would do, +// taking into account whether eventually consistency is considered or not. +// This function uses either GetMaximumCumulativeBackoffWithoutJitter or GetMaximumCumulativeEventuallyConsistentBackoffWithoutJitter, +// whichever is appropriate +func (rp RetryPolicy) GetMaximumCumulativeBackoffWithoutJitter() time.Duration { + if rp.NonEventuallyConsistentPolicy == nil { + return GetMaximumCumulativeBackoffWithoutJitter(rp) + } + return GetMaximumCumulativeEventuallyConsistentBackoffWithoutJitter(rp) +} + +// +// Functions to calculate backoff and maximum cumulative backoff +// + +// GetBackoffWithoutJitter calculates the backoff without jitter for the attempt, given the retry policy. +func GetBackoffWithoutJitter(policy RetryPolicy, attempt uint) time.Duration { + return time.Duration(getBackoffWithoutJitterHelper(policy.MinSleepBetween, policy.MaxSleepBetween, policy.ExponentialBackoffBase, attempt)) * time.Second +} + +// getBackoffWithoutJitterHelper calculates the backoff without jitter for the attempt, given the loose retry policy values. +func getBackoffWithoutJitterHelper(minSleepBetween float64, maxSleepBetween float64, exponentialBackoffBase float64, attempt uint) float64 { + sleepTime := math.Pow(exponentialBackoffBase, float64(attempt-1)) + if sleepTime < minSleepBetween { + sleepTime = minSleepBetween + } + if sleepTime > maxSleepBetween { + sleepTime = maxSleepBetween + } + return sleepTime +} + +// GetMaximumCumulativeBackoffWithoutJitter calculates the maximum backoff without jitter, according to the retry +// policy, if every retry attempt is made. +func GetMaximumCumulativeBackoffWithoutJitter(policy RetryPolicy) time.Duration { + return getMaximumCumulativeBackoffWithoutJitterHelper(policy.MinSleepBetween, policy.MaxSleepBetween, policy.ExponentialBackoffBase, policy.MaximumNumberAttempts, policy.MaximumCumulativeBackoffWithoutJitter) +} + +func getMaximumCumulativeBackoffWithoutJitterHelper(minSleepBetween float64, maxSleepBetween float64, exponentialBackoffBase float64, MaximumNumberAttempts uint, MaximumCumulativeBackoffWithoutJitter float64) time.Duration { + var cumulative time.Duration = 0 + + if MaximumNumberAttempts == 0 { + // unlimited + return time.Duration(MaximumCumulativeBackoffWithoutJitter) * time.Second + } + + // use a one-based counter because it's easier to think about operation retry in terms of attempt numbering + for currentOperationAttempt := uint(1); currentOperationAttempt < MaximumNumberAttempts; currentOperationAttempt++ { + cumulative += time.Duration(getBackoffWithoutJitterHelper(minSleepBetween, maxSleepBetween, exponentialBackoffBase, currentOperationAttempt)) * time.Second + } + return cumulative +} + +// +// Functions to calculate backoff and maximum cumulative backoff for eventual consistency +// + +// GetEventuallyConsistentBackoffWithoutJitter calculates the backoff without jitter for the attempt, given the retry policy +// and dealing with eventually consistent effects. The result is then multiplied by backoffScalingFactor. +func GetEventuallyConsistentBackoffWithoutJitter(policy RetryPolicy, attempt uint, backoffScalingFactor float64) time.Duration { + return time.Duration(getEventuallyConsistentBackoffWithoutJitterHelper(policy.MinSleepBetween, policy.MaxSleepBetween, policy.ExponentialBackoffBase, attempt, backoffScalingFactor, + func(minSleepBetween float64, maxSleepBetween float64, exponentialBackoffBase float64, attempt uint) float64 { + rp := policy.NonEventuallyConsistentPolicy + return getBackoffWithoutJitterHelper(rp.MinSleepBetween, rp.MaxSleepBetween, rp.ExponentialBackoffBase, attempt) + })*1000) * time.Millisecond +} + +// getEventuallyConsistentBackoffWithoutJitterHelper calculates the backoff without jitter for the attempt, given the loose retry policy values, +// and dealing with eventually consistent effects. The result is then multiplied by backoffScalingFactor. +func getEventuallyConsistentBackoffWithoutJitterHelper(minSleepBetween float64, maxSleepBetween float64, exponentialBackoffBase float64, attempt uint, backoffScalingFactor float64, + defaultBackoffWithoutJitterHelper func(minSleepBetween float64, maxSleepBetween float64, exponentialBackoffBase float64, attempt uint) float64) float64 { + var sleepTime = math.Pow(exponentialBackoffBase, float64(attempt-1)) + if sleepTime < minSleepBetween { + sleepTime = minSleepBetween + } + if sleepTime > maxSleepBetween { + sleepTime = maxSleepBetween + } + sleepTime = sleepTime * backoffScalingFactor + defaultSleepTime := defaultBackoffWithoutJitterHelper(minSleepBetween, maxSleepBetween, exponentialBackoffBase, attempt) + if defaultSleepTime > sleepTime { + sleepTime = defaultSleepTime + } + return sleepTime +} + +// GetMaximumCumulativeEventuallyConsistentBackoffWithoutJitter calculates the maximum backoff without jitter, according to the retry +// policy and taking eventually consistent effects into account, if every retry attempt is made. +func GetMaximumCumulativeEventuallyConsistentBackoffWithoutJitter(policy RetryPolicy) time.Duration { + return getMaximumCumulativeEventuallyConsistentBackoffWithoutJitterHelper(policy.MinSleepBetween, policy.MaxSleepBetween, policy.ExponentialBackoffBase, + policy.MaximumNumberAttempts, policy.MaximumCumulativeBackoffWithoutJitter, + func(minSleepBetween float64, maxSleepBetween float64, exponentialBackoffBase float64, attempt uint) float64 { + rp := policy.NonEventuallyConsistentPolicy + return getBackoffWithoutJitterHelper(rp.MinSleepBetween, rp.MaxSleepBetween, rp.ExponentialBackoffBase, attempt) + }) +} + +func getMaximumCumulativeEventuallyConsistentBackoffWithoutJitterHelper(minSleepBetween float64, maxSleepBetween float64, exponentialBackoffBase float64, MaximumNumberAttempts uint, + MaximumCumulativeBackoffWithoutJitter float64, + defaultBackoffWithoutJitterHelper func(minSleepBetween float64, maxSleepBetween float64, exponentialBackoffBase float64, attempt uint) float64) time.Duration { + if MaximumNumberAttempts == 0 { + // unlimited + return time.Duration(MaximumCumulativeBackoffWithoutJitter) * time.Second + } + + var cumulative time.Duration = 0 + // use a one-based counter because it's easier to think about operation retry in terms of attempt numbering + for currentOperationAttempt := uint(1); currentOperationAttempt < MaximumNumberAttempts; currentOperationAttempt++ { + cumulative += time.Duration(getEventuallyConsistentBackoffWithoutJitterHelper(minSleepBetween, maxSleepBetween, exponentialBackoffBase, currentOperationAttempt, 1.0, defaultBackoffWithoutJitterHelper)*1000) * time.Millisecond + } + return cumulative +} + +func returnSamePolicy(policy RetryPolicy) (RetryPolicy, *time.Time, float64) { + // we're returning the end of window time nonetheless, even though the default non-eventual consistency (EC) + // retry policy doesn't use it; this is useful in case developers wants to write an EC-aware retry policy + // on their own + return policy, EcContext.GetEndOfWindow(), 1.0 +} + +// NoRetryPolicy is a helper method that assembles and returns a return policy that indicates an operation should +// never be retried (the operation is performed exactly once). +func NoRetryPolicy() RetryPolicy { + dontRetryOperation := func(OCIOperationResponse) bool { return false } + zeroNextDuration := func(OCIOperationResponse) time.Duration { return 0 * time.Second } + return newRetryPolicyWithOptionsNoDefault( + WithMaximumNumberAttempts(1), + WithShouldRetryOperation(dontRetryOperation), + WithNextDuration(zeroNextDuration), + withMinSleepBetween(0.0*time.Second), + withMaxSleepBetween(0.0*time.Second), + withExponentialBackoffBase(0.0), + withDeterminePolicyToUse(returnSamePolicy), + withNonEventuallyConsistentPolicy(nil)) +} + +// DefaultShouldRetryOperation is the function that should be used for RetryPolicy.ShouldRetryOperation when +// not taking eventual consistency into account. +func DefaultShouldRetryOperation(r OCIOperationResponse) bool { + if r.Error == nil && 199 < r.Response.HTTPResponse().StatusCode && r.Response.HTTPResponse().StatusCode < 300 { + // success + return false + } + return IsErrorRetryableByDefault(r.Error) +} + +// DefaultRetryPolicy is a helper method that assembles and returns a return policy that is defined to be a default one +// The default retry policy will retry on (409, IncorrectState), (429, TooManyRequests) and any 5XX errors except (501, MethodNotImplemented) +// The default retry behavior is using exponential backoff with jitter, the maximum wait time is 30s plus 1s jitter +// The maximum cumulative backoff after all 8 attempts have been made is about 1.5 minutes. +// It will also retry on errors affected by eventual consistency. +// The eventual consistency retry behavior is using exponential backoff with jitter, the maximum wait time is 45s plus 1s jitter +// Under eventual consistency, the maximum cumulative backoff after all 9 attempts have been made is about 4 minutes. +func DefaultRetryPolicy() RetryPolicy { + return NewRetryPolicyWithOptions( + ReplaceWithValuesFromRetryPolicy(DefaultRetryPolicyWithoutEventualConsistency()), + WithEventualConsistency()) +} + +// DefaultRetryPolicyWithoutEventualConsistency is a helper method that assembles and returns a return policy that is defined to be a default one +// The default retry policy will retry on (409, IncorrectState), (429, TooManyRequests) and any 5XX errors except (501, MethodNotImplemented) +// It will not retry on errors affected by eventual consistency. +// The default retry behavior is using exponential backoff with jitter, the maximum wait time is 30s plus 1s jitter +func DefaultRetryPolicyWithoutEventualConsistency() RetryPolicy { + exponentialBackoffWithJitter := func(r OCIOperationResponse) time.Duration { + sleepTime := getBackoffWithoutJitterHelper(defaultMinSleepBetween, defaultMaxSleepBetween, defaultExponentialBackoffBase, r.AttemptNumber) + nextDuration := time.Duration(1000.0*(sleepTime+rand.Float64())) * time.Millisecond + return nextDuration + } + return newRetryPolicyWithOptionsNoDefault( + WithMaximumNumberAttempts(defaultMaximumNumberAttempts), + WithShouldRetryOperation(DefaultShouldRetryOperation), + WithNextDuration(exponentialBackoffWithJitter), + withMinSleepBetween(defaultMinSleepBetween*time.Second), + withMaxSleepBetween(defaultMaxSleepBetween*time.Second), + withExponentialBackoffBase(defaultExponentialBackoffBase), + withDeterminePolicyToUse(returnSamePolicy), + withNonEventuallyConsistentPolicy(nil)) +} + +// EventuallyConsistentShouldRetryOperation is the function that should be used for RetryPolicy.ShouldRetryOperation when +// taking eventual consistency into account +func EventuallyConsistentShouldRetryOperation(r OCIOperationResponse) bool { + if r.Error == nil && 199 < r.Response.HTTPResponse().StatusCode && r.Response.HTTPResponse().StatusCode < 300 { + // success + Debugln(fmt.Sprintf("EC.ShouldRetryOperation, status = %v, 2xx, returning false", r.Response.HTTPResponse().StatusCode)) + return false + } + if IsErrorRetryableByDefault(r.Error) { + return true + } + // not retryable by default + if _, ok := IsServiceError(r.Error); ok { + now := EcContext.timeNowProvider() + if r.EndOfWindowTime == nil || r.EndOfWindowTime.Before(now) { + // either no eventually consistent effects, or they have disappeared by now + Debugln(fmt.Sprintf("EC.ShouldRetryOperation, no EC or in the past, returning false: endOfWindowTime = %v, now = %v", r.EndOfWindowTime, now)) + return false + } + // there were eventually consistent effects present at the time of the first request + // and they could still affect the retries + if IsErrorAffectedByEventualConsistency(r.Error) { + // and it's one of the three affected error codes + Debugln(fmt.Sprintf("EC.ShouldRetryOperation, affected by EC, EC is present: endOfWindowTime = %v, now = %v", r.EndOfWindowTime, now)) + return true + } + return false + } + + return false +} + +// EventuallyConsistentRetryPolicy is a helper method that assembles and returns a return policy that is defined to be a default one +// plus dealing with errors affected by eventual consistency. +// The default retry behavior is using exponential backoff with jitter, the maximum wait time is 45s plus 1s jitter +func EventuallyConsistentRetryPolicy(nonEventuallyConsistentPolicy RetryPolicy) RetryPolicy { + if nonEventuallyConsistentPolicy.NonEventuallyConsistentPolicy != nil { + // already deals with eventual consistency + return nonEventuallyConsistentPolicy + } + exponentialBackoffWithJitter := func(r OCIOperationResponse) time.Duration { + sleepTime := getEventuallyConsistentBackoffWithoutJitterHelper(ecMinSleepBetween, ecMaxSleepBetween, ecExponentialBackoffBase, r.AttemptNumber, r.BackoffScalingFactor, + func(minSleepBetween float64, maxSleepBetween float64, exponentialBackoffBase float64, attempt uint) float64 { + rp := nonEventuallyConsistentPolicy + return getBackoffWithoutJitterHelper(rp.MinSleepBetween, rp.MaxSleepBetween, rp.ExponentialBackoffBase, attempt) + }) + nextDuration := time.Duration(1000.0*(sleepTime+rand.Float64())) * time.Millisecond + Debugln(fmt.Sprintf("EventuallyConsistentRetryPolicy.NextDuration for attempt %v: sleepTime = %.1fs, nextDuration = %v", r.AttemptNumber, sleepTime, nextDuration)) + return nextDuration + } + returnModifiedPolicy := func(policy RetryPolicy) (RetryPolicy, *time.Time, float64) { return determinePolicyToUse(policy) } + nonEventuallyConsistentPolicyCopy := newRetryPolicyWithOptionsNoDefault( + ReplaceWithValuesFromRetryPolicy(nonEventuallyConsistentPolicy)) + return newRetryPolicyWithOptionsNoDefault( + WithMaximumNumberAttempts(ecMaximumNumberAttempts), + WithShouldRetryOperation(EventuallyConsistentShouldRetryOperation), + WithNextDuration(exponentialBackoffWithJitter), + withMinSleepBetween(ecMinSleepBetween*time.Second), + withMaxSleepBetween(ecMaxSleepBetween*time.Second), + withExponentialBackoffBase(ecExponentialBackoffBase), + withDeterminePolicyToUse(returnModifiedPolicy), + withNonEventuallyConsistentPolicy(&nonEventuallyConsistentPolicyCopy)) +} + +// NewRetryPolicy is a helper method for assembling a Retry Policy object. It does not handle eventual consistency, so as to not break existing code. +// If you want to handle eventual consistency, the simplest way to do that is to replace the code +// NewRetryPolicy(a, r, n) +// with the code +// NewRetryPolicyWithOptions( +// WithMaximumNumberAttempts(a), +// WithFixedBackoff(fb) // fb is the fixed backoff duration +// WithShouldRetryOperation(r)) +// or +// NewRetryPolicyWithOptions( +// WithMaximumNumberAttempts(a), +// WithExponentialBackoff(mb, e) // mb is the maximum backoff duration, and e is the base for exponential backoff, e.g. 2.0 +// WithShouldRetryOperation(r)) +// or, if a == 0 (the maximum number of attempts is unlimited) +// NewRetryPolicyWithEventualConsistencyUnlimitedAttempts(a, r, n, mcb) // mcb is the maximum cumulative backoff duration without jitter +func NewRetryPolicy(attempts uint, retryOperation func(OCIOperationResponse) bool, nextDuration func(OCIOperationResponse) time.Duration) RetryPolicy { + return NewRetryPolicyWithOptions( + ReplaceWithValuesFromRetryPolicy(DefaultRetryPolicyWithoutEventualConsistency()), + WithMaximumNumberAttempts(attempts), + WithShouldRetryOperation(retryOperation), + WithNextDuration(nextDuration), + ) +} + +// NewRetryPolicyWithEventualConsistencyUnlimitedAttempts is a helper method for assembling a Retry Policy object. +// It does handle eventual consistency, but other than that, it is very similar to NewRetryPolicy. +// NewRetryPolicyWithEventualConsistency does not support limited attempts, use NewRetryPolicyWithEventualConsistency instead. +func NewRetryPolicyWithEventualConsistencyUnlimitedAttempts(attempts uint, retryOperation func(OCIOperationResponse) bool, nextDuration func(OCIOperationResponse) time.Duration, + maximumCumulativeBackoffWithoutJitter time.Duration) (*RetryPolicy, error) { + + if attempts != 0 { + return nil, fmt.Errorf("NewRetryPolicyWithEventualConsistencyUnlimitedAttempts cannot be used with attempts != 0 (limited attempts), use NewRetryPolicyWithEventualConsistency instead") + } + + result := NewRetryPolicyWithOptions( + ReplaceWithValuesFromRetryPolicy(DefaultRetryPolicyWithoutEventualConsistency()), + WithUnlimitedAttempts(maximumCumulativeBackoffWithoutJitter), + WithShouldRetryOperation(retryOperation), + WithNextDuration(nextDuration), + ) + return &result, nil +} + +// NewRetryPolicyWithOptions is a helper method for assembling a Retry Policy object. +// It starts out with the values returned by DefaultRetryPolicy() and does handle eventual consistency, +// unless you replace all options set using ReplaceWithValuesFromRetryPolicy(DefaultRetryPolicyWithoutEventualConsistency()). +func NewRetryPolicyWithOptions(opts ...RetryPolicyOption) RetryPolicy { + rp := &RetryPolicy{} + + // start with the default retry policy + ReplaceWithValuesFromRetryPolicy(DefaultRetryPolicyWithoutEventualConsistency())(rp) + WithEventualConsistency()(rp) + + // then allow changing values + for _, opt := range opts { + opt(rp) + } + + if rp.DeterminePolicyToUse == nil { + rp.DeterminePolicyToUse = returnSamePolicy + } + + return *rp +} + +// newRetryPolicyWithOptionsNoDefault is a helper method for assembling a Retry Policy object. +// Contrary to newRetryPolicyWithOptions, it does not start out with the values returned by +// DefaultRetryPolicy(). +func newRetryPolicyWithOptionsNoDefault(opts ...RetryPolicyOption) RetryPolicy { + rp := &RetryPolicy{} + + // then allow changing values + for _, opt := range opts { + opt(rp) + } + + if rp.DeterminePolicyToUse == nil { + rp.DeterminePolicyToUse = returnSamePolicy + } + + return *rp +} + +// WithMaximumNumberAttempts is the option for NewRetryPolicyWithOptions that sets the maximum number of attempts. +func WithMaximumNumberAttempts(attempts uint) RetryPolicyOption { + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + rp.MaximumNumberAttempts = attempts + } +} + +// WithUnlimitedAttempts is the option for NewRetryPolicyWithOptions that sets unlimited number of attempts, +// but it needs to set a MaximumCumulativeBackoffWithoutJitter duration. +// If you use WithUnlimitedAttempts, you should set your own NextDuration function using WithNextDuration. +func WithUnlimitedAttempts(maximumCumulativeBackoffWithoutJitter time.Duration) RetryPolicyOption { + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + rp.MaximumNumberAttempts = 0 + rp.MaximumCumulativeBackoffWithoutJitter = float64(maximumCumulativeBackoffWithoutJitter / time.Second) + } +} + +// WithShouldRetryOperation is the option for NewRetryPolicyWithOptions that sets the function that checks +// whether retries should be performed. +func WithShouldRetryOperation(retryOperation func(OCIOperationResponse) bool) RetryPolicyOption { + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + rp.ShouldRetryOperation = retryOperation + } +} + +// WithNextDuration is the option for NewRetryPolicyWithOptions that sets the function for computing the next +// backoff duration. +// It is preferred to use WithFixedBackoff or WithExponentialBackoff instead. +func WithNextDuration(nextDuration func(OCIOperationResponse) time.Duration) RetryPolicyOption { + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + rp.NextDuration = nextDuration + } +} + +// withMinSleepBetween is the option for NewRetryPolicyWithOptions that sets the minimum backoff duration. +func withMinSleepBetween(minSleepBetween time.Duration) RetryPolicyOption { + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + rp.MinSleepBetween = float64(minSleepBetween / time.Second) + } +} + +// withMaxsSleepBetween is the option for NewRetryPolicyWithOptions that sets the maximum backoff duration. +func withMaxSleepBetween(maxSleepBetween time.Duration) RetryPolicyOption { + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + rp.MaxSleepBetween = float64(maxSleepBetween / time.Second) + } +} + +// withExponentialBackoffBase is the option for NewRetryPolicyWithOptions that sets the base for the +// exponential backoff +func withExponentialBackoffBase(base float64) RetryPolicyOption { + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + rp.ExponentialBackoffBase = base + } +} + +// withDeterminePolicyToUse is the option for NewRetryPolicyWithOptions that sets the function that +// determines which polich should be used and if eventual consistency should be considered +func withDeterminePolicyToUse(determinePolicyToUse func(policy RetryPolicy) (RetryPolicy, *time.Time, float64)) RetryPolicyOption { + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + rp.DeterminePolicyToUse = determinePolicyToUse + } +} + +// withNonEventuallyConsistentPolicy is the option for NewRetryPolicyWithOptions that sets the fallback +// strategy if eventual consistency should not be considered +func withNonEventuallyConsistentPolicy(nonEventuallyConsistentPolicy *RetryPolicy) RetryPolicyOption { + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + // we want a non-EC policy for NonEventuallyConsistentPolicy; make sure that NonEventuallyConsistentPolicy is nil + for nonEventuallyConsistentPolicy != nil && nonEventuallyConsistentPolicy.NonEventuallyConsistentPolicy != nil { + nonEventuallyConsistentPolicy = nonEventuallyConsistentPolicy.NonEventuallyConsistentPolicy + } + rp.NonEventuallyConsistentPolicy = nonEventuallyConsistentPolicy + } +} + +// WithExponentialBackoff is an option for NewRetryPolicyWithOptions that sets the exponential backoff base, +// minimum and maximum sleep between attempts, and next duration function. +// Therefore, WithExponentialBackoff is a combination of WithNextDuration, withMinSleepBetween, withMaxSleepBetween, +// and withExponentialBackoffBase. +func WithExponentialBackoff(newMaxSleepBetween time.Duration, newExponentialBackoffBase float64) RetryPolicyOption { + exponentialBackoffWithJitter := func(r OCIOperationResponse) time.Duration { + sleepTime := getBackoffWithoutJitterHelper(defaultMinSleepBetween, newMaxSleepBetween.Seconds(), newExponentialBackoffBase, r.AttemptNumber) + nextDuration := time.Duration(1000.0*(sleepTime+rand.Float64())) * time.Millisecond + Debugln(fmt.Sprintf("NextDuration for attempt %v: sleepTime = %.1fs, nextDuration = %v", r.AttemptNumber, sleepTime, nextDuration)) + return nextDuration + } + + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + withMinSleepBetween(0)(rp) + withMaxSleepBetween(newMaxSleepBetween)(rp) + withExponentialBackoffBase(newExponentialBackoffBase)(rp) + WithNextDuration(exponentialBackoffWithJitter)(rp) + } +} + +// WithFixedBackoff is an option for NewRetryPolicyWithOptions that sets the backoff to always be exactly the same value. There is no jitter either. +// Therefore, WithFixedBackoff is a combination of WithNextDuration, withMinSleepBetween, withMaxSleepBetween, and withExponentialBackoffBase. +func WithFixedBackoff(newSleepBetween time.Duration) RetryPolicyOption { + fixedBackoffWithoutJitter := func(r OCIOperationResponse) time.Duration { + nextDuration := newSleepBetween + Debugln(fmt.Sprintf("NextDuration for attempt %v: nextDuration = %v", r.AttemptNumber, nextDuration)) + return nextDuration + } + + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + withMinSleepBetween(newSleepBetween)(rp) + withMaxSleepBetween(newSleepBetween)(rp) + withExponentialBackoffBase(1.0)(rp) + WithNextDuration(fixedBackoffWithoutJitter)(rp) + } +} + +// WithEventualConsistency is the option for NewRetryPolicyWithOptions that enables considering eventual backoff for the policy. +func WithEventualConsistency() RetryPolicyOption { + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + copy := RetryPolicy{ + MaximumNumberAttempts: rp.MaximumNumberAttempts, + ShouldRetryOperation: rp.ShouldRetryOperation, + NextDuration: rp.NextDuration, + MinSleepBetween: rp.MinSleepBetween, + MaxSleepBetween: rp.MaxSleepBetween, + ExponentialBackoffBase: rp.ExponentialBackoffBase, + DeterminePolicyToUse: rp.DeterminePolicyToUse, + NonEventuallyConsistentPolicy: rp.NonEventuallyConsistentPolicy, + } + ecrp := EventuallyConsistentRetryPolicy(copy) + rp.MaximumNumberAttempts = ecrp.MaximumNumberAttempts + rp.ShouldRetryOperation = ecrp.ShouldRetryOperation + rp.NextDuration = ecrp.NextDuration + rp.MinSleepBetween = ecrp.MinSleepBetween + rp.MaxSleepBetween = ecrp.MaxSleepBetween + rp.ExponentialBackoffBase = ecrp.ExponentialBackoffBase + rp.DeterminePolicyToUse = ecrp.DeterminePolicyToUse + rp.NonEventuallyConsistentPolicy = ecrp.NonEventuallyConsistentPolicy + } +} + +// WithConditionalOption is an option for NewRetryPolicyWithOptions that enables or disables another option. +func WithConditionalOption(enabled bool, otherOption RetryPolicyOption) RetryPolicyOption { + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + if enabled { + otherOption(rp) + } + } +} + +// ReplaceWithValuesFromRetryPolicy is an option for NewRetryPolicyWithOptions that copies over all settings from another RetryPolicy +func ReplaceWithValuesFromRetryPolicy(other RetryPolicy) RetryPolicyOption { + // this is the RetryPolicyOption function type + return func(rp *RetryPolicy) { + rp.MaximumNumberAttempts = other.MaximumNumberAttempts + rp.ShouldRetryOperation = other.ShouldRetryOperation + rp.NextDuration = other.NextDuration + rp.MinSleepBetween = other.MinSleepBetween + rp.MaxSleepBetween = other.MaxSleepBetween + rp.ExponentialBackoffBase = other.ExponentialBackoffBase + rp.DeterminePolicyToUse = other.DeterminePolicyToUse + rp.NonEventuallyConsistentPolicy = other.NonEventuallyConsistentPolicy + rp.MaximumCumulativeBackoffWithoutJitter = other.MaximumCumulativeBackoffWithoutJitter + } +} + +// shouldContinueIssuingRequests returns true if we should continue retrying a request, based on the current attempt +// number and the maximum number of attempts specified, or false otherwise. +func shouldContinueIssuingRequests(current, maximum uint) bool { + return maximum == UnlimitedNumAttemptsValue || current <= maximum +} + +// RetryToken generates a retry token that must be included on any request passed to the Retry method. +func RetryToken() string { + alphanumericChars := []rune("abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") + retryToken := make([]rune, generatedRetryTokenLength) + for i := range retryToken { + retryToken[i] = alphanumericChars[rand.Intn(len(alphanumericChars))] + } + return string(retryToken) +} + +func determinePolicyToUse(policy RetryPolicy) (RetryPolicy, *time.Time, float64) { + initialAttemptTime := EcContext.timeNowProvider() + var useDefaultTimingInstead = true + var endOfWindowTime = (*time.Time)(nil) + var backoffScalingFactor = 1.0 + var policyToUse RetryPolicy = policy + + eowt := EcContext.GetEndOfWindow() + if eowt != nil { + // there was an eventually consistent request + if eowt.After(initialAttemptTime) { + // and the eventually consistent effects may still be present + endOfWindowTime = eowt + // if the time between now and the end of the window is less than the time we normally would retry, use the default timing + durationToEndOfWindow := endOfWindowTime.Sub(initialAttemptTime) + maxCumulativeBackoffWithoutJitter := GetMaximumCumulativeBackoffWithoutJitter(*policy.NonEventuallyConsistentPolicy) + Debugln(fmt.Sprintf("durationToEndOfWindow = %v, maxCumulativeBackoffWithoutJitter = %v", durationToEndOfWindow, maxCumulativeBackoffWithoutJitter)) + if durationToEndOfWindow > maxCumulativeBackoffWithoutJitter { + // the end of the eventually consistent window is later than when default retries would end + // do not use default timing + maximumCumulativeBackoffWithoutJitter := GetMaximumCumulativeEventuallyConsistentBackoffWithoutJitter(policy) + backoffScalingFactor = float64(durationToEndOfWindow) / float64(maximumCumulativeBackoffWithoutJitter) + useDefaultTimingInstead = false + Debugln(fmt.Sprintf("Use eventually consistent timing, durationToEndOfWindow = %v, maximumCumulativeBackoffWithoutJitter = %v, backoffScalingFactor = %.2f", + durationToEndOfWindow, maximumCumulativeBackoffWithoutJitter, backoffScalingFactor)) + } else { + Debugln(fmt.Sprintf("Use default timing, end of EC window is sooner than default retries")) + } + } else { + useDefaultTimingInstead = false + policyToUse = *policy.NonEventuallyConsistentPolicy + Debugln(fmt.Sprintf("Use default timing and strategy, end of EC window is in the past")) + } + } else { + useDefaultTimingInstead = false + policyToUse = *policy.NonEventuallyConsistentPolicy + Debugln(fmt.Sprintf("Use default timing and strategy, no EC window set")) + } + + if useDefaultTimingInstead { + // use timing from defaultRetryPolicy, but whether to retry from the policy that was passed into this request + policyToUse = NewRetryPolicyWithOptions( + ReplaceWithValuesFromRetryPolicy(*policy.NonEventuallyConsistentPolicy), + WithShouldRetryOperation(policy.ShouldRetryOperation)) + } + + return policyToUse, endOfWindowTime, backoffScalingFactor +} + +// Retry is a package-level operation that executes the retryable request using the specified operation and retry policy. +func Retry(ctx context.Context, request OCIRetryableRequest, operation OCIOperation, policy RetryPolicy) (OCIResponse, error) { + type retrierResult struct { + response OCIResponse + err error + } + + var response OCIResponse + var err error + retrierChannel := make(chan retrierResult) + + validated, validateError := policy.validate() + if !validated { + return nil, validateError + } + + initialAttemptTime := time.Now() + + go func() { + + // Deal with panics more graciously + defer func() { + if r := recover(); r != nil { + stackBuffer := make([]byte, 1024) + bytesWritten := runtime.Stack(stackBuffer, false) + stack := string(stackBuffer[:bytesWritten]) + error := fmt.Errorf("panicked while retrying operation. Panic was: %s\nStack: %s", r, stack) + Debugln(error) + retrierChannel <- retrierResult{nil, error} + } + }() + + // if request body is binary request body and seekable, save the current position + var curPos int64 = 0 + isSeekable := false + rsc, isBinaryRequest := request.BinaryRequestBody() + if rsc != nil && rsc.rc != nil { + defer rsc.rc.Close() + } + if policy.MaximumNumberAttempts != uint(1) { + if rsc.Seekable() { + isSeekable = true + curPos, _ = rsc.Seek(0, io.SeekCurrent) + } + } + + extraHeaders := make(map[string]string) + + // some legacy code constructing RetryPolicy instances directly may not have set DeterminePolicyToUse. + // In that case, just assume that it doesn't handle eventual consistency. + if policy.DeterminePolicyToUse == nil { + policy.DeterminePolicyToUse = returnSamePolicy + } + + // this determines which policy to use, when the eventual consistency window ends, and what the backoff + // scaling factor should be + policyToUse, endOfWindowTime, backoffScalingFactor := policy.DeterminePolicyToUse(policy) + Debugln(fmt.Sprintf("Retry policy to use: %v", policyToUse)) + + // use a one-based counter because it's easier to think about operation retry in terms of attempt numbering + for currentOperationAttempt := uint(1); shouldContinueIssuingRequests(currentOperationAttempt, policyToUse.MaximumNumberAttempts); currentOperationAttempt++ { + Debugln(fmt.Sprintf("operation attempt #%v", currentOperationAttempt)) + // rewind body once needed + if isSeekable { + rsc = NewOCIReadSeekCloser(rsc.rc) + rsc.Seek(curPos, io.SeekStart) + } + response, err = operation(ctx, request, rsc, extraHeaders) + + operationResponse := NewOCIOperationResponseExtended(response, err, currentOperationAttempt, endOfWindowTime, backoffScalingFactor, initialAttemptTime) + + if !policyToUse.ShouldRetryOperation(operationResponse) { + // we should NOT retry operation based on response and/or error => return + retrierChannel <- retrierResult{response, err} + return + } + + // if the request body type is stream, requested retry but doesn't resettable, throw error and stop retrying + if isBinaryRequest && !isSeekable { + retrierChannel <- retrierResult{response, NonSeekableRequestRetryFailure{err}} + return + } + + duration := policyToUse.NextDuration(operationResponse) + //The following condition is kept for backwards compatibility reasons + if deadline, ok := ctx.Deadline(); ok && EcContext.timeNowProvider().Add(duration).After(deadline) { + // we want to retry the operation, but the policy is telling us to wait for a duration that exceeds + // the specified overall deadline for the operation => instead of waiting for however long that + // time period is and then aborting, abort now and save the cycles + retrierChannel <- retrierResult{response, DeadlineExceededByBackoff} + return + } + Debugln(fmt.Sprintf("waiting %v before retrying operation", duration)) + // sleep before retrying the operation + <-time.After(duration) + } + + retrierChannel <- retrierResult{response, err} + }() + + select { + case <-ctx.Done(): + return response, ctx.Err() + case result := <-retrierChannel: + return result.response, result.err + } +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/common/version.go b/vendor/github.com/oracle/oci-go-sdk/v48/common/version.go similarity index 98% rename from vendor/github.com/oracle/oci-go-sdk/v28/common/version.go rename to vendor/github.com/oracle/oci-go-sdk/v48/common/version.go index 6d8f87e..8ae842a 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/common/version.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/common/version.go @@ -11,7 +11,7 @@ import ( ) const ( - major = "28" + major = "48" minor = "0" patch = "0" tag = "" diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/application.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/application.go similarity index 91% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/application.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/application.go index fbc7980..784e6fe 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/application.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/application.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. @@ -10,7 +10,7 @@ package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" ) // Application An application contains functions and defined attributes shared between those functions, such as network configuration and configuration. Avoid entering confidential information. @@ -37,12 +37,17 @@ type Application struct { // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the subnets in which to run functions in the application. SubnetIds []string `mandatory:"false" json:"subnetIds"` + // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the Network Security Groups to add the application to. + NetworkSecurityGroupIds []string `mandatory:"false" json:"networkSecurityGroupIds"` + // A syslog URL to which to send all function logs. Supports tcp, udp, and tcp+tls. // The syslog URL must be reachable from all of the subnets configured for the application. // Note: If you enable the OCI Logging service for this application, the syslogUrl value is ignored. Function logs are sent to the OCI Logging service, and not to the syslog URL. // Example: `tcp://logserver.myserver:1234` SyslogUrl *string `mandatory:"false" json:"syslogUrl"` + TraceConfig *ApplicationTraceConfig `mandatory:"false" json:"traceConfig"` + // Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. // For more information, see Resource Tags (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). // Example: `{"Department": "Finance"}` @@ -61,6 +66,8 @@ type Application struct { // timestamp format. // Example: `2018-09-12T22:47:12.613Z` TimeUpdated *common.SDKTime `mandatory:"false" json:"timeUpdated"` + + ImagePolicyConfig *ImagePolicyConfig `mandatory:"false" json:"imagePolicyConfig"` } func (m Application) String() string { diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/application_summary.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/application_summary.go similarity index 83% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/application_summary.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/application_summary.go index dd5dcfc..2e261df 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/application_summary.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/application_summary.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. @@ -10,7 +10,7 @@ package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" ) // ApplicationSummary Summary of an application. @@ -31,6 +31,11 @@ type ApplicationSummary struct { // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the subnets in which to run functions in the application. SubnetIds []string `mandatory:"false" json:"subnetIds"` + // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the Network Security Groups to add the application to. + NetworkSecurityGroupIds []string `mandatory:"false" json:"networkSecurityGroupIds"` + + TraceConfig *ApplicationTraceConfig `mandatory:"false" json:"traceConfig"` + // Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. // For more information, see Resource Tags (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). // Example: `{"Department": "Finance"}` @@ -49,6 +54,8 @@ type ApplicationSummary struct { // timestamp format. // Example: `2018-09-12T22:47:12.613Z` TimeUpdated *common.SDKTime `mandatory:"false" json:"timeUpdated"` + + ImagePolicyConfig *ImagePolicyConfig `mandatory:"false" json:"imagePolicyConfig"` } func (m ApplicationSummary) String() string { diff --git a/vendor/github.com/oracle/oci-go-sdk/v48/functions/application_trace_config.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/application_trace_config.go new file mode 100644 index 0000000..860fc83 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/application_trace_config.go @@ -0,0 +1,28 @@ +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Functions Service API +// +// API for the Functions service. +// + +package functions + +import ( + "github.com/oracle/oci-go-sdk/v48/common" +) + +// ApplicationTraceConfig Define the tracing configuration for an application. +type ApplicationTraceConfig struct { + + // Define if tracing is enabled for the resource. + IsEnabled *bool `mandatory:"false" json:"isEnabled"` + + // The OCID of the collector (e.g. an APM Domain) trace events will be sent to. + DomainId *string `mandatory:"false" json:"domainId"` +} + +func (m ApplicationTraceConfig) String() string { + return common.PointerString(m) +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/change_application_compartment_details.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/change_application_compartment_details.go similarity index 88% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/change_application_compartment_details.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/change_application_compartment_details.go index 2389966..b6272b9 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/change_application_compartment_details.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/change_application_compartment_details.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. @@ -10,7 +10,7 @@ package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" ) // ChangeApplicationCompartmentDetails Properties to change the compartment of an application. diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/change_application_compartment_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/change_application_compartment_request_response.go similarity index 79% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/change_application_compartment_request_response.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/change_application_compartment_request_response.go index df2dcf1..5aedcfc 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/change_application_compartment_request_response.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/change_application_compartment_request_response.go @@ -1,15 +1,19 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" ) // ChangeApplicationCompartmentRequest wrapper for the ChangeApplicationCompartment operation +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/ChangeApplicationCompartment.go.html to see an example of how to use ChangeApplicationCompartmentRequest. type ChangeApplicationCompartmentRequest struct { // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this application. @@ -37,8 +41,16 @@ func (request ChangeApplicationCompartmentRequest) String() string { } // HTTPRequest implements the OCIRequest interface -func (request ChangeApplicationCompartmentRequest) HTTPRequest(method, path string) (http.Request, error) { - return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request) +func (request ChangeApplicationCompartmentRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request ChangeApplicationCompartmentRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + } // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/create_application_details.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/create_application_details.go similarity index 85% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/create_application_details.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/create_application_details.go index 0b43c64..594d61c 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/create_application_details.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/create_application_details.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. @@ -10,7 +10,7 @@ package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" ) // CreateApplicationDetails Properties for a new application. @@ -31,12 +31,17 @@ type CreateApplicationDetails struct { // The maximum size for all configuration keys and values is limited to 4KB. This is measured as the sum of octets necessary to represent each key and value in UTF-8. Config map[string]string `mandatory:"false" json:"config"` + // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the Network Security Groups to add the application to. + NetworkSecurityGroupIds []string `mandatory:"false" json:"networkSecurityGroupIds"` + // A syslog URL to which to send all function logs. Supports tcp, udp, and tcp+tls. // The syslog URL must be reachable from all of the subnets configured for the application. // Note: If you enable the OCI Logging service for this application, the syslogUrl value is ignored. Function logs are sent to the OCI Logging service, and not to the syslog URL. // Example: `tcp://logserver.myserver:1234` SyslogUrl *string `mandatory:"false" json:"syslogUrl"` + TraceConfig *ApplicationTraceConfig `mandatory:"false" json:"traceConfig"` + // Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. // For more information, see Resource Tags (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). // Example: `{"Department": "Finance"}` @@ -45,6 +50,8 @@ type CreateApplicationDetails struct { // Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). // Example: `{"Operations": {"CostCenter": "42"}}` DefinedTags map[string]map[string]interface{} `mandatory:"false" json:"definedTags"` + + ImagePolicyConfig *ImagePolicyConfig `mandatory:"false" json:"imagePolicyConfig"` } func (m CreateApplicationDetails) String() string { diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/create_application_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/create_application_request_response.go similarity index 77% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/create_application_request_response.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/create_application_request_response.go index 428dbd4..e2fcc6b 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/create_application_request_response.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/create_application_request_response.go @@ -1,15 +1,19 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" ) // CreateApplicationRequest wrapper for the CreateApplication operation +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/CreateApplication.go.html to see an example of how to use CreateApplicationRequest. type CreateApplicationRequest struct { // Specification of the application to create @@ -29,8 +33,16 @@ func (request CreateApplicationRequest) String() string { } // HTTPRequest implements the OCIRequest interface -func (request CreateApplicationRequest) HTTPRequest(method, path string) (http.Request, error) { - return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request) +func (request CreateApplicationRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request CreateApplicationRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + } // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/create_function_details.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/create_function_details.go similarity index 94% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/create_function_details.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/create_function_details.go index 2f89503..e3199ea 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/create_function_details.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/create_function_details.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. @@ -10,7 +10,7 @@ package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" ) // CreateFunctionDetails Properties to create a new function. @@ -44,6 +44,8 @@ type CreateFunctionDetails struct { // Timeout for executions of the function. Value in seconds. TimeoutInSeconds *int `mandatory:"false" json:"timeoutInSeconds"` + TraceConfig *FunctionTraceConfig `mandatory:"false" json:"traceConfig"` + // Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. // For more information, see Resource Tags (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). // Example: `{"Department": "Finance"}` diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/create_function_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/create_function_request_response.go similarity index 77% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/create_function_request_response.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/create_function_request_response.go index 49a2067..b7a0842 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/create_function_request_response.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/create_function_request_response.go @@ -1,15 +1,19 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" ) // CreateFunctionRequest wrapper for the CreateFunction operation +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/CreateFunction.go.html to see an example of how to use CreateFunctionRequest. type CreateFunctionRequest struct { // Specification of the function to create @@ -29,8 +33,16 @@ func (request CreateFunctionRequest) String() string { } // HTTPRequest implements the OCIRequest interface -func (request CreateFunctionRequest) HTTPRequest(method, path string) (http.Request, error) { - return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request) +func (request CreateFunctionRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request CreateFunctionRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + } // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/delete_application_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/delete_application_request_response.go similarity index 78% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/delete_application_request_response.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/delete_application_request_response.go index 9cdaa4c..2f1fa5b 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/delete_application_request_response.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/delete_application_request_response.go @@ -1,15 +1,19 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" ) // DeleteApplicationRequest wrapper for the DeleteApplication operation +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/DeleteApplication.go.html to see an example of how to use DeleteApplicationRequest. type DeleteApplicationRequest struct { // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this application. @@ -34,8 +38,16 @@ func (request DeleteApplicationRequest) String() string { } // HTTPRequest implements the OCIRequest interface -func (request DeleteApplicationRequest) HTTPRequest(method, path string) (http.Request, error) { - return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request) +func (request DeleteApplicationRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request DeleteApplicationRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + } // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/delete_function_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/delete_function_request_response.go similarity index 78% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/delete_function_request_response.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/delete_function_request_response.go index f8008f9..768bcfd 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/delete_function_request_response.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/delete_function_request_response.go @@ -1,15 +1,19 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" ) // DeleteFunctionRequest wrapper for the DeleteFunction operation +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/DeleteFunction.go.html to see an example of how to use DeleteFunctionRequest. type DeleteFunctionRequest struct { // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this function. @@ -34,8 +38,16 @@ func (request DeleteFunctionRequest) String() string { } // HTTPRequest implements the OCIRequest interface -func (request DeleteFunctionRequest) HTTPRequest(method, path string) (http.Request, error) { - return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request) +func (request DeleteFunctionRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request DeleteFunctionRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + } // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/function.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/function.go similarity index 96% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/function.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/function.go index ad3ca71..65daf5d 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/function.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/function.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. @@ -10,7 +10,7 @@ package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" ) // Function A function resource defines the code (Docker image) and configuration for a specific function. Functions are defined in applications. Avoid entering confidential information. @@ -53,6 +53,8 @@ type Function struct { // Timeout for executions of the function. Value in seconds. TimeoutInSeconds *int `mandatory:"false" json:"timeoutInSeconds"` + TraceConfig *FunctionTraceConfig `mandatory:"false" json:"traceConfig"` + // Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. // For more information, see Resource Tags (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). // Example: `{"Department": "Finance"}` diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/function_summary.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/function_summary.go similarity index 95% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/function_summary.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/function_summary.go index 3f7a18d..daf7fac 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/function_summary.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/function_summary.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. @@ -10,7 +10,7 @@ package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" ) // FunctionSummary Summary of a function. @@ -47,6 +47,8 @@ type FunctionSummary struct { // Timeout for executions of the function. Value in seconds. TimeoutInSeconds *int `mandatory:"false" json:"timeoutInSeconds"` + TraceConfig *FunctionTraceConfig `mandatory:"false" json:"traceConfig"` + // Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. // For more information, see Resource Tags (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). // Example: `{"Department": "Finance"}` diff --git a/vendor/github.com/oracle/oci-go-sdk/v48/functions/function_trace_config.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/function_trace_config.go new file mode 100644 index 0000000..5f09b02 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/function_trace_config.go @@ -0,0 +1,25 @@ +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Functions Service API +// +// API for the Functions service. +// + +package functions + +import ( + "github.com/oracle/oci-go-sdk/v48/common" +) + +// FunctionTraceConfig Define the tracing configuration for a function. +type FunctionTraceConfig struct { + + // Define if tracing is enabled for the resource. + IsEnabled *bool `mandatory:"false" json:"isEnabled"` +} + +func (m FunctionTraceConfig) String() string { + return common.PointerString(m) +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/functions_functionsinvoke_client.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/functions_functionsinvoke_client.go similarity index 88% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/functions_functionsinvoke_client.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/functions_functionsinvoke_client.go index dc137d6..d9b0d56 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/functions_functionsinvoke_client.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/functions_functionsinvoke_client.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. @@ -12,8 +12,8 @@ package functions import ( "context" "fmt" - "github.com/oracle/oci-go-sdk/v28/common" - "github.com/oracle/oci-go-sdk/v28/common/auth" + "github.com/oracle/oci-go-sdk/v48/common" + "github.com/oracle/oci-go-sdk/v48/common/auth" "net/http" ) @@ -73,6 +73,10 @@ func (client *FunctionsInvokeClient) ConfigurationProvider() *common.Configurati } // InvokeFunction Invokes a function +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/InvokeFunction.go.html to see an example of how to use InvokeFunction API. func (client FunctionsInvokeClient) InvokeFunction(ctx context.Context, request InvokeFunctionRequest) (response InvokeFunctionResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() @@ -103,8 +107,9 @@ func (client FunctionsInvokeClient) InvokeFunction(ctx context.Context, request } // invokeFunction implements the OCIOperation interface (enables retrying operations) -func (client FunctionsInvokeClient) invokeFunction(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { - httpRequest, err := request.HTTPRequest(http.MethodPost, "/functions/{functionId}/actions/invoke") +func (client FunctionsInvokeClient) invokeFunction(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodPost, "/functions/{functionId}/actions/invoke", binaryReqBody, extraHeaders) if err != nil { return nil, err } diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/functions_functionsmanagement_client.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/functions_functionsmanagement_client.go similarity index 83% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/functions_functionsmanagement_client.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/functions_functionsmanagement_client.go index 04a1ff2..364a4b0 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/functions_functionsmanagement_client.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/functions_functionsmanagement_client.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. @@ -12,8 +12,8 @@ package functions import ( "context" "fmt" - "github.com/oracle/oci-go-sdk/v28/common" - "github.com/oracle/oci-go-sdk/v28/common/auth" + "github.com/oracle/oci-go-sdk/v48/common" + "github.com/oracle/oci-go-sdk/v48/common/auth" "net/http" ) @@ -81,6 +81,10 @@ func (client *FunctionsManagementClient) ConfigurationProvider() *common.Configu // ChangeApplicationCompartment Moves an application into a different compartment within the same tenancy. // For information about moving resources between compartments, see Moving Resources Between Compartments (https://docs.cloud.oracle.com/iaas/Content/Identity/Tasks/managingcompartments.htm#moveRes). +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/ChangeApplicationCompartment.go.html to see an example of how to use ChangeApplicationCompartment API. func (client FunctionsManagementClient) ChangeApplicationCompartment(ctx context.Context, request ChangeApplicationCompartmentRequest) (response ChangeApplicationCompartmentResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() @@ -111,8 +115,9 @@ func (client FunctionsManagementClient) ChangeApplicationCompartment(ctx context } // changeApplicationCompartment implements the OCIOperation interface (enables retrying operations) -func (client FunctionsManagementClient) changeApplicationCompartment(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { - httpRequest, err := request.HTTPRequest(http.MethodPost, "/applications/{applicationId}/actions/changeCompartment") +func (client FunctionsManagementClient) changeApplicationCompartment(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodPost, "/applications/{applicationId}/actions/changeCompartment", binaryReqBody, extraHeaders) if err != nil { return nil, err } @@ -131,6 +136,10 @@ func (client FunctionsManagementClient) changeApplicationCompartment(ctx context } // CreateApplication Creates a new application. +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/CreateApplication.go.html to see an example of how to use CreateApplication API. func (client FunctionsManagementClient) CreateApplication(ctx context.Context, request CreateApplicationRequest) (response CreateApplicationResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() @@ -161,8 +170,9 @@ func (client FunctionsManagementClient) CreateApplication(ctx context.Context, r } // createApplication implements the OCIOperation interface (enables retrying operations) -func (client FunctionsManagementClient) createApplication(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { - httpRequest, err := request.HTTPRequest(http.MethodPost, "/applications") +func (client FunctionsManagementClient) createApplication(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodPost, "/applications", binaryReqBody, extraHeaders) if err != nil { return nil, err } @@ -181,6 +191,10 @@ func (client FunctionsManagementClient) createApplication(ctx context.Context, r } // CreateFunction Creates a new function. +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/CreateFunction.go.html to see an example of how to use CreateFunction API. func (client FunctionsManagementClient) CreateFunction(ctx context.Context, request CreateFunctionRequest) (response CreateFunctionResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() @@ -211,8 +225,9 @@ func (client FunctionsManagementClient) CreateFunction(ctx context.Context, requ } // createFunction implements the OCIOperation interface (enables retrying operations) -func (client FunctionsManagementClient) createFunction(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { - httpRequest, err := request.HTTPRequest(http.MethodPost, "/functions") +func (client FunctionsManagementClient) createFunction(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodPost, "/functions", binaryReqBody, extraHeaders) if err != nil { return nil, err } @@ -231,6 +246,10 @@ func (client FunctionsManagementClient) createFunction(ctx context.Context, requ } // DeleteApplication Deletes an application. +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/DeleteApplication.go.html to see an example of how to use DeleteApplication API. func (client FunctionsManagementClient) DeleteApplication(ctx context.Context, request DeleteApplicationRequest) (response DeleteApplicationResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() @@ -261,8 +280,9 @@ func (client FunctionsManagementClient) DeleteApplication(ctx context.Context, r } // deleteApplication implements the OCIOperation interface (enables retrying operations) -func (client FunctionsManagementClient) deleteApplication(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { - httpRequest, err := request.HTTPRequest(http.MethodDelete, "/applications/{applicationId}") +func (client FunctionsManagementClient) deleteApplication(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodDelete, "/applications/{applicationId}", binaryReqBody, extraHeaders) if err != nil { return nil, err } @@ -281,6 +301,10 @@ func (client FunctionsManagementClient) deleteApplication(ctx context.Context, r } // DeleteFunction Deletes a function. +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/DeleteFunction.go.html to see an example of how to use DeleteFunction API. func (client FunctionsManagementClient) DeleteFunction(ctx context.Context, request DeleteFunctionRequest) (response DeleteFunctionResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() @@ -311,8 +335,9 @@ func (client FunctionsManagementClient) DeleteFunction(ctx context.Context, requ } // deleteFunction implements the OCIOperation interface (enables retrying operations) -func (client FunctionsManagementClient) deleteFunction(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { - httpRequest, err := request.HTTPRequest(http.MethodDelete, "/functions/{functionId}") +func (client FunctionsManagementClient) deleteFunction(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodDelete, "/functions/{functionId}", binaryReqBody, extraHeaders) if err != nil { return nil, err } @@ -331,6 +356,10 @@ func (client FunctionsManagementClient) deleteFunction(ctx context.Context, requ } // GetApplication Retrieves an application. +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/GetApplication.go.html to see an example of how to use GetApplication API. func (client FunctionsManagementClient) GetApplication(ctx context.Context, request GetApplicationRequest) (response GetApplicationResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() @@ -361,8 +390,9 @@ func (client FunctionsManagementClient) GetApplication(ctx context.Context, requ } // getApplication implements the OCIOperation interface (enables retrying operations) -func (client FunctionsManagementClient) getApplication(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { - httpRequest, err := request.HTTPRequest(http.MethodGet, "/applications/{applicationId}") +func (client FunctionsManagementClient) getApplication(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodGet, "/applications/{applicationId}", binaryReqBody, extraHeaders) if err != nil { return nil, err } @@ -381,6 +411,10 @@ func (client FunctionsManagementClient) getApplication(ctx context.Context, requ } // GetFunction Retrieves a function. +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/GetFunction.go.html to see an example of how to use GetFunction API. func (client FunctionsManagementClient) GetFunction(ctx context.Context, request GetFunctionRequest) (response GetFunctionResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() @@ -411,8 +445,9 @@ func (client FunctionsManagementClient) GetFunction(ctx context.Context, request } // getFunction implements the OCIOperation interface (enables retrying operations) -func (client FunctionsManagementClient) getFunction(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { - httpRequest, err := request.HTTPRequest(http.MethodGet, "/functions/{functionId}") +func (client FunctionsManagementClient) getFunction(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodGet, "/functions/{functionId}", binaryReqBody, extraHeaders) if err != nil { return nil, err } @@ -431,6 +466,10 @@ func (client FunctionsManagementClient) getFunction(ctx context.Context, request } // ListApplications Lists applications for a compartment. +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/ListApplications.go.html to see an example of how to use ListApplications API. func (client FunctionsManagementClient) ListApplications(ctx context.Context, request ListApplicationsRequest) (response ListApplicationsResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() @@ -461,8 +500,9 @@ func (client FunctionsManagementClient) ListApplications(ctx context.Context, re } // listApplications implements the OCIOperation interface (enables retrying operations) -func (client FunctionsManagementClient) listApplications(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { - httpRequest, err := request.HTTPRequest(http.MethodGet, "/applications") +func (client FunctionsManagementClient) listApplications(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodGet, "/applications", binaryReqBody, extraHeaders) if err != nil { return nil, err } @@ -481,6 +521,10 @@ func (client FunctionsManagementClient) listApplications(ctx context.Context, re } // ListFunctions Lists functions for an application. +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/ListFunctions.go.html to see an example of how to use ListFunctions API. func (client FunctionsManagementClient) ListFunctions(ctx context.Context, request ListFunctionsRequest) (response ListFunctionsResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() @@ -511,8 +555,9 @@ func (client FunctionsManagementClient) ListFunctions(ctx context.Context, reque } // listFunctions implements the OCIOperation interface (enables retrying operations) -func (client FunctionsManagementClient) listFunctions(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { - httpRequest, err := request.HTTPRequest(http.MethodGet, "/functions") +func (client FunctionsManagementClient) listFunctions(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodGet, "/functions", binaryReqBody, extraHeaders) if err != nil { return nil, err } @@ -531,6 +576,10 @@ func (client FunctionsManagementClient) listFunctions(ctx context.Context, reque } // UpdateApplication Modifies an application +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/UpdateApplication.go.html to see an example of how to use UpdateApplication API. func (client FunctionsManagementClient) UpdateApplication(ctx context.Context, request UpdateApplicationRequest) (response UpdateApplicationResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() @@ -561,8 +610,9 @@ func (client FunctionsManagementClient) UpdateApplication(ctx context.Context, r } // updateApplication implements the OCIOperation interface (enables retrying operations) -func (client FunctionsManagementClient) updateApplication(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { - httpRequest, err := request.HTTPRequest(http.MethodPut, "/applications/{applicationId}") +func (client FunctionsManagementClient) updateApplication(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodPut, "/applications/{applicationId}", binaryReqBody, extraHeaders) if err != nil { return nil, err } @@ -581,6 +631,10 @@ func (client FunctionsManagementClient) updateApplication(ctx context.Context, r } // UpdateFunction Modifies a function +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/UpdateFunction.go.html to see an example of how to use UpdateFunction API. func (client FunctionsManagementClient) UpdateFunction(ctx context.Context, request UpdateFunctionRequest) (response UpdateFunctionResponse, err error) { var ociResponse common.OCIResponse policy := common.NoRetryPolicy() @@ -611,8 +665,9 @@ func (client FunctionsManagementClient) UpdateFunction(ctx context.Context, requ } // updateFunction implements the OCIOperation interface (enables retrying operations) -func (client FunctionsManagementClient) updateFunction(ctx context.Context, request common.OCIRequest) (common.OCIResponse, error) { - httpRequest, err := request.HTTPRequest(http.MethodPut, "/functions/{functionId}") +func (client FunctionsManagementClient) updateFunction(ctx context.Context, request common.OCIRequest, binaryReqBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (common.OCIResponse, error) { + + httpRequest, err := request.HTTPRequest(http.MethodPut, "/functions/{functionId}", binaryReqBody, extraHeaders) if err != nil { return nil, err } diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/get_application_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/get_application_request_response.go similarity index 78% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/get_application_request_response.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/get_application_request_response.go index bb1727a..d6de4ad 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/get_application_request_response.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/get_application_request_response.go @@ -1,15 +1,19 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" ) // GetApplicationRequest wrapper for the GetApplication operation +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/GetApplication.go.html to see an example of how to use GetApplicationRequest. type GetApplicationRequest struct { // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this application. @@ -29,8 +33,16 @@ func (request GetApplicationRequest) String() string { } // HTTPRequest implements the OCIRequest interface -func (request GetApplicationRequest) HTTPRequest(method, path string) (http.Request, error) { - return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request) +func (request GetApplicationRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request GetApplicationRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + } // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/get_function_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/get_function_request_response.go similarity index 78% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/get_function_request_response.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/get_function_request_response.go index 63b84aa..3ba4e85 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/get_function_request_response.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/get_function_request_response.go @@ -1,15 +1,19 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" ) // GetFunctionRequest wrapper for the GetFunction operation +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/GetFunction.go.html to see an example of how to use GetFunctionRequest. type GetFunctionRequest struct { // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this function. @@ -29,8 +33,16 @@ func (request GetFunctionRequest) String() string { } // HTTPRequest implements the OCIRequest interface -func (request GetFunctionRequest) HTTPRequest(method, path string) (http.Request, error) { - return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request) +func (request GetFunctionRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request GetFunctionRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + } // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. diff --git a/vendor/github.com/oracle/oci-go-sdk/v48/functions/image_policy_config.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/image_policy_config.go new file mode 100644 index 0000000..8198f8b --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/image_policy_config.go @@ -0,0 +1,28 @@ +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Functions Service API +// +// API for the Functions service. +// + +package functions + +import ( + "github.com/oracle/oci-go-sdk/v48/common" +) + +// ImagePolicyConfig Define the image signature verification policy for an application. +type ImagePolicyConfig struct { + + // Define if image signature verification policy is enabled for the application. + IsPolicyEnabled *bool `mandatory:"true" json:"isPolicyEnabled"` + + // A list of KMS key details. + KeyDetails []KeyDetails `mandatory:"false" json:"keyDetails"` +} + +func (m ImagePolicyConfig) String() string { + return common.PointerString(m) +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/invoke_function_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/invoke_function_request_response.go similarity index 83% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/invoke_function_request_response.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/invoke_function_request_response.go index 245ed92..77e3b31 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/invoke_function_request_response.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/invoke_function_request_response.go @@ -1,16 +1,20 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "io" "net/http" ) // InvokeFunctionRequest wrapper for the InvokeFunction operation +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/InvokeFunction.go.html to see an example of how to use InvokeFunctionRequest. type InvokeFunctionRequest struct { // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this function. @@ -41,8 +45,22 @@ func (request InvokeFunctionRequest) String() string { } // HTTPRequest implements the OCIRequest interface -func (request InvokeFunctionRequest) HTTPRequest(method, path string) (http.Request, error) { - return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request) +func (request InvokeFunctionRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + httpRequest, err := common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) + if err == nil && binaryRequestBody.Seekable() { + common.UpdateRequestBinaryBody(&httpRequest, binaryRequestBody) + } + return httpRequest, err +} + +// BinaryRequestBody implements the OCIRequest interface +func (request InvokeFunctionRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + rsc := common.NewOCIReadSeekCloser(request.InvokeFunctionBody) + if rsc.Seekable() { + return rsc, true + } + return nil, true + } // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. diff --git a/vendor/github.com/oracle/oci-go-sdk/v48/functions/key_details.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/key_details.go new file mode 100644 index 0000000..df61357 --- /dev/null +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/key_details.go @@ -0,0 +1,25 @@ +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. +// This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. +// Code generated. DO NOT EDIT. + +// Functions Service API +// +// API for the Functions service. +// + +package functions + +import ( + "github.com/oracle/oci-go-sdk/v48/common" +) + +// KeyDetails The properties that define the kms keys used by Functions for Image Signature verification. +type KeyDetails struct { + + // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the KMS key that will be used to verify the image signature. + KmsKeyId *string `mandatory:"true" json:"kmsKeyId"` +} + +func (m KeyDetails) String() string { + return common.PointerString(m) +} diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/list_applications_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/list_applications_request_response.go similarity index 89% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/list_applications_request_response.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/list_applications_request_response.go index 0430555..b3e7336 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/list_applications_request_response.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/list_applications_request_response.go @@ -1,15 +1,19 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" ) // ListApplicationsRequest wrapper for the ListApplications operation +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/ListApplications.go.html to see an example of how to use ListApplicationsRequest. type ListApplicationsRequest struct { // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the compartment to which this resource belongs. @@ -58,8 +62,16 @@ func (request ListApplicationsRequest) String() string { } // HTTPRequest implements the OCIRequest interface -func (request ListApplicationsRequest) HTTPRequest(method, path string) (http.Request, error) { - return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request) +func (request ListApplicationsRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request ListApplicationsRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + } // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/list_functions_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/list_functions_request_response.go similarity index 89% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/list_functions_request_response.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/list_functions_request_response.go index f513659..339430b 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/list_functions_request_response.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/list_functions_request_response.go @@ -1,15 +1,19 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" ) // ListFunctionsRequest wrapper for the ListFunctions operation +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/ListFunctions.go.html to see an example of how to use ListFunctionsRequest. type ListFunctionsRequest struct { // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of the application to which this function belongs. @@ -58,8 +62,16 @@ func (request ListFunctionsRequest) String() string { } // HTTPRequest implements the OCIRequest interface -func (request ListFunctionsRequest) HTTPRequest(method, path string) (http.Request, error) { - return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request) +func (request ListFunctionsRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request ListFunctionsRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + } // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/update_application_details.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/update_application_details.go similarity index 82% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/update_application_details.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/update_application_details.go index 76a6437..6032a60 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/update_application_details.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/update_application_details.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. @@ -10,7 +10,7 @@ package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" ) // UpdateApplicationDetails Properties to update an application. @@ -22,12 +22,17 @@ type UpdateApplicationDetails struct { // The maximum size for all configuration keys and values is limited to 4KB. This is measured as the sum of octets necessary to represent each key and value in UTF-8. Config map[string]string `mandatory:"false" json:"config"` + // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm)s of the Network Security Groups to add the application to. + NetworkSecurityGroupIds []string `mandatory:"false" json:"networkSecurityGroupIds"` + // A syslog URL to which to send all function logs. Supports tcp, udp, and tcp+tls. // The syslog URL must be reachable from all of the subnets configured for the application. // Note: If you enable the OCI Logging service for this application, the syslogUrl value is ignored. Function logs are sent to the OCI Logging service, and not to the syslog URL. // Example: `tcp://logserver.myserver:1234` SyslogUrl *string `mandatory:"false" json:"syslogUrl"` + TraceConfig *ApplicationTraceConfig `mandatory:"false" json:"traceConfig"` + // Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. // For more information, see Resource Tags (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). // Example: `{"Department": "Finance"}` @@ -36,6 +41,8 @@ type UpdateApplicationDetails struct { // Defined tags for this resource. Each key is predefined and scoped to a namespace. For more information, see Resource Tags (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). // Example: `{"Operations": {"CostCenter": "42"}}` DefinedTags map[string]map[string]interface{} `mandatory:"false" json:"definedTags"` + + ImagePolicyConfig *ImagePolicyConfig `mandatory:"false" json:"imagePolicyConfig"` } func (m UpdateApplicationDetails) String() string { diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/update_application_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/update_application_request_response.go similarity index 81% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/update_application_request_response.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/update_application_request_response.go index cef46d2..53513bd 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/update_application_request_response.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/update_application_request_response.go @@ -1,15 +1,19 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" ) // UpdateApplicationRequest wrapper for the UpdateApplication operation +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/UpdateApplication.go.html to see an example of how to use UpdateApplicationRequest. type UpdateApplicationRequest struct { // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this application. @@ -37,8 +41,16 @@ func (request UpdateApplicationRequest) String() string { } // HTTPRequest implements the OCIRequest interface -func (request UpdateApplicationRequest) HTTPRequest(method, path string) (http.Request, error) { - return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request) +func (request UpdateApplicationRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request UpdateApplicationRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + } // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/update_function_details.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/update_function_details.go similarity index 94% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/update_function_details.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/update_function_details.go index 0520c8b..92b4afe 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/update_function_details.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/update_function_details.go @@ -1,4 +1,4 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. @@ -10,7 +10,7 @@ package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" ) // UpdateFunctionDetails Updates attributes of a function. @@ -38,6 +38,8 @@ type UpdateFunctionDetails struct { // Timeout for executions of the function. Value in seconds. TimeoutInSeconds *int `mandatory:"false" json:"timeoutInSeconds"` + TraceConfig *FunctionTraceConfig `mandatory:"false" json:"traceConfig"` + // Free-form tags for this resource. Each tag is a simple key-value pair with no predefined name, type, or namespace. // For more information, see Resource Tags (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/resourcetags.htm). // Example: `{"Department": "Finance"}` diff --git a/vendor/github.com/oracle/oci-go-sdk/v28/functions/update_function_request_response.go b/vendor/github.com/oracle/oci-go-sdk/v48/functions/update_function_request_response.go similarity index 81% rename from vendor/github.com/oracle/oci-go-sdk/v28/functions/update_function_request_response.go rename to vendor/github.com/oracle/oci-go-sdk/v48/functions/update_function_request_response.go index 6e6b4c0..fe6ab8a 100644 --- a/vendor/github.com/oracle/oci-go-sdk/v28/functions/update_function_request_response.go +++ b/vendor/github.com/oracle/oci-go-sdk/v48/functions/update_function_request_response.go @@ -1,15 +1,19 @@ -// Copyright (c) 2016, 2018, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2016, 2018, 2021, Oracle and/or its affiliates. All rights reserved. // This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license. // Code generated. DO NOT EDIT. package functions import ( - "github.com/oracle/oci-go-sdk/v28/common" + "github.com/oracle/oci-go-sdk/v48/common" "net/http" ) // UpdateFunctionRequest wrapper for the UpdateFunction operation +// +// See also +// +// Click https://docs.cloud.oracle.com/en-us/iaas/tools/go-sdk-examples/latest/functions/UpdateFunction.go.html to see an example of how to use UpdateFunctionRequest. type UpdateFunctionRequest struct { // The OCID (https://docs.cloud.oracle.com/iaas/Content/General/Concepts/identifiers.htm) of this function. @@ -37,8 +41,16 @@ func (request UpdateFunctionRequest) String() string { } // HTTPRequest implements the OCIRequest interface -func (request UpdateFunctionRequest) HTTPRequest(method, path string) (http.Request, error) { - return common.MakeDefaultHTTPRequestWithTaggedStruct(method, path, request) +func (request UpdateFunctionRequest) HTTPRequest(method, path string, binaryRequestBody *common.OCIReadSeekCloser, extraHeaders map[string]string) (http.Request, error) { + + return common.MakeDefaultHTTPRequestWithTaggedStructAndExtraHeaders(method, path, request, extraHeaders) +} + +// BinaryRequestBody implements the OCIRequest interface +func (request UpdateFunctionRequest) BinaryRequestBody() (*common.OCIReadSeekCloser, bool) { + + return nil, false + } // RetryPolicy implements the OCIRetryableRequest interface. This retrieves the specified retry policy. diff --git a/vendor/modules.txt b/vendor/modules.txt index 611e06c..4024481 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -56,9 +56,11 @@ github.com/mitchellh/go-homedir github.com/mitchellh/mapstructure # github.com/oracle/oci-go-sdk/v28 v28.0.0 ## explicit -github.com/oracle/oci-go-sdk/v28/common -github.com/oracle/oci-go-sdk/v28/common/auth -github.com/oracle/oci-go-sdk/v28/functions +# github.com/oracle/oci-go-sdk/v48 v48.0.0 +## explicit +github.com/oracle/oci-go-sdk/v48/common +github.com/oracle/oci-go-sdk/v48/common/auth +github.com/oracle/oci-go-sdk/v48/functions # github.com/pmezard/go-difflib v1.0.0 github.com/pmezard/go-difflib/difflib # github.com/stretchr/testify v1.6.1