Skip to content
This repository was archived by the owner on Nov 4, 2020. It is now read-only.
Open
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
55 changes: 55 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
env:
- GO111MODULE=on
- CGO_ENABLED=1
before:
hooks:
- go mod tidy
# You may remove this if you don't use go modules.
- go mod download
# you may remove this if you don't need go generate
#- go generate ./...
builds:
- env:
- CGO_ENABLED=1
- GO111MODULE=on
- CC=o64-clang
- CXX=o64-clang++
main: ./main.go
binary: platformer
goos:
- linux
- windows
- darwin
goarch:
- amd64
ignore:
- goos: darwin
goarch: 386
archives:
- format: tar.gz
format_overrides:
- goos: windows
format: zip
name_template: '{{.ProjectName}}_{{.Version}}_{{.Os}}-{{.Arch}}'
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
files:
- README.md
- LICENSE
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: '{{ .Tag }}-next'
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
- 'README'
- Merge pull request
- Merge branch
1 change: 0 additions & 1 deletion cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ func startServerAndAwaitToken(server *http.Server, tokenChan chan<- string, errc
})

c := cors.New(cors.Options{
// @TODO: add production/staging URLs
AllowedMethods: []string{http.MethodPost, http.MethodOptions, http.MethodConnect},
AllowedOrigins: []string{"http://localhost:3000", "https://console.dev.x.platformer.com", "http://localhost:9999", "https://beta.console.platformer.com"},
AllowedHeaders: []string{"*"},
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9
github.com/pelletier/go-toml v1.7.0 h1:7utD74fnzVc/cpcyy8sjrlFr5vYpypUixARcHIMIGuI=
github.com/pelletier/go-toml v1.7.0/go.mod h1:vwGMzjaWMwyfHwgIBhI2YUM4fB6nL6lVAvS1LBMMhTE=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/platformer-com/platformer-cli v0.0.0-20200814035411-fb69fc54e438 h1:1T5djV+WXR3oEWpHD1y9YnRbF3ZlvYJRhB56iGrPOoc=
github.com/platformer-com/platformer-cli v0.0.0-20200814035411-fb69fc54e438/go.mod h1:DwHEBKdnzQviZ+EThJKC1XsAcgv0wCVMmpd7z+YPrY4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
Expand Down
1 change: 1 addition & 0 deletions internal/auth/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func IsLoggedIn() bool {
config.RemoveToken()
return false
}

if resp.StatusCode != 200 {
config.RemoveToken()
return false
Expand Down
5 changes: 2 additions & 3 deletions internal/auth/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ func FetchPermanentToken(token string) (string, error) {
Description string `json:"description"`
ExpiredIn *string `json:"expired_in"`
}{
// @todo - add proper values here
"test-service account",
"",
"cli-service account",
"Getting token for CLI use",
nil,
})

Expand Down
2 changes: 2 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ func SaveToken(token string) {

// RemoveToken removes the locally saved token
func RemoveToken() {
viper.Set("context.organization", "")
viper.Set("context.project", "")
viper.Set("auth.token", "")
_ = viper.WriteConfig()
}
Expand Down
10 changes: 9 additions & 1 deletion internal/mizzen/connect_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/platformercloud/platformer-cli/internal/config"
"github.com/platformercloud/platformer-cli/internal/util"
"io/ioutil"
"net/http"
Expand Down Expand Up @@ -48,18 +49,25 @@ func register(orgID string, projectID string, clusterName string) (*credentials,
ClusterName string `json:"cluster_name"`
ProjectID string `json:"project_id"`
OrganizationID string `json:"organization_id"`
ClusterType string `json:"cluster_type"`
WhitelistIPs []string `json:"whitelist_ips"`
}{
clusterName,
projectID,
orgID,
"private",
[]string{}, // Whitelist IPs are not set using the CLI
})

client := &http.Client{
Timeout: time.Second * 30,
}
r, err := client.Post(util.MizzenClusterRegistrationURL, "application/json", &body)

req, _ := http.NewRequest("POST", util.MizzenClusterRegistrationURL, &body)
req.Header.Add("Authorization", config.GetToken())

r, err := client.Do(req)

if err != nil {
return nil, fmt.Errorf("api request failed (register cluster): %w", err)
}
Expand Down