Skip to content

Commit

Permalink
Merge pull request #49 from pusher/hello2022
Browse files Browse the repository at this point in the history
Hello2022
  • Loading branch information
marcelcorso committed Aug 1, 2022
2 parents 2921cb0 + 2408472 commit 0220e7e
Show file tree
Hide file tree
Showing 13 changed files with 609 additions and 106 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/golangci-lint.yml
@@ -0,0 +1,44 @@
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
contents: read
# Optional: allow read access to pull request. Use with `only-new-issues` option.
# pull-requests: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: latest

# Optional: working directory, useful for monorepos
# working-directory: somedir

# Optional: golangci-lint command line arguments.
# args: --issues-exit-code=0

# Optional: show only new issues if it's a pull request. The default value is `false`.
# only-new-issues: true

# Optional: if set to true then the all caching functionality will be complete disabled,
# takes precedence over all other caching options.
# skip-cache: true

# Optional: if set to true then the action don't cache or restore ~/go/pkg.
# skip-pkg-cache: true

# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
# skip-build-cache: true
35 changes: 15 additions & 20 deletions .github/workflows/test.yml
@@ -1,29 +1,24 @@
name: Tests
name: Go

on:
pull_request:
push:
branches: [ master, main ]
branches: [ master main ]
pull_request:

jobs:
test:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
go: ['1.11', '1.12', '1.13', '1.14', '1.15']

name: Go ${{ matrix.go }} Test

build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18

- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Build
run: go build -v ./...

