Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: update cue #202

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
6 changes: 3 additions & 3 deletions core/gotemplate/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ func (m *Module) Configure(injector *dingo.Injector) {
func (m *Module) CueConfig() string {
return `
// general config
core gotemplate engine: {
templates basepath: string | *"templates"
layout dir: string | *""
core: gotemplate: engine: {
templates: basepath: string | *"templates"
layout: dir: string | *""
}
`
}
Expand Down
2 changes: 1 addition & 1 deletion core/healthcheck/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (m *Module) Configure(injector *dingo.Injector) {
// CueConfig schema and configuration
func (m *Module) CueConfig() string {
return `
core healthcheck: {
core: healthcheck: {
checkSession: bool | *true
checkAuth: bool | *false
checkPath: string | *"/status/healthcheck"
Expand Down
2 changes: 1 addition & 1 deletion core/oauth/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (m *Module) Configure(injector *dingo.Injector) {
// CueConfig for oauth module
func (*Module) CueConfig() string {
return `
core oauth: {
core: oauth: {
server: string | *""
secret: string | *""
clientid: string | *""
Expand Down
2 changes: 1 addition & 1 deletion core/zap/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (subscriber *shutdownEventSubscriber) Notify(_ context.Context, event flami
func (m *Module) CueConfig() string {
// language=cue
return `
core zap: {
core: zap: {
loglevel: *"Debug" | "Info" | "Warn" | "Error" | "DPanic" | "Panic" | "Fatal"
sampling: {
enabled: bool | *true
Expand Down
24 changes: 13 additions & 11 deletions framework/config/cueast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (

"cuelang.org/go/cue"
"cuelang.org/go/cue/build"
"cuelang.org/go/cue/cuecontext"
"cuelang.org/go/cue/parser"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)

func Test_cueAstTree(t *testing.T) {
Expand Down Expand Up @@ -52,9 +54,9 @@ b: 2

func Test_cueAstMerge(t *testing.T) {
predefined, err := parser.ParseFile("predefined", `
predef :: {x: 1}
#predef: {x: 1}
`)
assert.NoError(t, err)
require.NoError(t, err)

base, err := parser.ParseFile("base", `
a: int
Expand All @@ -68,28 +70,28 @@ list: [1,2,3]
struct: x: 1
defbase :: { c: 3 }
def :: { defbase, a: 1, b: 2}
defined: def
predefined: predef
defined: #def
predefined: #predef
`)
assert.NoError(t, err)
require.NoError(t, err)

in, err := parser.ParseFile("in", `
b: 22
struct: d: e: f2: 223
list: [3,2,1]
struct: y: 2
struct: z: {z1: 51, z2: 52}
def :: { b: 3 }
#def: { b: 3 }
`)
assert.NoError(t, err)
require.NoError(t, err)

res := cueAstMergeFile(base, in)

buildInstance := build.NewContext().NewInstance("", nil)
assert.NoError(t, buildInstance.AddSyntax(predefined))
assert.NoError(t, buildInstance.AddSyntax(res))
instance, err := new(cue.Runtime).Build(buildInstance)
assert.NoError(t, err)
require.NoError(t, buildInstance.AddSyntax(predefined))
require.NoError(t, buildInstance.AddSyntax(res))
ctx := cuecontext.New()
instance := ctx.BuildInstance(buildInstance)

var testData struct {
A int
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
contrib.go.opencensus.io/exporter/jaeger v0.2.0
contrib.go.opencensus.io/exporter/prometheus v0.1.0
contrib.go.opencensus.io/exporter/zipkin v0.1.1
cuelang.org/go v0.0.15
cuelang.org/go v0.4.0
flamingo.me/dingo v0.2.9
github.com/boj/redistore v0.0.0-20180917114910-cd5dcc76aeff
github.com/coreos/etcd v3.3.24+incompatible // indirect
Expand Down Expand Up @@ -36,6 +36,7 @@ require (
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect
github.com/prometheus/client_golang v1.4.1 // indirect
github.com/prometheus/procfs v0.0.10 // indirect
github.com/rogpeppe/testscript v1.1.0 // indirect
github.com/satori/go.uuid v1.2.0
github.com/spf13/cobra v1.1.3
github.com/spf13/pflag v1.0.5
Expand Down
Loading