Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Services Unittests #184

Merged
merged 16 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
8 changes: 4 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.19.x]
go-version: [1.21.x]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -31,7 +31,7 @@ jobs:
if: success()
uses: actions/setup-go@v1
with:
go-version: 1.19.x
go-version: 1.21.x
- name: Checkout code
uses: actions/checkout@v1
- name: Calc coverage
Expand All @@ -57,10 +57,10 @@ jobs:
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.19
- name: Set up Go 1.21
uses: actions/setup-go@v1
with:
go-version: 1.19
go-version: 1.21
id: go

- name: Check out code into the Go module directory
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@ _testmain.go
*.test
*.prof
*.DS_STORE

# Git vendor things
vendor/
40 changes: 12 additions & 28 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
GO_CMD=go
GO_BUILD=$(GO_CMD) build
GO_DEPS=$(GO_CMD) get -d -v
GO_DEPS_UPDATE=$(GO_DEPS) -u
GO_FMT=gofmt
GO_INSTALL=$(GO_CMD) install
GO_RUN=$(GO_CMD) run
GO_TEST=$(GO_CMD) test
TOOLS=$(GO_RUN) tools/main.go tools/loadmeta.go tools/common.go tools/version.go

TOOLS=go run ./tools
VETARGS?=-all
COVERPROFILE=coverage.out

PACKAGE_LIST := $$(go list ./... | grep -v '/vendor/')

.PHONY: all alpha build deps fmt fmtcheck generate install release test coverage test_deps update_deps version vet
.PHONY: all alpha build deps fmt fmtcheck generate release test coverage version vet

all: build

Expand All @@ -23,26 +16,23 @@ alpha:
git push

build: fmtcheck vet deps
$(GO_BUILD) ./...
go build ./...

deps:
$(GO_DEPS) ./...
go mod vendor

fmt:
@$(GO_FMT) -w `find . -name '*.go' | grep -v vendor`
gofmt -w `find . -name '*.go' | grep -v vendor`

fmtcheck:
@fmt_list=$$($(GO_FMT) -e -l `find . -name '*.go' | grep -v vendor`) && \
@fmt_list=$$(gofmt -e -l `find . -name '*.go' | grep -v vendor`) && \
[ -z $${fmt_list} ] || \
(echo "gofmt needs to be run on the following files:" \
&& echo "$${fmt_list}" && \
echo "You can run 'make fmt' to format code" && false)

generate:
@$(TOOLS) generate

install: fmtcheck deps
@$(GO_INSTALL) ./...
go run ./tools generate

release: build
@NEW_VERSION=$$($(TOOLS) version --bump patch) && \
Expand All @@ -52,20 +42,14 @@ release: build
git push && \
git push origin $${NEW_VERSION}

test: fmtcheck vet test_deps
@$(GO_TEST) $(PACKAGE_LIST) -timeout=30s -parallel=4
test: fmtcheck vet deps
go test $(PACKAGE_LIST) -timeout=30s

coverage:
@echo "Running unit tests. Cover profile saved to $(COVERPROFILE) ...\n"
@$(GO_TEST) $(PACKAGE_LIST) -timeout=30s -parallel=4 -coverprofile=$(COVERPROFILE)
go test $(PACKAGE_LIST) -timeout=30s -coverprofile=$(COVERPROFILE)
@echo "\nBuilding function coverage report...\n"
@$(GO_CMD) tool cover -func=$(COVERPROFILE)

test_deps:
$(GO_DEPS) -t ./...

update_deps:
$(GO_DEPS_UPDATE) ./...
go tool cover -func=$(COVERPROFILE)

version:
@$(TOOLS) version
Expand Down
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# softlayer-go

