Skip to content
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
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Bug report
about: Create a report to help us improve
title: ""
labels: bug
assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Use function '...'
2. Pass parameters '....'
3. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Environment:**

- Go version: [e.g. 1.23]
- Library version: [e.g. v2.1.0]

**Additional context**
Add any other context about the problem here.
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: Feature request
about: Suggest an idea for this project
title: ""
labels: enhancement
assignees: ""
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is.

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or examples about the feature request here.
15 changes: 14 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ updates:
directory: "/"
schedule:
interval: "daily"
groups:
github-actions:
patterns:
- "*"

- package-ecosystem: "gomod"
directory: "/"
ignore:
- dependency-name: "github.com/hashicorp/go-hclog"
- dependency-name: "golang.org/x/tools"
- dependency-name: "google.golang.org/grpc"
schedule:
interval: "daily"
interval: "daily"
groups:
golang-dependencies:
patterns:
- "*"
exclude-patterns:
- "github.com/hashicorp/go-hclog"
- "golang.org/x/tools"
- "google.golang.org/grpc"
22 changes: 22 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Description

Please include a summary of the change and which issue is fixed.

Fixes # (issue)

## Type of change

Please delete options that are not relevant.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update

## Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] I have updated the documentation accordingly
15 changes: 14 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,17 @@ go.work
.idea/

# VSCode Settings
.vscode/
.vscode/

# Coverage
coverage.txt
coverage.html

# IDE
.idea/
.vscode/
*.swp
*.swo

# OS
.DS_Store
22 changes: 22 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
linters:
enable:
- gofmt
- govet
- revive
- gosimple
- staticcheck
- errcheck
- ineffassign
- gosec
- misspell
- unconvert

run:
timeout: 5m
tests: true

issues:
exclude-rules:
- path: _test\.go
linters:
- gosec
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Contributing to Cloud Connexa Go Client

## Development Process

1. Fork the repository
2. Create a feature branch
3. Write tests
4. Make your changes
5. Run tests and linters
6. Submit a Pull Request

## Testing

```bash
make test # Run unit tests
make e2e # Run e2e tests
make lint # Run linters
```

## Pull Request Process

1. Update documentation
2. Add tests for new features
3. Ensure CI passes
4. Get review from maintainers

## Releases

Changes will be available after a new GitHub release is published. Releases follow semantic versioning (vX.Y.Z):

- Major (X): Breaking changes
- Minor (Y): New features
- Patch (Z): Bug fixes

New releases are created by maintainers after significant changes are merged to main branch.
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,20 @@ all: test
deps:
@go mod download

.PHONY: test
.PHONY: test e2e lint build clean

test:
@go test -cover -race -v ./cloudconnexa/...
go test -v -race ./cloudconnexa/...

.PHONY: e2e
e2e:
@go test -v ./e2e/...
go test -v -race ./e2e/...

lint:
golangci-lint run

build:
go build -v ./...

clean:
go clean
rm -f coverage.txt
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ func main() {
log.Fatalf("error creating client: %v", err)
}

networkId := "your_network_id"
routes, err := client.Routes.List(networkId)
networkID := "your_network_id"
routes, err := client.Routes.List(networkID)
if err != nil {
log.Fatalf("error getting routes: %v", err)
}
Expand All @@ -83,7 +83,7 @@ network := cloudconnexa.Network{
Name: "test-network",
Description: "Test network created via API",
InternetAccess: cloudconnexa.InternetAccessSplitTunnelOn,
Egress: false,
Egress: false,
}

createdNetwork, err := client.Networks.Create(network)
Expand All @@ -99,7 +99,7 @@ users, err := client.Users.List("", "")
user := cloudconnexa.User{
Username: "testuser",
Email: "[email protected]",
GroupId: "group-id",
GroupID: "group-id",
}

createdUser, err := client.Users.Create(user)
Expand Down
14 changes: 14 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Security Policy

## Reporting a Vulnerability

Please report security vulnerabilities to [[email protected]](mailto:[email protected]).

Do not report security vulnerabilities through public GitHub issues.

## Supported Versions

| Version | Supported |
| ------- | ------------------ |
| 2.x.x | :white_check_mark: |
| 1.x.x | :x: |
12 changes: 6 additions & 6 deletions cloudconnexa/access_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