- name: Run test suite
run: |
go test ./...
- name: Test
run: go test -v ./...
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -21,7 +21,7 @@ You can download the latest release from [here](https://github.com/pusher/cli/re
1. Clone this repository;
1. Pull dependencies with `dep ensure`;
1. Build with `go build -o pusher`;
1. Copy `pusher` to your `$GOPATH/bin` or just use it as is.
1. Copy `pusher` to somewhere in your `$PATH` or just use it as is.

### Homebrew

Expand All @@ -35,7 +35,7 @@ brew install pusher/brew/pusher

1. Clone this repository;
1. Create a new branch by running `git checkout -b <YOUR_BRANCH_NAME_HERE> master`
1. Pull dependencies with `dep ensure`;
1. Run `go build` to fetch dependencies and run tests for the first time.
1. Ready to hack.

We [publish binaries on GitHub](https://github.com/pusher/cli/releases)
Expand All @@ -46,4 +46,4 @@ We [publish binaries on GitHub](https://github.com/pusher/cli/releases)
1. [Generate a GitHub personal access token](https://github.com/settings/tokens)
with the `repo` scope selected.
Set this as env var `GITHUB_TOKEN`.
1. From this directory, run `goreleaser` (or [follow these instructions](https://goreleaser.com/#releasing))
1. From this directory, run `goreleaser` (or [follow these instructions](https://goreleaser.com/#releasing))
6 changes: 3 additions & 3 deletions api/app.go
Expand Up @@ -8,7 +8,7 @@ import (

type App struct {
Name string `json:"name"`
Id int `json:"id"`
ID int `json:"id"`
Cluster string `json:"cluster"`
}

Expand All @@ -29,14 +29,14 @@ func GetAllApps() ([]App, error) {
return apps, nil
}

func GetApp(appId string) (*App, error) {
func GetApp(appID string) (*App, error) {
apps, err := GetAllApps()
if err != nil {
return nil, err
}

for _, app := range apps {
if fmt.Sprintf("%d", app.Id) == appId {
if fmt.Sprintf("%d", app.ID) == appID {
return &app, nil
}
}
Expand Down
2 changes: 0 additions & 2 deletions api/shared.go
Expand Up @@ -3,7 +3,6 @@ package api
import (
"bytes"
"io/ioutil"
"math/rand"
"net/http"
"time"

Expand All @@ -13,7 +12,6 @@ import (

var (
httpClient = &http.Client{Timeout: 5 * time.Second}
rnd = rand.New(rand.NewSource(time.Now().UnixNano()))
)

func makeRequest(reqtype string, path string, body []byte) (string, error) {
Expand Down
2 changes: 1 addition & 1 deletion commands/channels/apps.go
Expand Up @@ -39,7 +39,7 @@ var Apps = &cobra.Command{
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"App ID", "App Name", "Cluster"})
for _, app := range apps {
table.Append([]string{strconv.Itoa(app.Id), app.Name, app.Cluster})
table.Append([]string{strconv.Itoa(app.ID), app.Name, app.Cluster})
}
table.Render()
}
Expand Down
11 changes: 8 additions & 3 deletions commands/channels/auth_server.go
Expand Up @@ -49,7 +49,7 @@ var LocalAuthServer = &cobra.Command{
}

pClient := pusher.Client{
AppId: fmt.Sprintf("%d", app.Id),
AppID: fmt.Sprintf("%d", app.ID),
Key: token.Key,
Secret: token.Secret,
Cluster: app.Cluster,
Expand All @@ -66,15 +66,20 @@ var LocalAuthServer = &cobra.Command{

resp.Header().Set("Access-Control-Allow-Origin", "*")

fmt.Fprintf(resp, string(response))
fmt.Fprint(resp, string(response))
})

portColor := color.New(color.FgBlue)
fmt.Print("Started local server. Listening on port ")
portColor.Printf("%d", localAuthServerPort)
fmt.Print(".\n")

http.ListenAndServe(fmt.Sprintf(":%d", localAuthServerPort), nil)
err = http.ListenAndServe(fmt.Sprintf(":%d", localAuthServerPort), nil)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not listen and serve: %s\n", err.Error())
os.Exit(1)
return
}
},
}

Expand Down
2 changes: 1 addition & 1 deletion commands/channels/channel_info.go
Expand Up @@ -44,7 +44,7 @@ var ChannelInfo = &cobra.Command{
}

client := pusher.Client{
AppId: commands.AppID,
AppID: commands.AppID,
Key: token.Key,
Secret: token.Secret,
Cluster: app.Cluster,
Expand Down
2 changes: 1 addition & 1 deletion commands/channels/list_channels.go
Expand Up @@ -38,7 +38,7 @@ var ListChannels = &cobra.Command{
}

client := pusher.Client{
AppId: commands.AppID,
AppID: commands.AppID,
Key: token.Key,
Secret: token.Secret,
Cluster: app.Cluster,
Expand Down
4 changes: 2 additions & 2 deletions commands/channels/trigger.go
Expand Up @@ -56,13 +56,13 @@ var Trigger = &cobra.Command{
}

client := pusher.Client{
AppId: commands.AppID,
AppID: commands.AppID,
Key: token.Key,
Secret: token.Secret,
Cluster: app.Cluster,
}

_, err = client.Trigger(commands.ChannelName, commands.EventName, commands.Message)
err = client.Trigger(commands.ChannelName, commands.EventName, commands.Message)
if err != nil {
fmt.Fprintf(os.Stderr, "Could not trigger: %s\n", err.Error())
return
Expand Down
46 changes: 22 additions & 24 deletions go.mod
Expand Up @@ -3,31 +3,29 @@ module github.com/pusher/cli
go 1.15

require (
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.5.0
github.com/fsnotify/fsnotify v1.4.2 // indirect
github.com/gorilla/websocket v1.2.0 // indirect
github.com/hashicorp/hcl v0.0.0-20171017181929-23c074d0eceb // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/magiconair/properties v1.7.3 // indirect
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.3 // indirect
github.com/mattn/go-runewidth v0.0.2 // indirect
github.com/mitchellh/mapstructure v0.0.0-20171017171808-06020f85339e // indirect
github.com/olekukonko/tablewriter v0.0.0-20170925234030-a7a4c189eb47
github.com/pelletier/go-toml v1.0.1 // indirect
github.com/fatih/color v1.13.0
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-colorable v0.1.12 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/olekukonko/tablewriter v0.0.5
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pusher-community/pusher-websocket-go v0.0.0-20171002130509-d33b2ac886af
github.com/pusher/pusher-http-go v1.2.0
github.com/spf13/afero v0.0.0-20171021110813-5660eeed305f // indirect
github.com/spf13/cast v1.1.0 // indirect
github.com/spf13/cobra v0.0.1
github.com/spf13/jwalterweatherman v0.0.0-20170901151539-12bd96e66386 // indirect
github.com/spf13/pflag v1.0.0 // indirect
github.com/stretchr/testify v1.7.0 // indirect
github.com/pusher/pusher-http-go v4.0.1+incompatible
github.com/rivo/uniseg v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.8.1 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.5.0
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/stretchr/testify v1.8.0 // indirect
github.com/theherk/viper v0.0.0-20171202031228-e0502e82247d
golang.org/x/sys v0.0.0-20171027130407-80ad69fa329a // indirect
golang.org/x/text v0.1.1-0.20171024115504-6eab0e8f74e8 // indirect
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7 // indirect
)

0 comments on commit 0220e7e

Please sign in to comment.