Skip to content

Commit

Permalink
Merge pull request #7 from turnerlabs/importlibrary
Browse files Browse the repository at this point in the history
Fix issue where Go cStore library is not importable.
  • Loading branch information
kendavis2 committed Mar 9, 2020
2 parents 726848c + f7a2eb1 commit bc44d40
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 17 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
env:
working-directory: ./v4
steps:
- uses: olegtarasov/get-tag@v1
id: tagName
Expand All @@ -24,6 +26,7 @@ jobs:
uses: actions/checkout@v2

- name: Run Tests
working-directory: ${{env.working-directory}}
run: go test ./...

- name: Build and Publish Code
Expand All @@ -32,7 +35,7 @@ jobs:
GOROOT: /usr/local/go
with:
args: |
cd cli
cd ${{env.working-directory}}/cli
gox -os='linux' -os='windows' -ldflags '-X main.version=${{ steps.tagName.outputs.tag }}.${{ github.run_number }}' -output 'artifacts/cstore_{{.OS}}_{{.Arch}}'
ghr -t '${{ secrets.GITHUB_TOKEN }}' -u turnerlabs -r cstore -c $GITHUB_SHA -delete ${{ steps.tagName.outputs.tag }} artifacts
2 changes: 1 addition & 1 deletion docs/LIBRARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"log"
"os"

"github.com/turnerlabs/cstore"
"github.com/turnerlabs/cstore/v4"
)

config, err := cstore.Pull(os.Getenv("CSTORE_CATALOG"),
Expand Down
2 changes: 1 addition & 1 deletion docs/PUBLISH.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ NOTE: semver tag format required `v1.0.0-rc`
```bash
$ git tag {{TAG}}
$ git push origin {{TAG}}
$ ./create_darwin_build.sh
$ ./{{MAJOR_VERSION_NUMBER}}/create_darwin_build.sh
```
Once the build is complete the {{TAG}} release will be published to GitHub.

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/subosito/gotenv v1.2.0
github.com/tidwall/gjson v1.6.0
github.com/tidwall/sjson v1.0.4
github.com/turnerlabs/cstore/v4 v4.0.0-20200305155425-65deccbd3934 // indirect
github.com/turnerlabs/cstore/v4 v4.0.0 // indirect
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073
gopkg.in/yaml.v2 v2.2.8
)
12 changes: 5 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
Expand Down Expand Up @@ -60,8 +58,10 @@ github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvW
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
Expand All @@ -82,7 +82,6 @@ github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
Expand Down Expand Up @@ -119,7 +118,6 @@ github.com/spf13/viper v1.6.2/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfD
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
Expand All @@ -132,9 +130,8 @@ github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhV
github.com/tidwall/sjson v1.0.4 h1:UcdIRXff12Lpnu3OLtZvnc03g4vH2suXDXhBwBqmzYg=
github.com/tidwall/sjson v1.0.4/go.mod h1:bURseu1nuBkFpIES5cz6zBtjmYeOQmEESshn7VpF15Y=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/turnerlabs/cstore v3.1.0-alpha+incompatible/go.mod h1:ny3OdebjGICnMZDEOzQE9YgSTmWY1XV3Mngm4xsDcKI=
github.com/turnerlabs/cstore/v4 v4.0.0-20200305155425-65deccbd3934 h1:e+qxcX8LjSR9iUsYw2YImCd85o7Lh46MOaLe/Kw3S1Q=
github.com/turnerlabs/cstore/v4 v4.0.0-20200305155425-65deccbd3934/go.mod h1:HaSKfRFkDrDkd2hCKfqXIiddZ+6KLylkA1skE3rUN8M=
github.com/turnerlabs/cstore/v4 v4.0.0 h1:cd28jAomnLymAyDP9Vx0NRdg+BbXy2DB5PvoLOwoEwY=
github.com/turnerlabs/cstore/v4 v4.0.0/go.mod h1:F67ddVyI7QqxUWcGYZdKGlEygWg85OhgKk5hzkP5AoQ=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
Expand Down Expand Up @@ -181,6 +178,7 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
Expand Down
8 changes: 5 additions & 3 deletions v4/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
"github.com/turnerlabs/cstore/v4/components/cfg"
)

var version = "v3.0.0-rc"
var version = ""

func main() {
cfg.Version = version

if len(version) > 0 {
cfg.Version = version
}

if err := cmd.RootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(-1)
Expand Down
4 changes: 3 additions & 1 deletion v4/components/catalog/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package catalog

import (
"errors"

"time"

"github.com/turnerlabs/cstore/v4/components/local"
Expand All @@ -13,7 +14,7 @@ const name = "state.yml"

// RemoveRecords ...
func (c Catalog) RemoveRecords(fileName string) error {
pulls := map[string]time.Time{}
pulls := map[string]State{}

b, err := local.Get(name, "")
if err == nil {
Expand All @@ -34,6 +35,7 @@ func (c Catalog) RemoveRecords(fileName string) error {

// RecordPull ...
func (c Catalog) RecordPull(fileName string, lastPull time.Time, version string) error {

if lastPull.IsZero() {
return errors.New("invalid time")
}
Expand Down
4 changes: 2 additions & 2 deletions v4/components/cfg/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cfg

// Version is overridden by the main function unless tests
// which require a default are running.
var Version = "v3.0.0-default"
var Version = "v4.0.0-default"

// SupportedVersions ...
var SupportedVersions = []string{"v2", Version}
var SupportedVersions = []string{"v2", "v3", Version}
6 changes: 6 additions & 0 deletions v4/create_darwin_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
read -p 'Git Tag: ' VERSION_NUM
read -p 'GitHub Actions Build #: ' BUILD_NUM

cd cli

go build -ldflags "-X main.version=$VERSION_NUM.$BUILD_NUM" -o ../cstore_darwin_amd64
3 changes: 3 additions & 0 deletions v4/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ require (
github.com/aws/aws-sdk-go v1.29.18
github.com/fatih/color v1.9.0
github.com/keybase/go-keychain v0.0.0-20200218013740-86d4642e4ce2
github.com/mattn/go-colorable v0.1.4
github.com/mitchellh/go-homedir v1.1.0
github.com/satori/go.uuid v1.2.0
github.com/spf13/cobra v0.0.6
github.com/spf13/viper v1.6.2
github.com/subosito/gotenv v1.2.0
github.com/tidwall/gjson v1.6.0
github.com/tidwall/sjson v1.0.4
Expand Down
Loading

0 comments on commit bc44d40

Please sign in to comment.