forked from IBM-Cloud/terraform-provider-ibm
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c19e32
commit 97bf42b
Showing
11 changed files
with
82,559 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Makefile | ||
|
||
all: build lint tidy | ||
|
||
travis-ci: build lint tidy test-unit | ||
|
||
build: | ||
go build ./vpcv1 | ||
|
||
test-unit: | ||
go test `go list ./... | grep vpcv1` -v -tags=unit | ||
|
||
test-integration: | ||
go test `go list ./... | grep vpcv1` -v -tags=integration -skipForMockTesting -testCount | ||
|
||
test-examples: | ||
go test `go list ./... | grep vpcv1` -v -tags=examples | ||
|
||
lint: | ||
golangci-lint --timeout=2m run | ||
|
||
tidy: | ||
go mod tidy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package common | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
) | ||
|
||
const ( | ||
HEADER_NAME_USER_AGENT = "User-Agent" | ||
|
||
SDK_NAME = "vpc-go-sdk" | ||
) | ||
|
||
// | ||
// GetSdkHeaders - returns the set of SDK-specific headers to be included in an outgoing request. | ||
// | ||
// This function is invoked by generated service methods (i.e. methods which implement the REST API operations | ||
// defined within the API definition). The purpose of this function is to give the SDK implementor the opportunity | ||
// to provide SDK-specific HTTP headers that will be sent with an outgoing REST API request. | ||
// This function is invoked for each invocation of a generated service method, | ||
// so the set of HTTP headers could be request-specific. | ||
// As an optimization, if your SDK will be returning the same set of HTTP headers for each invocation of this | ||
// function, it is recommended that you initialize the returned map just once (perhaps by using | ||
// lazy initialization) and simply return it each time the function is invoked, instead of building it each time | ||
// as in the example below. | ||
// | ||
// Parameters: | ||
// serviceName - the name of the service as defined in the API definition (e.g. "MyService1") | ||
// serviceVersion - the version of the service as defined in the API definition (e.g. "V1") | ||
// operationId - the operationId as defined in the API definition (e.g. getContext) | ||
// | ||
// Returns: | ||
// a Map which contains the set of headers to be included in the REST API request | ||
// | ||
func GetSdkHeaders(serviceName string, serviceVersion string, operationId string) map[string]string { | ||
sdkHeaders := make(map[string]string) | ||
|
||
sdkHeaders[HEADER_NAME_USER_AGENT] = GetUserAgentInfo() | ||
|
||
return sdkHeaders | ||
} | ||
|
||
var userAgent string = fmt.Sprintf("%s-%s %s", SDK_NAME, Version, GetSystemInfo()) | ||
|
||
func GetUserAgentInfo() string { | ||
return userAgent | ||
} | ||
|
||
var systemInfo = fmt.Sprintf("(arch=%s; os=%s; go.version=%s)", runtime.GOARCH, runtime.GOOS, runtime.Version()) | ||
|
||
func GetSystemInfo() string { | ||
return systemInfo | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package common | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func TestGetSystemInfo(t *testing.T) { | ||
var sysinfo = GetSystemInfo() | ||
assert.NotNil(t, sysinfo) | ||
assert.True(t, strings.Contains(sysinfo, "arch=")) | ||
assert.True(t, strings.Contains(sysinfo, "os=")) | ||
assert.True(t, strings.Contains(sysinfo, "go.version=")) | ||
} | ||
|
||
func TestGetSdkHeaders(t *testing.T) { | ||
var headers = GetSdkHeaders("myService", "v123", "myOperation") | ||
assert.NotNil(t, headers) | ||
|
||
var foundIt bool | ||
|
||
_, foundIt = headers[HEADER_NAME_USER_AGENT] | ||
assert.True(t, foundIt) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package common | ||
|
||
// Version of the SDK | ||
const Version = "0.6.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module github.com/IBM/vpc-go-sdk | ||
|
||
go 1.14 | ||
|
||
require ( | ||
github.com/IBM/go-sdk-core/v5 v5.7.2 | ||
github.com/go-openapi/strfmt v0.20.2 | ||
github.com/onsi/ginkgo v1.14.2 | ||
github.com/onsi/gomega v1.10.5 | ||
github.com/stretchr/testify v1.7.0 | ||
) |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.