type AccessGroup struct {
Id string `json:"id"`
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description,omitempty"`
Source []AccessItem `json:"source"`
Expand All @@ -23,7 +23,7 @@ type AccessItem struct {
}

type Item struct {
Id string `json:"id"`
ID string `json:"id"`
}

type AccessGroupPageResponse struct {
Expand Down Expand Up @@ -99,14 +99,14 @@ func (c *AccessGroupsService) Get(id string) (*AccessGroup, error) {
}

func (c *AccessGroupsService) Create(accessGroup *AccessGroup) (*AccessGroup, error) {
accessGroupJson, err := json.Marshal(accessGroup)
accessGroupJSON, err := json.Marshal(accessGroup)
if err != nil {
return nil, err
}

endpoint := fmt.Sprintf("%s/access-groups", c.client.GetV1Url())

req, err := http.NewRequest(http.MethodPost, endpoint, bytes.NewBuffer(accessGroupJson))
req, err := http.NewRequest(http.MethodPost, endpoint, bytes.NewBuffer(accessGroupJSON))
if err != nil {
return nil, err
}
Expand All @@ -125,14 +125,14 @@ func (c *AccessGroupsService) Create(accessGroup *AccessGroup) (*AccessGroup, er
}

func (c *AccessGroupsService) Update(id string, accessGroup *AccessGroup) (*AccessGroup, error) {
accessGroupJson, err := json.Marshal(accessGroup)
accessGroupJSON, err := json.Marshal(accessGroup)
if err != nil {
return nil, err
}

endpoint := fmt.Sprintf("%s/access-groups/%s", c.client.GetV1Url(), id)

req, err := http.NewRequest(http.MethodPut, endpoint, bytes.NewBuffer(accessGroupJson))
req, err := http.NewRequest(http.MethodPut, endpoint, bytes.NewBuffer(accessGroupJSON))
if err != nil {
return nil, err
}
Expand Down
10 changes: 5 additions & 5 deletions cloudconnexa/cloudconnexa.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type Client struct {

HostConnectors *HostConnectorsService
NetworkConnectors *NetworkConnectorsService
DnsRecords *DNSRecordsService
DNSRecords *DNSRecordsService
Hosts *HostsService
HostIPServices *HostIPServicesService
NetworkIPServices *NetworkIPServicesService
Expand Down Expand Up @@ -62,8 +62,8 @@ func (e ErrClientResponse) Error() string {
return fmt.Sprintf("status code: %d, response body: %s", e.status, e.body)
}

func NewClient(baseURL, clientId, clientSecret string) (*Client, error) {
if clientId == "" || clientSecret == "" {
func NewClient(baseURL, clientID, clientSecret string) (*Client, error) {
if clientID == "" || clientSecret == "" {
return nil, ErrCredentialsRequired
}

Expand All @@ -80,7 +80,7 @@ func NewClient(baseURL, clientId, clientSecret string) (*Client, error) {
return nil, err
}

req.SetBasicAuth(clientId, clientSecret)
req.SetBasicAuth(clientID, clientSecret)
req.Header.Add("Accept", "application/json")
httpClient := &http.Client{Timeout: 30 * time.Second}
resp, err := httpClient.Do(req)
Expand Down Expand Up @@ -110,7 +110,7 @@ func NewClient(baseURL, clientId, clientSecret string) (*Client, error) {
c.common.client = c
c.HostConnectors = (*HostConnectorsService)(&c.common)
c.NetworkConnectors = (*NetworkConnectorsService)(&c.common)
c.DnsRecords = (*DNSRecordsService)(&c.common)
c.DNSRecords = (*DNSRecordsService)(&c.common)
c.Hosts = (*HostsService)(&c.common)
c.HostIPServices = (*HostIPServicesService)(&c.common)
c.NetworkIPServices = (*NetworkIPServicesService)(&c.common)
Expand Down
11 changes: 6 additions & 5 deletions cloudconnexa/cloudconnexa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package cloudconnexa

import (
"encoding/json"
"github.com/stretchr/testify/assert"
"golang.org/x/time/rate"
"log"
"net/http"
"net/http/httptest"
"testing"

"github.com/stretchr/testify/assert"
"golang.org/x/time/rate"
)

func setupMockServer() *httptest.Server {
Expand Down Expand Up @@ -42,18 +43,18 @@ func TestNewClient(t *testing.T) {
tests := []struct {
name string
baseURL string
clientId string
clientID string
clientSecret string
wantErr bool
}{
{"Valid Credentials", server.URL, "test-id", "test-secret", false},
{"Empty ClientId", server.URL, "", "test-secret", true},
{"Empty ClientID", server.URL, "", "test-secret", true},
{"Empty ClientSecret", server.URL, "test-id", "", true},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
client, err := NewClient(tt.baseURL, tt.clientId, tt.clientSecret)
client, err := NewClient(tt.baseURL, tt.clientID, tt.clientSecret)

if tt.wantErr {
assert.Error(t, err, "NewClient should return an error for invalid credentials")
Expand Down
Loading
Loading