Skip to content

Commit

Permalink
update to cue-v0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
verdverm committed Apr 6, 2021
1 parent b94b037 commit 43fe5b3
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 112 deletions.
24 changes: 5 additions & 19 deletions go.mod
Expand Up @@ -3,7 +3,7 @@ module github.com/hofstadter-io/hof
go 1.16

require (
cuelang.org/go v0.3.0-beta.6
cuelang.org/go v0.3.0
github.com/aymerick/raymond v2.0.2+incompatible
github.com/bmatcuk/doublestar v1.3.1
github.com/chzyer/logex v1.1.10 // indirect
Expand All @@ -12,6 +12,7 @@ require (
github.com/clbanning/mxj v1.8.4
github.com/cockroachdb/apd/v2 v2.0.2 // indirect
github.com/codemodus/kace v0.5.1
github.com/elazarl/goproxy v0.0.0-20200310082302-296d8939dc5a // indirect
github.com/emicklei/proto v1.9.0 // indirect
github.com/epiclabs-io/diff3 v0.0.0-20181217103619-05282cece609
github.com/fatih/color v1.9.0
Expand All @@ -22,21 +23,16 @@ require (
github.com/go-git/go-billy/v5 v5.0.0
github.com/go-git/go-git/v5 v5.1.0
github.com/golang/protobuf v1.4.2 // indirect
github.com/google/go-cmp v0.4.0 // indirect
github.com/google/go-github/v30 v30.1.0
github.com/google/uuid v1.1.1 // indirect
github.com/hofstadter-io/data-utils v0.0.0-20200128210141-0a3e569b27ed
github.com/hofstadter-io/dotpath v0.0.0-20191027071558-52e2819b7d2d
github.com/hofstadter-io/hof-lang v0.0.0-20180925221847-4d1c962b0729
github.com/hofstadter-io/yagu v0.0.3 // indirect
github.com/kirsle/configdir v0.0.0-20170128060238-e45d2f54772f
github.com/kr/pretty v0.2.0
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/mattn/go-zglob v0.0.2
github.com/mitchellh/mapstructure v1.3.2 // indirect
github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de // indirect
github.com/naoina/toml v0.1.1
github.com/nbutton23/zxcvbn-go v0.0.0-20180912185939-ae427f1e4c1d // indirect
github.com/olekukonko/tablewriter v0.0.4
github.com/parnurzeal/gorequest v0.2.16
github.com/pelletier/go-toml v1.8.0 // indirect
Expand All @@ -46,6 +42,7 @@ require (
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.0.0
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.6.1
go.uber.org/zap v1.15.0
Expand All @@ -55,23 +52,12 @@ require (
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1 // indirect
golang.org/x/text v0.3.3
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect
google.golang.org/appengine v1.6.6 // indirect
google.golang.org/protobuf v1.24.0 // indirect
gopkg.in/errgo.v2 v2.1.0
gopkg.in/inconshreveable/log15.v2 v2.0.0-20200109203555-b30bc20e4fd1
gopkg.in/ini.v1 v1.57.0 // indirect
gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
moul.io/http2curl v1.0.0 // indirect
)

// Until the open PR is accepted and merged
// https://github.com/cuelang/cue/pull/413
//
// we have an artificial version bump on our fork
// replace cuelang.org/go => github.com/hofstadter-io/cue v0.3.0-alpha3

// we are currently maintaining a patch on the tip of gerrit or from inprogress CLs as we test work
// if you intend to build hof locally, please reach out to use for the latest details.
// we intend to set this version to v0.3.0 when it is officially released
// replace cuelang.org/go => ../../cue/gerrit
replace cuelang.org/go => ../../cue/cue
215 changes: 129 additions & 86 deletions go.sum

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions lib/cuetils/attrs.go
@@ -0,0 +1,14 @@
package cuetils

import (
"cuelang.org/go/cue"
)

// TODO, improve merge strategy
func AttrToMap(A cue.Attribute) (m map[string]string) {
for i := 0; i < A.NumArgs(); i++ {
key, val := A.Arg(i)
m[key] = val
}
return m
}
4 changes: 2 additions & 2 deletions lib/cuetils/get.go
Expand Up @@ -42,7 +42,7 @@ func GetByAttrKeys(val cue.Value, attr string, all, any []string) ([]KeyVal, err

label := iter.Label()
value := iter.Value()
attrs := value.Attributes()
attrs := value.Attributes(cue.ValueAttr)

// fmt.Println(" -", label, attrs)

Expand All @@ -52,7 +52,7 @@ func GetByAttrKeys(val cue.Value, attr string, all, any []string) ([]KeyVal, err
// does it have an "@<attr>(...)"
if A.Name() == attr {

vals := A.Map()
vals := AttrToMap(A)

// must match all
if len(all) > 0 {
Expand Down
2 changes: 1 addition & 1 deletion lib/cuetils/print.go
Expand Up @@ -88,7 +88,7 @@ func (CRT *CueRuntime) PrintValue() error {
label := iter.Label()
value := iter.Value()
fmt.Println(" -", label, value)
for attrKey, attrVal := range value.Attributes() {
for attrKey, attrVal := range value.Attributes(cue.ValueAttr) {
fmt.Println(" --", attrKey)
for i := 0; i < 5; i++ {
str, err := attrVal.String(i)
Expand Down
5 changes: 3 additions & 2 deletions lib/runtime.go
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/mattn/go-zglob"

"github.com/hofstadter-io/hof/cmd/hof/flags"
"github.com/hofstadter-io/hof/lib/cuetils"
"github.com/hofstadter-io/hof/lib/gen"
"github.com/hofstadter-io/hof/lib/yagu"
)
Expand Down Expand Up @@ -118,7 +119,7 @@ func (R *Runtime) ExtractGenerators() {

label := iter.Label()
value := iter.Value()
attrs := value.Attributes()
attrs := value.Attributes(cue.ValueAttr)

// find top-level with gen attr
hasgen := false
Expand All @@ -128,7 +129,7 @@ func (R *Runtime) ExtractGenerators() {

// are there flags to match?
if len(R.Flagpole.Generator) > 0 {
vals := A.Map()
vals := cuetils.AttrToMap(A)
match := false
for _, g := range R.Flagpole.Generator {
if _, ok := vals[g]; ok {
Expand Down
6 changes: 4 additions & 2 deletions lib/test/print.go
Expand Up @@ -4,6 +4,8 @@ import (
"fmt"
"sort"
"strings"

"github.com/hofstadter-io/hof/lib/cuetils"
)

func printTests(suites []Suite, stats bool) {
Expand All @@ -19,7 +21,7 @@ func printTests(suites []Suite, stats bool) {

A := S.Value.Attribute("test")
as := []string{}
for k, v := range A.Map() {
for k, v := range cuetils.AttrToMap(A) {
if v != "" {
as = append(as, fmt.Sprintf("%s=%s", k, v))
} else {
Expand All @@ -43,7 +45,7 @@ func printTests(suites []Suite, stats bool) {
for _, t := range S.Tests {
A := t.Value.Attribute("test")
as := []string{}
for k, v := range A.Map() {
for k, v := range cuetils.AttrToMap(A) {

// if key is a knownTester, put it first
known := false
Expand Down

0 comments on commit 43fe5b3

Please sign in to comment.