Skip to content

Commit

Permalink
Add Go Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
malvads committed May 28, 2024
1 parent d4ad9df commit e781e15
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 27 deletions.
20 changes: 10 additions & 10 deletions .github/workflows/rubocop.yml → .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: RuboCop
name: GoLint

on:
push:
Expand All @@ -7,15 +7,15 @@ on:
- master

jobs:
rubocop:
build:
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]')
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install RuboCop
run: sudo gem install rubocop -v 1.59.0

- name: Run RuboCop
run: rubocop ./bin
- uses: actions/checkout@v2
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.22.3
- name: Run GoLint
run: golangci-lint run
```
2 changes: 1 addition & 1 deletion utils/memcache.go → lib/memcache.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package arubacentral
package lib

import (
"github.com/bradfitz/gomemcache/memcache"
Expand Down
18 changes: 5 additions & 13 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,25 @@ package main

import (
"fmt"
"io/ioutil"

arubacentral "redborder.com/rb-arubacentral/rest"
)

func main() {
ArubaClient := arubacentral.NewArubaClient(
GoAruba := arubacentral.NewArubaClient(
"",
"",
"",
"",
"",
"",
)
resp, err := ArubaClient.Get("/visualrf_api/v1/campus")
resp, err := GoAruba.Get("/visualrf_api/v1/campus")

if err != nil {
panic(err)
fmt.Println("Error:", err)
return
}
defer resp.Body.Close()

fmt.Println("Response Status:", resp.Status)
fmt.Println("Response Headers:", resp.Header)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
fmt.Println("Response Body:", string(body))

fmt.Println("Response:", string(resp))
}
14 changes: 14 additions & 0 deletions rest/aps.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package arubacentral

import (
"fmt"
)

func GetAps(GoAruba *ArubaClient, floorID string) ([]byte, error) {
url := fmt.Sprintf("/visualrf_api/v1/floor/%s/access_point_location", floorID)
return GoAruba.Get(url)
}

func GetStatuses(GoAruba *ArubaClient) ([]byte, error) {
return GoAruba.Get("/monitoring/v2/aps")
}
16 changes: 13 additions & 3 deletions rest/aruba.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package arubacentral
import (
"fmt"
"net/http"

"io"
httpclient "redborder.com/rb-arubacentral/lib"
)

Expand Down Expand Up @@ -35,7 +35,7 @@ func (a *ArubaClient) OAuth() error {
return fmt.Errorf("access_token not found or not a string")
}

func (a *ArubaClient) Get(path string) (*http.Response, error) {
func (a *ArubaClient) Get(path string) ([]byte, error) {
headers := map[string]string{
"Authorization": fmt.Sprintf("Bearer %s", a.Token),
}
Expand All @@ -60,5 +60,15 @@ func (a *ArubaClient) Get(path string) (*http.Response, error) {
}
}

return resp, nil
if err != nil {
return nil, err
}
defer resp.Body.Close()

body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}

return body, nil
}
10 changes: 10 additions & 0 deletions rest/building.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package arubacentral

import (
"fmt"
)

func GetBuilding(GoAruba *ArubaClient, buildingID string) ([]byte, error) {
url := fmt.Sprintf("/visualrf_api/v1/building/%s", buildingID)
return GoAruba.Get(url)
}
14 changes: 14 additions & 0 deletions rest/campus.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package arubacentral

import (
"fmt"
)

func GetCampuses(GoAruba *ArubaClient) ([]byte, error) {
return GoAruba.Get("/visualrf_api/v1/campus")
}

func GetCampus(GoAruba *ArubaClient, campusID string) ([]byte, error) {
url := fmt.Sprintf("/visualrf_api/v1/campus/%s", campusID)
return GoAruba.Get(url)
}

0 comments on commit e781e15

Please sign in to comment.