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

[IGNORE] CUE: bump to latest alpha #2374

Merged
merged 5 commits into from
Oct 28, 2024
Merged
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
10 changes: 5 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
with:
enable_go: true
enable_cue: true
cue_version: "v0.10.0"
cue_version: "v0.11.0-alpha.4"
- name: check format
run: make checkformat
- name: check go.mod
Expand All @@ -64,7 +64,7 @@ jobs:
with:
enable_go: true
enable_cue: true # needed for DaC CLI commands unit tests
cue_version: "v0.10.0"
cue_version: "v0.11.0-alpha.4"
- name: test
run: make integration-test
test-mysql:
Expand All @@ -88,7 +88,7 @@ jobs:
with:
enable_go: true
enable_cue: true # needed for DaC CLI commands unit tests
cue_version: "v0.10.0"
cue_version: "v0.11.0-alpha.4"
- name: test
run: make mysql-integration-test
golangci:
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
with:
enable_go: true
enable_cue: true
cue_version: "v0.10.0"
cue_version: "v0.11.0-alpha.4"
- name: eval cue schema
run: make cue-eval
- name: test cue schema
Expand All @@ -138,7 +138,7 @@ jobs:
with:
enable_go: true
enable_cue: true
cue_version: "v0.10.0"
cue_version: "v0.11.0-alpha.4"
- name: generate cue files
run: make cue-gen
- name: check for changes
Expand Down
20 changes: 11 additions & 9 deletions cue/dac-utils/prometheus/filter/filter.cue
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ import (

#input: [...varBuilder]

filter: strings.Join(
[for var in #input {
[// switch
if var.#kind == "TextVariable" {"\(var.#name)=~\"$\(var.#name)\""},
if var.#kind == "ListVariable" if var.#pluginKind != labelNamesVar.kind {"\(var.#name)=~\"$\(var.#name)\""},
][0]
}],
",",
)
// Have to use an intermediary variable here to handle the fact that labelNames variable should be excluded from the filter
// This is again a case where proper support of short-circuit on CUE side would help simplify the code (see https://github.com/cue-lang/cue/issues/2232)
_matchers: [for var in #input {
[// switch
if var.#kind == "TextVariable" {"\(var.#name)=~\"$\(var.#name)\""},
if var.#kind == "ListVariable" if var.#pluginKind != labelNamesVar.kind {"\(var.#name)=~\"$\(var.#name)\""},
null,
][0]
}]