[![Build Status](https://travis-ci.org/softlayer/softlayer-go.svg?branch=master)](https://travis-ci.org/softlayer/softlayer-go)
[![Build Status](hhttps://github.com/softlayer/softlayer-go/actions/workflows/go/badge.svg?branch=master)](https://github.com/softlayer/softlayer-go/actions/workflows/go.yml)
[![GoDoc](https://godoc.org/github.com/softlayer/softlayer-go?status.svg)](https://godoc.org/github.com/softlayer/softlayer-go)
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](http://www.apache.org/licenses/LICENSE-2.0)
![Tests](https://github.com/softlayer/softlayer-go/workflows/Tests/badge.svg)
[![Coverage Status](https://coveralls.io/repos/github/softlayer/softlayer-go/badge.svg?branch=master)](https://coveralls.io/github/softlayer/softlayer-go?branch=master)

The Official and Complete SoftLayer API Client for Golang (the Go programming language).
Expand Down Expand Up @@ -326,6 +325,23 @@ func main() {
}
```

## Running Examples

The [Examples](https://github.com/softlayer/softlayer-go/tree/master/examples) directory has a few rough examples scripts that can help you get started developing with this library.

The Examples have their own modules since there are a few dependencies here not needed in the normal softlayer-go repo.
The following will get you started:

```bash
cd examples
go mod vendor
go run main.go --help
```

The examples use [SPF13's Cobra Command](https://github.com/spf13/cobra) library to build little command examples, which should be easy enough to
expand upon if needed. The [SoftLayer-CLI](https://github.com/softlayer/softlayer-cli) project is also a good example of how to use the softlayer-go library.


## Development

### Setup
Expand Down Expand Up @@ -379,10 +395,10 @@ make generate

(manually)
```bash
go run tools/main.go tools/loadmeta.go tools/common.go tools/version.go generate
go run ./tools generate
```


## Copyright

This software is Copyright (c) 2016 IBM Corp. See the bundled LICENSE file for more information.
This software is Copyright (c) 2016-2024 IBM Corp. See the bundled LICENSE file for more information.
21 changes: 7 additions & 14 deletions datatypes/abuse.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
/**
* Copyright 2016 IBM Corp.
* Copyright 2016-2024 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/

/**
* AUTOMATICALLY GENERATED CODE - DO NOT MODIFY
*/
// AUTOMATICALLY GENERATED CODE - DO NOT MODIFY

package datatypes

Expand Down
69 changes: 38 additions & 31 deletions datatypes/account.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
/**
* Copyright 2016 IBM Corp.
* Copyright 2016-2024 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed
* on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and limitations under the License.
*/

/**
* AUTOMATICALLY GENERATED CODE - DO NOT MODIFY
*/
// AUTOMATICALLY GENERATED CODE - DO NOT MODIFY

package datatypes

Expand Down Expand Up @@ -352,13 +345,6 @@ type Account struct {
// A count of the DNS domains associated with an account.
DomainCount *uint `json:"domainCount,omitempty" xmlrpc:"domainCount,omitempty"`

// A count of
DomainRegistrationCount *uint `json:"domainRegistrationCount,omitempty" xmlrpc:"domainRegistrationCount,omitempty"`

// no documentation yet
// Deprecated: This function has been marked as deprecated.
DomainRegistrations []Dns_Domain_Registration `json:"domainRegistrations,omitempty" xmlrpc:"domainRegistrations,omitempty"`

// The DNS domains associated with an account.
Domains []Dns_Domain `json:"domains,omitempty" xmlrpc:"domains,omitempty"`

Expand Down Expand Up @@ -1267,9 +1253,11 @@ type Account struct {
SubnetRegistrationDetailCount *uint `json:"subnetRegistrationDetailCount,omitempty" xmlrpc:"subnetRegistrationDetailCount,omitempty"`

// no documentation yet
// Deprecated: This function has been marked as deprecated.
SubnetRegistrationDetails []Account_Regional_Registry_Detail `json:"subnetRegistrationDetails,omitempty" xmlrpc:"subnetRegistrationDetails,omitempty"`

// no documentation yet
// Deprecated: This function has been marked as deprecated.
SubnetRegistrations []Network_Subnet_Registration `json:"subnetRegistrations,omitempty" xmlrpc:"subnetRegistrations,omitempty"`

// All network subnets associated with an account.
Expand Down Expand Up @@ -2616,10 +2604,12 @@ type Account_ProofOfConcept_Funding_Type struct {
KeyName *string `json:"keyName,omitempty" xmlrpc:"keyName,omitempty"`
}

// The subnet registration detail type has been deprecated.
type Account_Regional_Registry_Detail struct {
Entity

// The account that this detail object belongs to.
// [Deprecated] The account that this detail object belongs to.
// Deprecated: This function has been marked as deprecated.
Account *Account `json:"account,omitempty" xmlrpc:"account,omitempty"`

// The detail object's associated [[SoftLayer_Account|account]] id
Expand All @@ -2628,16 +2618,18 @@ type Account_Regional_Registry_Detail struct {
// The date and time the detail object was created
CreateDate *Time `json:"createDate,omitempty" xmlrpc:"createDate,omitempty"`

// A count of references to the [[SoftLayer_Network_Subnet_Registration|registration objects]] that consume this detail object.
// A count of [Deprecated] References to the [[SoftLayer_Network_Subnet_Registration|registration objects]] that consume this detail object.
DetailCount *uint `json:"detailCount,omitempty" xmlrpc:"detailCount,omitempty"`

// The associated type of this detail object.
// [Deprecated] The associated type of this detail object.
// Deprecated: This function has been marked as deprecated.
DetailType *Account_Regional_Registry_Detail_Type `json:"detailType,omitempty" xmlrpc:"detailType,omitempty"`

// The detail object's associated [[SoftLayer_Account_Regional_Registry_Detail_Type|type]] id
DetailTypeId *int `json:"detailTypeId,omitempty" xmlrpc:"detailTypeId,omitempty"`

// References to the [[SoftLayer_Network_Subnet_Registration|registration objects]] that consume this detail object.
// [Deprecated] References to the [[SoftLayer_Network_Subnet_Registration|registration objects]] that consume this detail object.
// Deprecated: This function has been marked as deprecated.
Details []Network_Subnet_Registration_Details `json:"details,omitempty" xmlrpc:"details,omitempty"`

// Unique ID of the detail object
Expand All @@ -2646,27 +2638,32 @@ type Account_Regional_Registry_Detail struct {
// The date and time the detail object was last modified
ModifyDate *Time `json:"modifyDate,omitempty" xmlrpc:"modifyDate,omitempty"`

// The individual properties that define this detail object's values.
// [Deprecated] The individual properties that define this detail object's values.
// Deprecated: This function has been marked as deprecated.
Properties []Account_Regional_Registry_Detail_Property `json:"properties,omitempty" xmlrpc:"properties,omitempty"`

// A count of the individual properties that define this detail object's values.
// A count of [Deprecated] The individual properties that define this detail object's values.
PropertyCount *uint `json:"propertyCount,omitempty" xmlrpc:"propertyCount,omitempty"`

// The associated RWhois handle of this detail object. Used only when detailed reassignments are necessary.
// [Deprecated] The associated RWhois handle of this detail object. Used only when detailed reassignments are necessary.
// Deprecated: This function has been marked as deprecated.
RegionalInternetRegistryHandle *Account_Rwhois_Handle `json:"regionalInternetRegistryHandle,omitempty" xmlrpc:"regionalInternetRegistryHandle,omitempty"`

// The detail object's associated [[SoftLayer_Account_Rwhois_Handle|RIR handle]] id
RegionalInternetRegistryHandleId *int `json:"regionalInternetRegistryHandleId,omitempty" xmlrpc:"regionalInternetRegistryHandleId,omitempty"`
}

// The subnet registration detail property type has been deprecated.
//
// Subnet registration properties are used to define various attributes of the [[SoftLayer_Account_Regional_Registry_Detail|detail objects]]. These properties are defined by the [[SoftLayer_Account_Regional_Registry_Detail_Property_Type]] objects, which describe the available value formats.
type Account_Regional_Registry_Detail_Property struct {
Entity

// no documentation yet
CreateDate *Time `json:"createDate,omitempty" xmlrpc:"createDate,omitempty"`

// The [[SoftLayer_Account_Regional_Registry_Detail]] object this property belongs to
// [Deprecated] The [[SoftLayer_Account_Regional_Registry_Detail]] object this property belongs to
// Deprecated: This function has been marked as deprecated.
Detail *Account_Regional_Registry_Detail `json:"detail,omitempty" xmlrpc:"detail,omitempty"`

// Unique ID of the property object
Expand All @@ -2675,7 +2672,8 @@ type Account_Regional_Registry_Detail_Property struct {
// no documentation yet
ModifyDate *Time `json:"modifyDate,omitempty" xmlrpc:"modifyDate,omitempty"`

// The [[SoftLayer_Account_Regional_Registry_Detail_Property_Type]] object this property belongs to
// [Deprecated] The [[SoftLayer_Account_Regional_Registry_Detail_Property_Type]] object this property belongs to
// Deprecated: This function has been marked as deprecated.
PropertyType *Account_Regional_Registry_Detail_Property_Type `json:"propertyType,omitempty" xmlrpc:"propertyType,omitempty"`

// The numeric ID of the related [[SoftLayer_Account_Regional_Registry_Detail_Property_Type|property type object]]
Expand All @@ -2691,6 +2689,8 @@ type Account_Regional_Registry_Detail_Property struct {
Value *string `json:"value,omitempty" xmlrpc:"value,omitempty"`
}

// The subnet registration detail property type type has been deprecated.
//
// Subnet Registration Detail Property Type objects describe the nature of a [[SoftLayer_Account_Regional_Registry_Detail_Property]] object. These types use [http://php.net/pcre.pattern.php Perl-Compatible Regular Expressions] to validate the value of a property object.
type Account_Regional_Registry_Detail_Property_Type struct {
Entity
Expand All @@ -2714,6 +2714,8 @@ type Account_Regional_Registry_Detail_Property_Type struct {
ValueExpression *string `json:"valueExpression,omitempty" xmlrpc:"valueExpression,omitempty"`
}

// The subnet registration detail type type has been deprecated.
//
// Subnet Registration Detail Type objects describe the nature of a [[SoftLayer_Account_Regional_Registry_Detail]] object.
//
// The standard values for these objects are as follows: <ul> <li><strong>NETWORK</strong> - The detail object represents the information for a [[SoftLayer_Network_Subnet|subnet]]</li> <li><strong>NETWORK6</strong> - The detail object represents the information for an [[SoftLayer_Network_Subnet_Version6|IPv6 subnet]]</li> <li><strong>PERSON</strong> - The detail object represents the information for a customer with the RIR</li> </ul>
Expand All @@ -2736,6 +2738,8 @@ type Account_Regional_Registry_Detail_Type struct {
Name *string `json:"name,omitempty" xmlrpc:"name,omitempty"`
}

// The subnet registration default person detail type has been deprecated.
//
// The SoftLayer_Account_Regional_Registry_Detail_Version4_Person_Default data type contains general information relating to a single SoftLayer RIR account. RIR account information in this type such as names, addresses, and phone numbers are assigned to the registry only and not to users belonging to the account.
type Account_Regional_Registry_Detail_Version4_Person_Default struct {
Account_Regional_Registry_Detail
Expand Down Expand Up @@ -2809,11 +2813,14 @@ type Account_Reports_Request struct {
UsrRecordId *int `json:"usrRecordId,omitempty" xmlrpc:"usrRecordId,omitempty"`
}

// The subnet registration handle type has been deprecated.
//
// Provides a means of tracking handle identifiers at the various regional internet registries (RIRs). These objects are used by the [[SoftLayer_Network_Subnet_Registration (type)|SoftLayer_Network_Subnet_Registration]] objects to identify a customer or organization when a subnet is registered.
type Account_Rwhois_Handle struct {
Entity

// The account that this handle belongs to.
// [Deprecated] The account that this handle belongs to.
// Deprecated: This function has been marked as deprecated.
Account *Account `json:"account,omitempty" xmlrpc:"account,omitempty"`

// The handle object's associated [[SoftLayer_Account|account]] id
Expand Down
Loading
Loading