diff --git a/.circleci/config.yml b/.circleci/config.yml index 476cf7b..f410205 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -30,7 +30,7 @@ jobs: - source - run: go get github.com/mitchellh/gox - run: go get github.com/tcnksm/ghr - - run: make build + - run: make crossbuild - run: ${CIRCLE_WORKING_DIRECTORY}/.circleci/compress_binaries.sh - run: ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME $CIRCLE_TAG pkg/ @@ -49,4 +49,4 @@ workflows: tags: only: /^v.*$/ branches: - ignore: /.*/ \ No newline at end of file + ignore: /.*/ diff --git a/Gopkg.lock b/Gopkg.lock index 196b366..be7a5a8 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -17,14 +17,6 @@ revision = "4aabc24848ce5fd31929f7d1e4ea74d3709c14cd" version = "v0.1.0" -[[projects]] - branch = "master" - digest = "1:ff5aa602ab7910353eceb9aa09f8b768cf10e25f1e8af63c06ad48a203d362fa" - name = "github.com/chroju/go-nature-remo" - packages = ["cloud"] - pruneopts = "UT" - revision = "a4c363bfa97aee004273263c5b958bf7ad0cadfe" - [[projects]] digest = "1:865079840386857c809b72ce300be7580cb50d3d3129ce11bf9aa6ca2bc1934a" name = "github.com/fatih/color" @@ -102,6 +94,14 @@ revision = "ffc2cf5e958af5ac4156a886153c7cadd24a521a" version = "v1.2.0" +[[projects]] + branch = "master" + digest = "1:516d85094a7310cc112e49c7254fe6271a9e68e19b0f62c17d1baa11cd34fce2" + name = "github.com/tenntenn/natureremo" + packages = ["."] + pruneopts = "UT" + revision = "4732091860d68334497b2ea03750731718041c2f" + [[projects]] branch = "master" digest = "1:be4f165c438aa39318fd5c8c180a95f4a52524641c0b714638b0fd9fd912b38d" @@ -114,11 +114,11 @@ analyzer-name = "dep" analyzer-version = 1 input-imports = [ - "github.com/chroju/go-nature-remo/cloud", "github.com/fatih/color", "github.com/go-yaml/yaml", "github.com/mitchellh/cli", "github.com/pkg/errors", + "github.com/tenntenn/natureremo", ] solver-name = "gps-cdcl" solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml index 89f3213..30c18e9 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -27,7 +27,7 @@ [[constraint]] branch = "master" - name = "github.com/chroju/go-nature-remo" + name = "github.com/tenntenn/natureremo" [[constraint]] name = "github.com/mitchellh/cli" diff --git a/Makefile b/Makefile index 42c48f1..490dba9 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ GOCLEAN=$(GOCMD) clean GOTEST=$(GOCMD) test BINARY_NAME=remo -build: +crossbuild: $(GOBUILD) -os="linux darwin windows" -arch="386 amd64" -output "bin/remo_{{.OS}}_{{.Arch}}/{{.Dir}}" clean: $(GOCLEAN) diff --git a/commands/send.go b/commands/send.go index 1ece593..13b1320 100644 --- a/commands/send.go +++ b/commands/send.go @@ -1,13 +1,14 @@ package commands import ( + "context" "fmt" "github.com/fatih/color" - cloud "github.com/chroju/go-nature-remo/cloud" "github.com/chroju/nature-remo-cli/configfile" "github.com/mitchellh/cli" + "github.com/tenntenn/natureremo" ) type SendCommand struct { @@ -34,19 +35,19 @@ func (c *SendCommand) Run(args []string) int { return 1 } - var signalID string + var toSendSignal *natureremo.Signal for _, v := range appliances { if v.Name == applianceName { for _, signal := range v.Signals { if signal.Name == signalName { - signalID = signal.ID + toSendSignal = signal break } } break } } - if signalID == "" { + if toSendSignal == nil { c.UI.Error(color.RedString(fmt.Sprintf("Appliance '%s' - Signal '%s' is invalid", applianceName, signalName))) return 1 } @@ -57,8 +58,9 @@ func (c *SendCommand) Run(args []string) int { return 1 } - client := cloud.NewClient(token) - if _, err := client.SendSignal(signalID); err != nil { + client := natureremo.NewClient(token) + ctx := context.Background() + if err := client.SignalService.Send(ctx, toSendSignal); err != nil { c.UI.Error(err.Error()) return 1 } diff --git a/configfile/configfile.go b/configfile/configfile.go index 6be3981..fc2e607 100644 --- a/configfile/configfile.go +++ b/configfile/configfile.go @@ -1,6 +1,7 @@ package configfile import ( + "context" "fmt" "io" "io/ioutil" @@ -8,15 +9,15 @@ import ( "os/user" "path" - cloud "github.com/chroju/go-nature-remo/cloud" "github.com/go-yaml/yaml" "github.com/pkg/errors" + "github.com/tenntenn/natureremo" ) type Appliance struct { Name string ID string - Signals []cloud.Signal + Signals []*natureremo.Signal } type Setting struct { @@ -65,8 +66,10 @@ func (c *ConfigFile) SyncConfigFile(token string) error { } defer file.Close() - client := cloud.NewClient(token) - appliances, err := client.GetAppliances() + // client := cloud.NewClient(token) + client := natureremo.NewClient(token) + ctx := context.Background() + appliances, err := client.ApplianceService.GetAll(ctx) if err != nil { return fmt.Errorf("Failed to login") }