filter: strings.Join([for matcher in _matchers if matcher != null {matcher}], ",")
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ filter: {filterBuilder & {#input: #dependencies}}.filter

queryExpr: [// switch
if #query != _|_ {#query},
{#metric + "{" + filter + "}"},
#metric + "{" + filter + "}",
][0]

variable: promVarBuilder.variable & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ filter: {filterBuilder & {#input: #dependencies}}.filter

queryExpr: [// switch
if #query != _|_ {#query},
{#metric + "{" + filter + "}"},
#metric + "{" + filter + "}",
][0]

variable: promVarBuilder.variable & {
Expand Down
2 changes: 1 addition & 1 deletion cue/dac-utils/prometheus/variable/promql/promql.cue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ filter: {filterBuilder & {#input: #dependencies}}.filter

queryExpr: [// switch
if #query != _|_ {#query},
{"group by (\(#label)) (\(#metric){\(filter)})"},
"group by (\(#label)) (\(#metric){\(filter)})",
][0]

variable: promVarBuilder.variable & {
Expand Down
4 changes: 2 additions & 2 deletions cue/schemas/panels/gauge/migrate.cue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if #panel.type != _|_ if #panel.type == "gauge" {
#calcName: *"\(#panel.options.reduceOptions.calcs[0])" | null // only consider [0] here as Perses's GaugeChart doesn't support individual calcs
calculation: [ // switch
if #mapping.calc[#calcName] != _|_ { #mapping.calc[#calcName] },
{ #defaultCalc }
#defaultCalc
][0]

#unitPath: *"\(#panel.fieldConfig.defaults.unit)" | null
Expand All @@ -20,7 +20,7 @@ if #panel.type != _|_ if #panel.type == "gauge" {
steps: [ for _, step in #panel.fieldConfig.defaults.thresholds.steps if step.value != _|_ { // TODO how to manage the overrides part?
value: [ // switch
if step.value == null { 0 },
{ step.value }
step.value
][0]
color: step.color
}]
Expand Down
2 changes: 1 addition & 1 deletion cue/schemas/panels/stat/migrate.cue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ if #panel.type != _|_ if #panel.type == "stat" {
#calcName: *"\(#panel.options.reduceOptions.calcs[0])" | null // only consider [0] here as Perses's StatChart doesn't support individual calcs
calculation: [ // switch
if #mapping.calc[#calcName] != _|_ { #mapping.calc[#calcName] },
{ #defaultCalc }
#defaultCalc
][0]

#unitPath: *"\(#panel.fieldConfig.defaults.unit)" | null
Expand Down
6 changes: 3 additions & 3 deletions cue/schemas/panels/table/migrate.cue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ if #panel.type != _|_ if #panel.type == "table" {
if #panel.options != _|_ if #panel.options.cellHeight != _|_ {
density: [
if #panel.options.cellHeight == "sm" { "compact" },
if #panel.options.cellHeight == "md" { "standard" },
if #panel.options.cellHeight == "lg" { "comfortable" }
"standard"
][0]
}

Expand Down Expand Up @@ -130,7 +130,7 @@ if #panel.type != _|_ if #panel.type == "table" {
if option.text != _|_ { text: option.text }
if option.color != _|_ { backgroundColor: [ // switch
if #mapping.color[option.color] != _|_ { #mapping.color[option.color] },
{ option.color }
option.color
][0]}
}]
}
Expand All @@ -152,7 +152,7 @@ if #panel.type != _|_ if #panel.type == "table" {
if mapping.options.result.text != _|_ { text: mapping.options.result.text }
if mapping.options.result.color != _|_ { backgroundColor: [ // switch
if #mapping.color[mapping.options.result.color] != _|_ { #mapping.color[mapping.options.result.color] },
{ mapping.options.result.color }
mapping.options.result.color
][0]}
}
}
Expand Down
12 changes: 6 additions & 6 deletions cue/schemas/panels/time-series/migrate.cue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ if #panel.type != _|_ if #panel.type == "timeseries" || #panel.type == "graph" {
if #panel.type == "timeseries" {
position: [
if #panel.options.legend.placement != _|_ if #panel.options.legend.placement == "right" {"right"},
{"bottom"}
"bottom"
][0]
mode: [
if #panel.options.legend.displayMode == "list" { "list" },
if #panel.options.legend.displayMode == "table" { "table" },
"list"
][0]
values: [ for calc in #panel.options.legend.calcs
if (#mapping.calc[calc] != _|_) { #mapping.calc[calc] }
Expand All @@ -22,11 +22,11 @@ if #panel.type != _|_ if #panel.type == "timeseries" || #panel.type == "graph" {
if #panel.type == "graph" {
position: [ // switch
if #panel.legend.rightSide != _|_ if #panel.legend.rightSide { "right" },
{ "bottom" }
"bottom"
][0]
mode: [
if #panel.legend.alignAsTable != _|_ if #panel.legend.alignAsTable { "table" },
{ "list" }
"list"
][0]
values: [ for oldCalc, newCalc in #mapping.calc
// Check if the mapping field is set on the legend and
Expand Down Expand Up @@ -65,7 +65,7 @@ if #panel.type != _|_ if #panel.type == "timeseries" || #panel.type == "graph" {
steps: [ for _, step in #panel.fieldConfig.defaults.thresholds.steps if step.value != _|_ { // TODO how to manage the overrides part?
value: [ // switch
if step.value == null { 0 },
{ step.value }
step.value
][0]
color: step.color
}]
Expand All @@ -77,7 +77,7 @@ if #panel.type != _|_ if #panel.type == "timeseries" || #panel.type == "graph" {
lineWidth: [ // switch
if #panel.fieldConfig.defaults.custom.lineWidth > 3 { 3 }, // line width can't go beyond 3 in Perses
if #panel.fieldConfig.defaults.custom.lineWidth < 0.25 { 0.25 }, // line width can't go below 0.25 in Perses
{ #panel.fieldConfig.defaults.custom.lineWidth }
#panel.fieldConfig.defaults.custom.lineWidth
][0]
}
if #panel.fieldConfig.defaults.custom.fillOpacity != _|_ {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/perses/perses
go 1.22.5

require (
cuelang.org/go v0.11.0-alpha.3
cuelang.org/go v0.11.0-alpha.4
github.com/brunoga/deep v1.2.4
github.com/charmbracelet/huh v0.6.0
github.com/efficientgo/core v1.0.0-rc.3
Expand Down Expand Up @@ -141,7 +141,7 @@ require (
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/procfs v0.15.1 // indirect
github.com/protocolbuffers/txtpbfmt v0.0.0-20231025115547-084445ff1adf // indirect
github.com/protocolbuffers/txtpbfmt v0.0.0-20240823084532-8e6b51fa9bef // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/robfig/cron v1.2.0 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cuelabs.dev/go/oci/ociregistry v0.0.0-20240906074133-82eb438dd565 h1:R5wwEcbEZSBmeyg91MJZTxfd7WpBo2jPof3AYjRbxwY=
cuelabs.dev/go/oci/ociregistry v0.0.0-20240906074133-82eb438dd565/go.mod h1:5A4xfTzHTXfeVJBU6RAUf+QrlfTCW+017q/QiW+sMLg=
cuelang.org/go v0.11.0-alpha.3 h1:KipbP157eNB59we+6p6VvR2VgskMR/x3UhflJZF++y0=
cuelang.org/go v0.11.0-alpha.3/go.mod h1:v4uj1INFL5yGorRYlr5W2oMjRjKi/ClHU8AeipYie/8=
cuelang.org/go v0.11.0-alpha.4 h1:+OzuIIrCcXl8+lOBdxVFjb+D9xcj+ZTlnSG+1lf0V5w=
cuelang.org/go v0.11.0-alpha.4/go.mod h1:3OQOwNq6qr1BJy1AVShmUZJceKMVYSnBto2txFc0BWE=
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
Expand Down Expand Up @@ -351,8 +351,8 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/prometheus/promu v0.17.0 h1:lrYuxTON9hImNM3lS0CgjJKqsV3WereHQoqrMMuyFmI=
github.com/prometheus/promu v0.17.0/go.mod h1:H4qXHbrvfowu3bY33DuI9fkO69nBbEF8tWu6arhhPoA=
github.com/protocolbuffers/txtpbfmt v0.0.0-20231025115547-084445ff1adf h1:014O62zIzQwvoD7Ekj3ePDF5bv9Xxy0w6AZk0qYbjUk=
github.com/protocolbuffers/txtpbfmt v0.0.0-20231025115547-084445ff1adf/go.mod h1:jgxiZysxFPM+iWKwQwPR+y+Jvo54ARd4EisXxKYpB5c=
github.com/protocolbuffers/txtpbfmt v0.0.0-20240823084532-8e6b51fa9bef h1:ej+64jiny5VETZTqcc1GFVAPEtaSk6U1D0kKC2MS5Yc=
github.com/protocolbuffers/txtpbfmt v0.0.0-20240823084532-8e6b51fa9bef/go.mod h1:jgxiZysxFPM+iWKwQwPR+y+Jvo54ARd4EisXxKYpB5c=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
Expand Down
2 changes: 1 addition & 1 deletion internal/api/discovery/cuetils/cuetils.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewFromSchema(v cue.Value) ([]*Node, error) {
}
for it.Next() {
queue = append(queue, iteratorQueue{
fieldName: it.Label(),
fieldName: it.Selector().String(),
value: it.Value(),
parent: root,
})
Expand Down
4 changes: 2 additions & 2 deletions internal/api/discovery/cuetils/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func buildTree(queue []iteratorQueue) error {
for it.Next() {
node.Type = StructNodeType
queue = append(queue, iteratorQueue{
fieldName: it.Label(),
fieldName: it.Selector().String(),
value: it.Value(),
parent: node,
})
Expand Down Expand Up @@ -259,7 +259,7 @@ func buildMapFromStructValue(v cue.Value) map[string]cue.Value {
result := make(map[string]cue.Value)
it, _ := v.Fields()
for it.Next() {
result[it.Label()] = it.Value()
result[it.Selector().String()] = it.Value()
}
return result
}
Expand Down
Loading