Skip to content

Commit 2f371b3

Browse files
[ENHANCEMENT] cue/common: provide new standard definitions for datasource plugins
Signed-off-by: AntoineThebaud <antoine.thebaud@yahoo.fr>
1 parent 653507d commit 2f371b3

3 files changed

Lines changed: 58 additions & 4 deletions

File tree

cue-test/common/datasource.cue

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Copyright The Perses Authors
2+
// Licensed under the Apache License, Version 2.0 (the "License");
3+
// you may not use this file except in compliance with the License.
4+
// You may obtain a copy of the License at
5+
//
6+
// http://www.apache.org/licenses/LICENSE-2.0
7+
//
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
14+
package common
15+
16+
myDirectSpec: {
17+
common.#baseDatasourceSpec
18+
directUrl: "localhost:8080"
19+
}
20+
21+
myProxySpec: {
22+
common.#baseDatasourceSpec
23+
proxy: {
24+
kind: "HTTPProxy",
25+
spec: {
26+
url: "https://prometheus.demo.prometheus.io",
27+
allowedEndpoints: [
28+
{
29+
endpointPattern: "/api/v1/labels",
30+
method: "POST"
31+
},
32+
{
33+
endpointPattern: "/api/v1/series",
34+
method: "POST"
35+
},
36+
]
37+
}
38+
},
39+
}
40+
41+
myDsVarSelector: #datasourceSelector & { _kind: "MyDatasource" }
42+
43+
myDsVarSelector: #datasourceSelector & { datasource: "$dsVar" }

cue-test/common/format.cue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
package common
1515

1616
myFormat: #format & {
17-
decimalPlaces: 0
18-
shortValues: false
17+
decimalPlaces: 0
18+
shortValues: false
1919
}

cue/common/datasource.cue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,20 @@
1313

1414
package common
1515

16+
#baseDatasourceSpec: #directUrl | #proxy
17+
18+
#directUrl: {
19+
directUrl: common.#url
20+
}
21+
22+
#proxy: {
23+
proxy: commonProxy.#HTTPProxy
24+
}
25+
1626
#datasourceSelector: {
27+
_kind: string
1728
datasource?: =~#variableSyntaxRegex | {
18-
kind: string
29+
kind: _kind
1930
name?: string
2031
}
21-
}
32+
}

0 commit comments

Comments
 (0)