diff --git a/example/README.md b/example/README.md index e3529ef..4425809 100644 --- a/example/README.md +++ b/example/README.md @@ -27,13 +27,34 @@ ceClient, err := ibmcloudcodeenginev1.NewIbmCloudCodeEngineV1(&ibmcloudcodeengin }) ``` +### Use an HTTP library to get a Delegated Refresh Token from IAM +```go +iamRequestData := url.Values{} +iamRequestData.Set("grant_type", "urn:ibm:params:oauth:grant-type:apikey") +iamRequestData.Set("apikey", os.Getenv("CE_API_KEY")) +iamRequestData.Set("response_type", "delegated_refresh_token") +iamRequestData.Set("receiver_client_ids", "ce") +iamRequestData.Set("delegated_refresh_token_expiry", "3600") + +client := &http.Client{} +req, _ := http.NewRequest("POST", "https://iam.cloud.ibm.com/identity/token", strings.NewReader(iamRequestData.Encode())) +req.Header.Add("Content-Type", "application/x-www-form-urlencoded") +resp, _ := client.Do(req) + +var iamResponseData map[string]string +json.NewDecoder(resp.Body).Decode(&iamResponseData) +delegatedRefreshToken := iamResponseData["delegated_refresh_token"] +``` + ### Use the Code Engine client to get a Kubernetes config ```go projectID := os.Getenv("CE_PROJECT_ID") -iamToken, _ := authenticator.RequestToken() -refreshToken := iamToken.RefreshToken -result, _, err := ceClient.ListKubeconfig(&ibmcloudcodeenginev1.ListKubeconfigOptions{ - RefreshToken: &refreshToken, - ID: &projectID, +result, _, err := ceClient.GetKubeconfig(&ibmcloudcodeenginev1.GetKubeconfigOptions{ + XDelegatedRefreshToken: &delegatedRefreshToken, + ID: &projectID, }) ``` + +## Deprecated endpoint + +The `/namespaces/{id}/config` endpoint function, `ListKubeconfig()`, is deprecated, and will be removed before Code Engine is out of Beta. Please use the `GetKubeconfig` function, demonstrated in the example above. \ No newline at end of file diff --git a/example/example.go b/example/example.go index c0ed66c..963f10e 100644 --- a/example/example.go +++ b/example/example.go @@ -1,8 +1,12 @@ package main import ( + "encoding/json" "fmt" + "net/http" + "net/url" "os" + "strings" "github.com/IBM/code-engine-go-sdk/ibmcloudcodeenginev1" "github.com/IBM/go-sdk-core/v4/core" @@ -43,23 +47,42 @@ func main() { return } - // Get an IAM token - iamToken, err := authenticator.RequestToken() + // Use the http library to get an IAM Delegated Refresh Token + iamRequestData := url.Values{} + iamRequestData.Set("grant_type", "urn:ibm:params:oauth:grant-type:apikey") + iamRequestData.Set("apikey", os.Getenv("CE_API_KEY")) + iamRequestData.Set("response_type", "delegated_refresh_token") + iamRequestData.Set("receiver_client_ids", "ce") + iamRequestData.Set("delegated_refresh_token_expiry", "3600") + + client := &http.Client{} + req, err := http.NewRequest("POST", "https://iam.cloud.ibm.com/identity/token", strings.NewReader(iamRequestData.Encode())) if err != nil { - fmt.Printf("RequestToken error: %s\n", err.Error()) + fmt.Printf("NewRequest err: %s\n", err) os.Exit(1) return } + req.Header.Add("Content-Type", "application/x-www-form-urlencoded") + resp, err := client.Do(req) + if err != nil { + fmt.Printf("POST /identity/token err: %s\n", err) + os.Exit(1) + return + } + + var iamResponseData map[string]string + json.NewDecoder(resp.Body).Decode(&iamResponseData) + resp.Body.Close() + delegatedRefreshToken := iamResponseData["delegated_refresh_token"] // Get Code Engine project config using the Code Engine Client projectID := os.Getenv("CE_PROJECT_ID") - refreshToken := iamToken.RefreshToken - result, _, err := ceClient.ListKubeconfig(&ibmcloudcodeenginev1.ListKubeconfigOptions{ - RefreshToken: &refreshToken, - ID: &projectID, + result, _, err := ceClient.GetKubeconfig(&ibmcloudcodeenginev1.GetKubeconfigOptions{ + XDelegatedRefreshToken: &delegatedRefreshToken, + ID: &projectID, }) if err != nil { - fmt.Printf("ListKubeconfig error: %s\n", err.Error()) + fmt.Printf("GetKubeconfig error: %s\n", err.Error()) os.Exit(1) return } @@ -98,5 +121,4 @@ func main() { return } fmt.Printf("Project %s has %d configmaps.\n", os.Getenv("CE_PROJECT_ID"), len(configMapList.Items)) - } diff --git a/example/example_deprecated.go b/example/example_deprecated.go new file mode 100644 index 0000000..8f03a9e --- /dev/null +++ b/example/example_deprecated.go @@ -0,0 +1,102 @@ +package main + +import ( + "fmt" + "os" + + "github.com/IBM/code-engine-go-sdk/ibmcloudcodeenginev1" + "github.com/IBM/go-sdk-core/v4/core" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/client-go/kubernetes" + _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" + "k8s.io/client-go/tools/clientcmd" +) + +func deprecated() { + + // Validate environment + requiredEnvs := []string{"CE_API_KEY", "CE_PROJECT_REGION", "CE_PROJECT_ID"} + for _, env := range requiredEnvs { + if os.Getenv(env) == "" { + fmt.Printf("Environment variable %s must be set\n", env) + os.Exit(1) + return + } + } + + // Create an IAM authenticator. + authenticator := &core.IamAuthenticator{ + ApiKey: os.Getenv("CE_API_KEY"), + ClientId: "bx", + ClientSecret: "bx", + } + + // Setup a Code Engine client + ceClient, err := ibmcloudcodeenginev1.NewIbmCloudCodeEngineV1(&ibmcloudcodeenginev1.IbmCloudCodeEngineV1Options{ + Authenticator: authenticator, + URL: "https://api." + os.Getenv("CE_PROJECT_REGION") + ".codeengine.cloud.ibm.com/api/v1", + }) + if err != nil { + fmt.Printf("NewIbmCloudCodeEngineV1 error: %s\n", err.Error()) + os.Exit(1) + return + } + + // Get an IAM token + iamToken, err := authenticator.RequestToken() + if err != nil { + fmt.Printf("RequestToken error: %s\n", err.Error()) + os.Exit(1) + return + } + + // Get Code Engine project config using the Code Engine Client + projectID := os.Getenv("CE_PROJECT_ID") + refreshToken := iamToken.RefreshToken + result, _, err := ceClient.ListKubeconfig(&ibmcloudcodeenginev1.ListKubeconfigOptions{ + RefreshToken: &refreshToken, + ID: &projectID, + }) + if err != nil { + fmt.Printf("ListKubeconfig error: %s\n", err.Error()) + os.Exit(1) + return + } + + // Get Kubernetes client using Code Engine project config + kubeConfig, err := clientcmd.NewClientConfigFromBytes([]byte(*result)) + if err != nil { + fmt.Printf("NewClientConfigFromBytes error: %s\n", err.Error()) + os.Exit(1) + return + } + kubeClientConfig, err := kubeConfig.ClientConfig() + if err != nil { + fmt.Printf("ClientConfig error: %s\n", err.Error()) + os.Exit(1) + return + } + kubeClient, err := kubernetes.NewForConfig(kubeClientConfig) + if err != nil { + fmt.Printf("NewForConfig error: %s\n", err.Error()) + os.Exit(1) + return + } + + // Get something from project + namespace, _, err := kubeConfig.Namespace() + if err != nil { + fmt.Printf("Namespace error: %s\n", err.Error()) + os.Exit(1) + return + } + configMapList, err := kubeClient.CoreV1().ConfigMaps(namespace).List(metav1.ListOptions{}) + if err != nil { + fmt.Printf("Pods list error: %s\n", err.Error()) + os.Exit(1) + return + } + fmt.Printf("Project %s has %d configmaps.\n", os.Getenv("CE_PROJECT_ID"), len(configMapList.Items)) + +} diff --git a/example/go.mod b/example/go.mod index 20ecfef..e5fa709 100644 --- a/example/go.mod +++ b/example/go.mod @@ -4,10 +4,9 @@ go 1.13 require ( github.com/IBM/code-engine-go-sdk v0.0.0-00010101000000-000000000000 - github.com/IBM/go-sdk-core/v4 v4.6.1 + github.com/IBM/go-sdk-core/v4 v4.10.0 github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef // indirect github.com/go-openapi/errors v0.19.7 // indirect - github.com/go-openapi/strfmt v0.19.6 // indirect github.com/gogo/protobuf v1.3.1 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/googleapis/gnostic v0.3.1 // indirect diff --git a/example/go.sum b/example/go.sum index f4a7bf2..3f8635d 100644 --- a/example/go.sum +++ b/example/go.sum @@ -38,6 +38,8 @@ github.com/IBM/go-sdk-core/v4 v4.6.0 h1:HPaNgDpQJlm0EbJ+8Uo+F2aZiCGNeHNRMdNj3C0A github.com/IBM/go-sdk-core/v4 v4.6.0/go.mod h1:lTUXbqIX6/aAbSCkP6q59+dyFsTwZAc0ewRS2vJWVbg= github.com/IBM/go-sdk-core/v4 v4.6.1 h1:T/ITOcjCU1KEOhkjEjH4oMA9U+6knNUh5eobeOr3+CM= github.com/IBM/go-sdk-core/v4 v4.6.1/go.mod h1:lTUXbqIX6/aAbSCkP6q59+dyFsTwZAc0ewRS2vJWVbg= +github.com/IBM/go-sdk-core/v4 v4.10.0 h1:aLoKusSFVsxMJeKHf8csj9tBWt4Y50kVvfxoKh6scN0= +github.com/IBM/go-sdk-core/v4 v4.10.0/go.mod h1:0uz2ca0MZ2DwsBRGl9Jp3EaCTqxmKZTdvV/CkCB7JnI= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef h1:46PFijGLmAjMPwCCCo7Jf0W6f9slllCkkv7vyc1yOSg= @@ -75,6 +77,8 @@ github.com/go-openapi/strfmt v0.19.5 h1:0utjKrw+BAh8s57XE9Xz8DUBsVvPmRUB6styvl9w github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= github.com/go-openapi/strfmt v0.19.6 h1:epWc+q5qSgsy7A7+/HYyxLF37vLEYdPSkNB9G8mRqjw= github.com/go-openapi/strfmt v0.19.6/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= +github.com/go-openapi/strfmt v0.19.10 h1:FEv6Pt/V4wLwP4vOCZbWlpfmi8kj4UiRip34IDE6SGw= +github.com/go-openapi/strfmt v0.19.10/go.mod h1:qBBipho+3EoIqn6YDI+4RnQEtj6jT/IdKm+PAlXxSUc= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= @@ -169,6 +173,11 @@ github.com/googleapis/gnostic v0.3.1 h1:WeAefnSUHlBb0iJKwxFDZdbfGwkd7xRNuV+IpXMJ github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU= github.com/googleapis/gnostic v0.5.1 h1:A8Yhf6EtqTv9RMsU6MQTyrtV1TjWlR6xU9BsZIwuTCM= github.com/googleapis/gnostic v0.5.1/go.mod h1:6U4PtQXGIEt/Z3h5MAT7FNofLnw9vXk2cUuW7uA/OeU= +github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-retryablehttp v0.6.6 h1:HJunrbHTDDbBb/ay4kxa1n+dLmttUlnP3V9oNE4hmsM= +github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -220,10 +229,12 @@ github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+W github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.1 h1:jMU0WaQrP0a/YAEq8eJmJKjBoMs+pClEr1vDMlM/Do4= github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs= github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -341,6 +352,7 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgN golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up98WAHf3f/ulnJ62IyA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb h1:mUVeFHoDKis5nxCAzoAi7E8Ghb86EXh/RK6wtvJIqRY= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= diff --git a/go.mod b/go.mod index bae87de..a16d805 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,11 @@ module github.com/IBM/code-engine-go-sdk go 1.13 require ( - github.com/IBM/go-sdk-core/v4 v4.5.0 - github.com/go-openapi/strfmt v0.19.5 + github.com/IBM/go-sdk-core/v4 v4.10.0 + github.com/go-openapi/strfmt v0.19.10 github.com/imdario/mergo v0.3.11 // indirect - github.com/onsi/ginkgo v1.14.1 - github.com/onsi/gomega v1.10.2 + github.com/onsi/ginkgo v1.14.2 + github.com/onsi/gomega v1.10.3 github.com/stretchr/testify v1.6.1 golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect k8s.io/api v0.19.2 // indirect diff --git a/go.sum b/go.sum index 314501a..dc40add 100644 --- a/go.sum +++ b/go.sum @@ -2,11 +2,14 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/IBM/go-sdk-core/v4 v4.5.0 h1:gAKmLzRWZjpKoFTYkdyoX5Lh4RkVUag+7xK/0FG/MXc= github.com/IBM/go-sdk-core/v4 v4.5.0/go.mod h1:lTUXbqIX6/aAbSCkP6q59+dyFsTwZAc0ewRS2vJWVbg= +github.com/IBM/go-sdk-core/v4 v4.10.0 h1:aLoKusSFVsxMJeKHf8csj9tBWt4Y50kVvfxoKh6scN0= +github.com/IBM/go-sdk-core/v4 v4.10.0/go.mod h1:0uz2ca0MZ2DwsBRGl9Jp3EaCTqxmKZTdvV/CkCB7JnI= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/aws/aws-sdk-go v1.34.28/go.mod h1:H7NKnBqNVzoTJpGfLrQkkD+ytBA93eiDYi/+8rV9s48= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -35,13 +38,40 @@ github.com/go-openapi/jsonreference v0.0.0-20160704190145-13c6e3589ad9/go.mod h1 github.com/go-openapi/spec v0.0.0-20160808142527-6aced65f8501/go.mod h1:J8+jY1nAiCcj+friV/PDoE1/3eeccG9LYBs0tYvLOWc= github.com/go-openapi/strfmt v0.19.5 h1:0utjKrw+BAh8s57XE9Xz8DUBsVvPmRUB6styvl9wWIM= github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= +github.com/go-openapi/strfmt v0.19.10 h1:FEv6Pt/V4wLwP4vOCZbWlpfmi8kj4UiRip34IDE6SGw= +github.com/go-openapi/strfmt v0.19.10/go.mod h1:qBBipho+3EoIqn6YDI+4RnQEtj6jT/IdKm+PAlXxSUc= github.com/go-openapi/swag v0.0.0-20160704191624-1d0bd113de87/go.mod h1:DXUve3Dpr1UfpPtxFw+EFuQ41HhCWZfha5jSVRG7C7I= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gobuffalo/attrs v0.0.0-20190224210810-a9411de4debd/go.mod h1:4duuawTqi2wkkpB4ePgWMaai6/Kc6WEz83bhFwpHzj0= +github.com/gobuffalo/depgen v0.0.0-20190329151759-d478694a28d3/go.mod h1:3STtPUQYuzV0gBVOY3vy6CfMm/ljR4pABfrTeHNLHUY= +github.com/gobuffalo/depgen v0.1.0/go.mod h1:+ifsuy7fhi15RWncXQQKjWS9JPkdah5sZvtHc2RXGlg= +github.com/gobuffalo/envy v1.6.15/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/envy v1.7.0/go.mod h1:n7DRkBerg/aorDM8kbduw5dN3oXGswK5liaSCx4T5NI= +github.com/gobuffalo/flect v0.1.0/go.mod h1:d2ehjJqGOH/Kjqcoz+F7jHTBbmDb38yXA598Hb50EGs= +github.com/gobuffalo/flect v0.1.1/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/flect v0.1.3/go.mod h1:8JCgGVbRjJhVgD6399mQr4fx5rRfGKVzFjbj6RE/9UI= +github.com/gobuffalo/genny v0.0.0-20190329151137-27723ad26ef9/go.mod h1:rWs4Z12d1Zbf19rlsn0nurr75KqhYp52EAGGxTbBhNk= +github.com/gobuffalo/genny v0.0.0-20190403191548-3ca520ef0d9e/go.mod h1:80lIj3kVJWwOrXWWMRzzdhW3DsrdjILVil/SFKBzF28= +github.com/gobuffalo/genny v0.1.0/go.mod h1:XidbUqzak3lHdS//TPu2OgiFB+51Ur5f7CSnXZ/JDvo= +github.com/gobuffalo/genny v0.1.1/go.mod h1:5TExbEyY48pfunL4QSXxlDOmdsD44RRq4mVZ0Ex28Xk= +github.com/gobuffalo/gitgen v0.0.0-20190315122116-cc086187d211/go.mod h1:vEHJk/E9DmhejeLeNt7UVvlSGv3ziL+djtTr3yyzcOw= +github.com/gobuffalo/gogen v0.0.0-20190315121717-8f38393713f5/go.mod h1:V9QVDIxsgKNZs6L2IYiGR8datgMhB577vzTDqypH360= +github.com/gobuffalo/gogen v0.1.0/go.mod h1:8NTelM5qd8RZ15VjQTFkAW6qOMx5wBbW4dSCS3BY8gg= +github.com/gobuffalo/gogen v0.1.1/go.mod h1:y8iBtmHmGc4qa3urIyo1shvOD8JftTtfcKi+71xfDNE= +github.com/gobuffalo/logger v0.0.0-20190315122211-86e12af44bc2/go.mod h1:QdxcLw541hSGtBnhUc4gaNIXRjiDppFGaDqzbrBd3v8= +github.com/gobuffalo/mapi v1.0.1/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/mapi v1.0.2/go.mod h1:4VAGh89y6rVOvm5A8fKFxYG+wIW6LO1FMTG9hnKStFc= +github.com/gobuffalo/packd v0.0.0-20190315124812-a385830c7fc0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packd v0.1.0/go.mod h1:M2Juc+hhDXf/PnmBANFCqx4DM3wRbgDvnVWeG2RIxq4= +github.com/gobuffalo/packr/v2 v2.0.9/go.mod h1:emmyGweYTm6Kdper+iywB6YK5YzuKchGtJQZ0Odn4pQ= +github.com/gobuffalo/packr/v2 v2.2.0/go.mod h1:CaAwI0GPIAv+5wKLtv8Afwl+Cm78K/I/VCm/3ptBN+0= +github.com/gobuffalo/syncx v0.0.0-20190224160051-33c29581e754/go.mod h1:HhnNqWY95UYwwW3uSASeV7vtgYkT2t16hJgV3AEPUpw= github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls= github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= @@ -58,11 +88,13 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= @@ -70,15 +102,30 @@ github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gnostic v0.4.1 h1:DLJCy1n/vrD4HPjOvYcT8aYQXpPIzoRZONaYwyycI+I= github.com/googleapis/gnostic v0.4.1/go.mod h1:LRhVm6pbyptWbWbuZ38d1eyptfvIytN3ir6b65WBswg= +github.com/hashicorp/go-cleanhttp v0.5.1 h1:dH3aiDG9Jvb5r5+bYHsikaOUIpcM0xvgMXVoDkXMzJM= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= +github.com/hashicorp/go-retryablehttp v0.6.6 h1:HJunrbHTDDbBb/ay4kxa1n+dLmttUlnP3V9oNE4hmsM= +github.com/hashicorp/go-retryablehttp v0.6.6/go.mod h1:vAew36LZh98gCBJNLH42IQ1ER/9wtLZZ8meHqQvEYWY= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/imdario/mergo v0.3.11 h1:3tnifQM4i+fbajXKBHXWEH+KvNHqojZ778UH75j3bGA= github.com/imdario/mergo v0.3.11/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= +github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/karrick/godirwalk v1.8.0/go.mod h1:H5KPZjojv4lE+QYImBI8xVtrBRgYrIVsaRPx4tDPEn4= +github.com/karrick/godirwalk v1.10.3/go.mod h1:RoGL9dQei4vP9ilrpETWE8CLOZ1kiN0LhBygSwrAsHA= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.9.5/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -87,6 +134,8 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/mailru/easyjson v0.0.0-20160728113105-d5b7844b561a/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/markbates/oncer v0.0.0-20181203154359-bf2de49a0be2/go.mod h1:Ld9puTsIW75CHf65OeIOkyKbteujpZVXDpWK6YGZbxE= +github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -95,6 +144,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= @@ -105,31 +155,55 @@ github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+ github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= github.com/onsi/ginkgo v1.14.1 h1:jMU0WaQrP0a/YAEq8eJmJKjBoMs+pClEr1vDMlM/Do4= github.com/onsi/ginkgo v1.14.1/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= +github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M= +github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= github.com/onsi/gomega v0.0.0-20170829124025-dcabb60a477c/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= github.com/onsi/gomega v1.10.2 h1:aY/nuoWlKJud2J6U0E3NWsjlg+0GtwXxgEqthRdzlcs= github.com/onsi/gomega v1.10.2/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= +github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA= +github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= +github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/sirupsen/logrus v1.4.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk= +github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/pflag v0.0.0-20170130214245-9ff6c6923cff/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v0.0.0-20180714160509-73f8eece6fdc/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= go.mongodb.org/mongo-driver v1.0.3 h1:GKoji1ld3tw2aC+GX1wbr/J2fX13yNacEYoJ8Nhr0yU= go.mongodb.org/mongo-driver v1.0.3/go.mod h1:u7ryQJ+DOzQmeO7zB6MHyr8jkEQvC8vH7qLUO4lqsUM= +go.mongodb.org/mongo-driver v1.4.2 h1:WlnEglfTg/PfPq4WXs2Vkl/5ICC6hoG8+r+LraPmGk4= +go.mongodb.org/mongo-driver v1.4.2/go.mod h1:WcMNYLx/IlOxLe6JRJiv2uXuCz6zBLndR4SoGjYphSc= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190422162423-af44ce270edf/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= +golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -142,20 +216,31 @@ golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73r golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 h1:AeiKBIuRw3UomYXSbLy0Mc2dDLfdtbT/IVn4keq83P0= golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200707034311-ab3426394381 h1:VXak5I6aEWmAXeQjA+QSZzlgNrpq9mjcfDemuexIKsU= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0 h1:wBouT66WTYFXdxfVdz9sVWARVd/2vfGcmI45D2gj45M= +golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190419153524-e8e3143a4f4a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -164,6 +249,8 @@ golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 h1:DYfZAGf2WMFjMxbgTjaC+2HC7 golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4 h1:5/PjkGUjvEU5Gl6BxmvKRPpqo2uNMv4rcHBMwzk/st8= golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -177,7 +264,11 @@ golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGm golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190329151228-23e29df326fe/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190416151739-9c9e1878f421/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190420181800-aa740d480789/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190531172133-b3315ee88b7d/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= @@ -199,8 +290,10 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= diff --git a/ibmcloudcodeenginev1/ibm_cloud_code_engine_v1.go b/ibmcloudcodeenginev1/ibm_cloud_code_engine_v1.go index b78b17c..38c5bdc 100644 --- a/ibmcloudcodeenginev1/ibm_cloud_code_engine_v1.go +++ b/ibmcloudcodeenginev1/ibm_cloud_code_engine_v1.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2021. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.12.0-64fe8d3f-20200820-144050 + * IBM OpenAPI SDK Code Generator Version: 3.15.0-45841b53-20201019-214802 */ @@ -23,12 +23,13 @@ package ibmcloudcodeenginev1 import ( + "context" "fmt" common "github.com/IBM/code-engine-go-sdk/common" "github.com/IBM/go-sdk-core/v4/core" ) -// IbmCloudCodeEngineV1 : The purpose is to provide an API to get Kubeconfig for IBM Cloud Code Engine Project +// IbmCloudCodeEngineV1 : The purpose is to provide an API to get Kubeconfig file for IBM Cloud Code Engine Project // // Version: 0.0 type IbmCloudCodeEngineV1 struct { @@ -108,9 +109,30 @@ func (ibmCloudCodeEngine *IbmCloudCodeEngineV1) SetServiceURL(url string) error return ibmCloudCodeEngine.Service.SetServiceURL(url) } -// ListKubeconfig : Retrieve KUBECONFIG for a specified project -// Returns the KUBECONFIG, similar to the output of `kubectl config view --minify=true`. +// GetServiceURL returns the service URL +func (ibmCloudCodeEngine *IbmCloudCodeEngineV1) GetServiceURL() string { + return ibmCloudCodeEngine.Service.GetServiceURL() +} + +// SetEnableGzipCompression sets the service's EnableGzipCompression field +func (ibmCloudCodeEngine *IbmCloudCodeEngineV1) SetEnableGzipCompression(enableGzip bool) { + ibmCloudCodeEngine.Service.SetEnableGzipCompression(enableGzip) +} + +// GetEnableGzipCompression returns the service's EnableGzipCompression field +func (ibmCloudCodeEngine *IbmCloudCodeEngineV1) GetEnableGzipCompression() bool { + return ibmCloudCodeEngine.Service.GetEnableGzipCompression() +} + +// ListKubeconfig : Deprecated soon: Retrieve KUBECONFIG for a specified project +// **Deprecated soon**: This API will be deprecated soon. Use the [GET /project/{id}/config](#get-kubeconfig) API +// instead. Returns the KUBECONFIG file, similar to the output of `kubectl config view --minify=true`. func (ibmCloudCodeEngine *IbmCloudCodeEngineV1) ListKubeconfig(listKubeconfigOptions *ListKubeconfigOptions) (result *string, response *core.DetailedResponse, err error) { + return ibmCloudCodeEngine.ListKubeconfigWithContext(context.Background(), listKubeconfigOptions) +} + +// ListKubeconfigWithContext is an alternate form of the ListKubeconfig method which supports a Context parameter +func (ibmCloudCodeEngine *IbmCloudCodeEngineV1) ListKubeconfigWithContext(ctx context.Context, listKubeconfigOptions *ListKubeconfigOptions) (result *string, response *core.DetailedResponse, err error) { err = core.ValidateNotNil(listKubeconfigOptions, "listKubeconfigOptions cannot be nil") if err != nil { return @@ -120,11 +142,14 @@ func (ibmCloudCodeEngine *IbmCloudCodeEngineV1) ListKubeconfig(listKubeconfigOpt return } - pathSegments := []string{"namespaces", "config"} - pathParameters := []string{*listKubeconfigOptions.ID} + pathParamsMap := map[string]string{ + "id": *listKubeconfigOptions.ID, + } builder := core.NewRequestBuilder(core.GET) - _, err = builder.ConstructHTTPURL(ibmCloudCodeEngine.Service.Options.URL, pathSegments, pathParameters) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = ibmCloudCodeEngine.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(ibmCloudCodeEngine.Service.Options.URL, `/namespaces/{id}/config`, pathParamsMap) if err != nil { return } @@ -137,7 +162,7 @@ func (ibmCloudCodeEngine *IbmCloudCodeEngineV1) ListKubeconfig(listKubeconfigOpt for headerName, headerValue := range sdkHeaders { builder.AddHeader(headerName, headerValue) } - builder.AddHeader("Accept", "text/html") + builder.AddHeader("Accept", "text/plain") if listKubeconfigOptions.RefreshToken != nil { builder.AddHeader("Refresh-Token", fmt.Sprint(*listKubeconfigOptions.RefreshToken)) } @@ -155,16 +180,139 @@ func (ibmCloudCodeEngine *IbmCloudCodeEngineV1) ListKubeconfig(listKubeconfigOpt return } +// GetKubeconfig : Retrieve KUBECONFIG for a specified project +// Returns the KUBECONFIG, similar to the output of `kubectl config view --minify=true`. There are 2 tokens in the +// Request Header and a query parameter that you must provide. +// These values can be generated as follows: 1. Auth Header Pass the generated IAM Token as the Authorization header +// from the CLI as `token=cat $HOME/.bluemix/config.json | jq .IAMToken -r`. Generate the token with the [Create an IAM +// access token for a user or service ID using an API +// key](https://cloud.ibm.com/apidocs/iam-identity-token-api#gettoken-apikey) API. +// +// 2. X-Delegated-Refresh-Token Header Generate an IAM Delegated Refresh Token for Code Engine with the [Create an IAM +// access token and delegated refresh token for a user or service +// ID](https://cloud.ibm.com/apidocs/iam-identity-token-api#gettoken-apikey-delegatedrefreshtoken) API. Specify the +// `receiver_client_ids` value to be `ce` and the `delegated_refresh_token_expiry` value to be `3600`. +// +// 3. Project ID In order to retrieve the Kubeconfig file for a specific Code Engine project, use the CLI to extract the +// ID +// `id=ibmcloud ce project get -n ${CE_PROJECT_NAME} -o jsonpath={.guid}` You must be logged into the account where the +// project was created to retrieve the ID. +func (ibmCloudCodeEngine *IbmCloudCodeEngineV1) GetKubeconfig(getKubeconfigOptions *GetKubeconfigOptions) (result *string, response *core.DetailedResponse, err error) { + return ibmCloudCodeEngine.GetKubeconfigWithContext(context.Background(), getKubeconfigOptions) +} + +// GetKubeconfigWithContext is an alternate form of the GetKubeconfig method which supports a Context parameter +func (ibmCloudCodeEngine *IbmCloudCodeEngineV1) GetKubeconfigWithContext(ctx context.Context, getKubeconfigOptions *GetKubeconfigOptions) (result *string, response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(getKubeconfigOptions, "getKubeconfigOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(getKubeconfigOptions, "getKubeconfigOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "id": *getKubeconfigOptions.ID, + } + + builder := core.NewRequestBuilder(core.GET) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = ibmCloudCodeEngine.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(ibmCloudCodeEngine.Service.Options.URL, `/project/{id}/config`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range getKubeconfigOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("ibm_cloud_code_engine", "V1", "GetKubeconfig") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + builder.AddHeader("Accept", "text/plain") + if getKubeconfigOptions.XDelegatedRefreshToken != nil { + builder.AddHeader("X-Delegated-Refresh-Token", fmt.Sprint(*getKubeconfigOptions.XDelegatedRefreshToken)) + } + if getKubeconfigOptions.Accept != nil { + builder.AddHeader("Accept", fmt.Sprint(*getKubeconfigOptions.Accept)) + } + + request, err := builder.Build() + if err != nil { + return + } + + response, err = ibmCloudCodeEngine.Service.Request(request, &result) + + return +} + +// GetKubeconfigOptions : The GetKubeconfig options. +type GetKubeconfigOptions struct { + // This IAM Delegated Refresh Token is specifically valid for Code Engine. Generate this token with the [Create an IAM + // access token and delegated refresh token for a user or service + // ID](https://cloud.ibm.com/apidocs/iam-identity-token-api#gettoken-apikey-delegatedrefreshtoken) API. Specify the + // `receiver_client_ids` value to be `ce` and the `delegated_refresh_token_expiry` value to be `3600`. + XDelegatedRefreshToken *string `json:"X-Delegated-Refresh-Token" validate:"required"` + + // The id of the IBM Cloud Code Engine project. + ID *string `json:"id" validate:"required,ne="` + + // The type of the response: text/plain or application/json. A character encoding can be specified by including a + // `charset` parameter. For example, 'text/plain;charset=utf-8'. + Accept *string `json:"Accept,omitempty"` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewGetKubeconfigOptions : Instantiate GetKubeconfigOptions +func (*IbmCloudCodeEngineV1) NewGetKubeconfigOptions(xDelegatedRefreshToken string, id string) *GetKubeconfigOptions { + return &GetKubeconfigOptions{ + XDelegatedRefreshToken: core.StringPtr(xDelegatedRefreshToken), + ID: core.StringPtr(id), + } +} + +// SetXDelegatedRefreshToken : Allow user to set XDelegatedRefreshToken +func (options *GetKubeconfigOptions) SetXDelegatedRefreshToken(xDelegatedRefreshToken string) *GetKubeconfigOptions { + options.XDelegatedRefreshToken = core.StringPtr(xDelegatedRefreshToken) + return options +} + +// SetID : Allow user to set ID +func (options *GetKubeconfigOptions) SetID(id string) *GetKubeconfigOptions { + options.ID = core.StringPtr(id) + return options +} + +// SetAccept : Allow user to set Accept +func (options *GetKubeconfigOptions) SetAccept(accept string) *GetKubeconfigOptions { + options.Accept = core.StringPtr(accept) + return options +} + +// SetHeaders : Allow user to set Headers +func (options *GetKubeconfigOptions) SetHeaders(param map[string]string) *GetKubeconfigOptions { + options.Headers = param + return options +} + // ListKubeconfigOptions : The ListKubeconfig options. type ListKubeconfigOptions struct { - // The IAM Refresh token associated with the IBM Cloud account. + // The IAM Refresh token associated with the IBM Cloud account. To retrieve your IAM token, run `ibmcloud iam + // oauth-tokens`. RefreshToken *string `json:"Refresh-Token" validate:"required"` - // The id of the IBM Cloud Code Engine project. - ID *string `json:"id" validate:"required"` + // The id of the IBM Cloud Code Engine project. To retrieve your project ID, run `ibmcloud ce project get -n + // `. + ID *string `json:"id" validate:"required,ne="` - // The type of the response: text/html or application/json. A character encoding can be specified by including a - // `charset` parameter. For example, 'text/html;charset=utf-8'. + // The type of the response: text/plain or application/json. A character encoding can be specified by including a + // `charset` parameter. For example, 'text/plain;charset=utf-8'. Accept *string `json:"Accept,omitempty"` // Allows users to set headers on API requests diff --git a/ibmcloudcodeenginev1/ibm_cloud_code_engine_v1_suite_test.go b/ibmcloudcodeenginev1/ibm_cloud_code_engine_v1_suite_test.go index cb26ff1..a5d706e 100644 --- a/ibmcloudcodeenginev1/ibm_cloud_code_engine_v1_suite_test.go +++ b/ibmcloudcodeenginev1/ibm_cloud_code_engine_v1_suite_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2021. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/ibmcloudcodeenginev1/ibm_cloud_code_engine_v1_test.go b/ibmcloudcodeenginev1/ibm_cloud_code_engine_v1_test.go index 46e878e..e218e48 100644 --- a/ibmcloudcodeenginev1/ibm_cloud_code_engine_v1_test.go +++ b/ibmcloudcodeenginev1/ibm_cloud_code_engine_v1_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2020. + * (C) Copyright IBM Corp. 2021. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ package ibmcloudcodeenginev1_test import ( "bytes" + "context" "fmt" "github.com/IBM/code-engine-go-sdk/ibmcloudcodeenginev1" "github.com/IBM/go-sdk-core/v4/core" @@ -143,13 +144,18 @@ var _ = Describe(`IbmCloudCodeEngineV1`, func() { defer GinkgoRecover() // Verify the contents of the request - Expect(req.URL.Path).To(Equal(listKubeconfigPath)) + Expect(req.URL.EscapedPath()).To(Equal(listKubeconfigPath)) Expect(req.Method).To(Equal("GET")) + Expect(req.Header["Refresh-Token"]).ToNot(BeNil()) Expect(req.Header["Refresh-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) Expect(req.Header["Accept"]).ToNot(BeNil()) - Expect(req.Header["Accept"][0]).To(Equal(fmt.Sprintf("%v", "text/html"))) - res.Header().Set("Content-type", "text/html") + Expect(req.Header["Accept"][0]).To(Equal(fmt.Sprintf("%v", "text/plain"))) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "text/plain") res.WriteHeader(200) fmt.Fprintf(res, "%s", `"OperationResponse"`) })) @@ -172,7 +178,7 @@ var _ = Describe(`IbmCloudCodeEngineV1`, func() { listKubeconfigOptionsModel := new(ibmcloudcodeenginev1.ListKubeconfigOptions) listKubeconfigOptionsModel.RefreshToken = core.StringPtr("testString") listKubeconfigOptionsModel.ID = core.StringPtr("testString") - listKubeconfigOptionsModel.Accept = core.StringPtr("text/html") + listKubeconfigOptionsModel.Accept = core.StringPtr("text/plain") listKubeconfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -180,6 +186,13 @@ var _ = Describe(`IbmCloudCodeEngineV1`, func() { Expect(operationErr).To(BeNil()) Expect(response).ToNot(BeNil()) Expect(result).ToNot(BeNil()) + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr = ibmCloudCodeEngineService.ListKubeconfigWithContext(ctx, listKubeconfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) }) It(`Invoke ListKubeconfig with error: Operation validation and request error`, func() { ibmCloudCodeEngineService, serviceErr := ibmcloudcodeenginev1.NewIbmCloudCodeEngineV1(&ibmcloudcodeenginev1.IbmCloudCodeEngineV1Options{ @@ -193,7 +206,7 @@ var _ = Describe(`IbmCloudCodeEngineV1`, func() { listKubeconfigOptionsModel := new(ibmcloudcodeenginev1.ListKubeconfigOptions) listKubeconfigOptionsModel.RefreshToken = core.StringPtr("testString") listKubeconfigOptionsModel.ID = core.StringPtr("testString") - listKubeconfigOptionsModel.Accept = core.StringPtr("text/html") + listKubeconfigOptionsModel.Accept = core.StringPtr("text/plain") listKubeconfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := ibmCloudCodeEngineService.SetServiceURL("") @@ -216,12 +229,121 @@ var _ = Describe(`IbmCloudCodeEngineV1`, func() { }) }) }) + + Describe(`GetKubeconfig(getKubeconfigOptions *GetKubeconfigOptions)`, func() { + getKubeconfigPath := "/project/testString/config" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(getKubeconfigPath)) + Expect(req.Method).To(Equal("GET")) + + Expect(req.Header["X-Delegated-Refresh-Token"]).ToNot(BeNil()) + Expect(req.Header["X-Delegated-Refresh-Token"][0]).To(Equal(fmt.Sprintf("%v", "testString"))) + Expect(req.Header["Accept"]).ToNot(BeNil()) + Expect(req.Header["Accept"][0]).To(Equal(fmt.Sprintf("%v", "text/plain"))) + // Sleep a short time to support a timeout test + time.Sleep(100 * time.Millisecond) + + // Set mock response + res.Header().Set("Content-type", "text/plain") + res.WriteHeader(200) + fmt.Fprintf(res, "%s", `"OperationResponse"`) + })) + }) + It(`Invoke GetKubeconfig successfully`, func() { + ibmCloudCodeEngineService, serviceErr := ibmcloudcodeenginev1.NewIbmCloudCodeEngineV1(&ibmcloudcodeenginev1.IbmCloudCodeEngineV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(ibmCloudCodeEngineService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + result, response, operationErr := ibmCloudCodeEngineService.GetKubeconfig(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + + // Construct an instance of the GetKubeconfigOptions model + getKubeconfigOptionsModel := new(ibmcloudcodeenginev1.GetKubeconfigOptions) + getKubeconfigOptionsModel.XDelegatedRefreshToken = core.StringPtr("testString") + getKubeconfigOptionsModel.ID = core.StringPtr("testString") + getKubeconfigOptionsModel.Accept = core.StringPtr("text/plain") + getKubeconfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + result, response, operationErr = ibmCloudCodeEngineService.GetKubeconfig(getKubeconfigOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + Expect(result).ToNot(BeNil()) + + // Invoke operation with a Context to test a timeout error + ctx, cancelFunc := context.WithTimeout(context.Background(), 80*time.Millisecond) + defer cancelFunc() + _, _, operationErr = ibmCloudCodeEngineService.GetKubeconfigWithContext(ctx, getKubeconfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring("deadline exceeded")) + }) + It(`Invoke GetKubeconfig with error: Operation validation and request error`, func() { + ibmCloudCodeEngineService, serviceErr := ibmcloudcodeenginev1.NewIbmCloudCodeEngineV1(&ibmcloudcodeenginev1.IbmCloudCodeEngineV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(ibmCloudCodeEngineService).ToNot(BeNil()) + + // Construct an instance of the GetKubeconfigOptions model + getKubeconfigOptionsModel := new(ibmcloudcodeenginev1.GetKubeconfigOptions) + getKubeconfigOptionsModel.XDelegatedRefreshToken = core.StringPtr("testString") + getKubeconfigOptionsModel.ID = core.StringPtr("testString") + getKubeconfigOptionsModel.Accept = core.StringPtr("text/plain") + getKubeconfigOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := ibmCloudCodeEngineService.SetServiceURL("") + Expect(err).To(BeNil()) + result, response, operationErr := ibmCloudCodeEngineService.GetKubeconfig(getKubeconfigOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + // Construct a second instance of the GetKubeconfigOptions model with no property values + getKubeconfigOptionsModelNew := new(ibmcloudcodeenginev1.GetKubeconfigOptions) + // Invoke operation with invalid model (negative test) + result, response, operationErr = ibmCloudCodeEngineService.GetKubeconfig(getKubeconfigOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + Expect(result).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`Model constructor tests`, func() { Context(`Using a service client instance`, func() { ibmCloudCodeEngineService, _ := ibmcloudcodeenginev1.NewIbmCloudCodeEngineV1(&ibmcloudcodeenginev1.IbmCloudCodeEngineV1Options{ URL: "http://ibmcloudcodeenginev1modelgenerator.com", Authenticator: &core.NoAuthAuthenticator{}, }) + It(`Invoke NewGetKubeconfigOptions successfully`, func() { + // Construct an instance of the GetKubeconfigOptions model + xDelegatedRefreshToken := "testString" + id := "testString" + getKubeconfigOptionsModel := ibmCloudCodeEngineService.NewGetKubeconfigOptions(xDelegatedRefreshToken, id) + getKubeconfigOptionsModel.SetXDelegatedRefreshToken("testString") + getKubeconfigOptionsModel.SetID("testString") + getKubeconfigOptionsModel.SetAccept("text/plain") + getKubeconfigOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(getKubeconfigOptionsModel).ToNot(BeNil()) + Expect(getKubeconfigOptionsModel.XDelegatedRefreshToken).To(Equal(core.StringPtr("testString"))) + Expect(getKubeconfigOptionsModel.ID).To(Equal(core.StringPtr("testString"))) + Expect(getKubeconfigOptionsModel.Accept).To(Equal(core.StringPtr("text/plain"))) + Expect(getKubeconfigOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewListKubeconfigOptions successfully`, func() { // Construct an instance of the ListKubeconfigOptions model refreshToken := "testString" @@ -229,12 +351,12 @@ var _ = Describe(`IbmCloudCodeEngineV1`, func() { listKubeconfigOptionsModel := ibmCloudCodeEngineService.NewListKubeconfigOptions(refreshToken, id) listKubeconfigOptionsModel.SetRefreshToken("testString") listKubeconfigOptionsModel.SetID("testString") - listKubeconfigOptionsModel.SetAccept("text/html") + listKubeconfigOptionsModel.SetAccept("text/plain") listKubeconfigOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listKubeconfigOptionsModel).ToNot(BeNil()) Expect(listKubeconfigOptionsModel.RefreshToken).To(Equal(core.StringPtr("testString"))) Expect(listKubeconfigOptionsModel.ID).To(Equal(core.StringPtr("testString"))) - Expect(listKubeconfigOptionsModel.Accept).To(Equal(core.StringPtr("text/html"))) + Expect(listKubeconfigOptionsModel.Accept).To(Equal(core.StringPtr("text/plain"))) Expect(listKubeconfigOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) })