Skip to content

Commit 3e9a087

Browse files
willpusherRobert Olesrobertolesamaddependabot[bot]
authored
Serverless Functions (#58)
* Add function management Enables operator to create/update/delete functions via pusher api. * Fix linter feedback * Bump golang.org/x/text from 0.3.7 to 0.3.8 Bumps [golang.org/x/text](https://github.com/golang/text) from 0.3.7 to 0.3.8. - [Release notes](https://github.com/golang/text/releases) - [Commits](golang/text@v0.3.7...v0.3.8) * Fix staging Enhance config options to allow use in staging clusters * Update status in README from alpha to beta Co-authored-by: Robert Oles <rob@duffel.com> Co-authored-by: robertoles <robertoles@me.com> Co-authored-by: Ahmad Samiei <ahmad.samiei@gmail.com> Co-authored-by: Ahmad Samiei <amad@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Agata Walukiewicz <agata.walukiewicz@messagebird.com> Co-authored-by: Vitaliy Kalachikhin <vitaliy.kalachikhin@messagebird.com> Co-authored-by: Felipe Benevides <me@benevides.pro>
1 parent e79ae93 commit 3e9a087

25 files changed

Lines changed: 1163 additions & 62 deletions

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.PHONY: build-mockgen
2+
build-mockgen:
3+
docker build -f mockgen.Dockerfile --tag pusher_cli_mockgen .
4+
5+
.PHONY: mocks
6+
mocks: build-mockgen
7+
docker run --rm --volume "$$(pwd):/src" pusher_cli_mockgen

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is a tool that allows developers access to their Pusher accounts via a command line interface.
44

5-
This is an alpha release. We recommend using it for non-production apps. It may eat your laundry! We'd appreciate your feedback.
5+
This is a beta release. We recommend using it for non-production apps unless otherwise advised. We'd appreciate your feedback.
66

77
## Usage
88

@@ -41,3 +41,17 @@ We [publish binaries on GitHub](https://github.com/pusher/cli/releases) and we u
4141

4242
1. `git tag -a v0.14 -m "v0.14"`
4343
1. `git push origin v0.14`
44+
45+
### Configuration
46+
47+
`pusher login` creates a file `~/.config/pusher.json` (or updates it if it already exists).
48+
If you need to point the Pusher CLI to different servers (e.g. when testing), you can change the `endpoint` value and add new name/value pairs as necessary:
49+
```JSON
50+
{
51+
"endpoint": "https://cli.another.domain.com",
52+
"token": "my-secret-api-key",
53+
"apihost": "api-mycluster.another.domain.com",
54+
"httphost": "sockjs-mycluster.another.domain.com",
55+
"wshost": "ws-mycluster.another.domain.com"
56+
}
57+
```

api/account.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ import (
88
)
99

1010
//isAPIKeyValid returns true if the stored API key is valid.
11-
func isAPIKeyValid() bool {
11+
func (p *PusherApi) isAPIKeyValid() bool {
1212
if viper.GetString("token") != "" {
13-
_, err := GetAllApps()
13+
_, err := p.GetAllApps()
1414
if err == nil {
1515
return true
1616
}
1717
}
1818
return false
1919
}
2020

21-
func validateKeyOrDie() {
22-
if !isAPIKeyValid() {
21+
func (p *PusherApi) validateKeyOrDie() {
22+
if !p.isAPIKeyValid() {
2323
fmt.Println("Your API key isn't valid. Add one with the `login` command.")
2424
os.Exit(1)
2525
}

api/app.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ type App struct {
1212
Cluster string `json:"cluster"`
1313
}
1414

15-
const getAppsAPIEndpoint = "/apps.json"
15+
const GetAppsAPIEndpoint = "/apps.json"
1616

17-
func GetAllApps() ([]App, error) {
18-
response, err := makeRequest("GET", getAppsAPIEndpoint, nil)
17+
func (p *PusherApi) GetAllApps() ([]App, error) {
18+
response, err := p.makeRequest("GET", GetAppsAPIEndpoint, nil)
1919
if err != nil {
2020
return nil, err
2121
}
@@ -29,8 +29,8 @@ func GetAllApps() ([]App, error) {
2929
return apps, nil
3030
}
3131

32-
func GetApp(appID string) (*App, error) {
33-
apps, err := GetAllApps()
32+
func (p *PusherApi) GetApp(appID string) (*App, error) {
33+
apps, err := p.GetAllApps()
3434
if err != nil {
3535
return nil, err
3636
}

0 commit comments

Comments
 (0)