cue modules: move stdlib to pkg/alpha.dagger.io

In preparation for Europa, we will vendor multiple CUE modules:

- `pkg/alpha.dagger.io`: legacy non-europa packages
- `pkg/dagger.io`: core Europa packages
- `pkg/universe.dagger.io`: Europa universe

Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
Andrea Luzzardi
2022-01-11 12:40:02 -08:00
parent e5316f3a1e
commit 282759c0e5
277 changed files with 33 additions and 31 deletions

View File

@@ -0,0 +1,39 @@
package graphql
import (
"encoding/json"
"alpha.dagger.io/dagger"
"alpha.dagger.io/http"
)
#Query: {
// Contents of the graphql query
query: string
// graphql variables
variable: [key=string]: _
// graphql url
url: string
//API Token
token: dagger.#Input & dagger.#Secret | *null
post: http.#Post & {
"url": url
request: {
body: json.Marshal({
"query": query
variables: json.Marshal(variable)
})
header: "Content-Type": "application/json"
token: token
}
}
payload: {
data: {...}
errors?: {...}
}
payload: json.Unmarshal(post.response.body)
data: payload.data @dagger(output)
errors?: payload.errors @dagger(output)
}

View File

@@ -0,0 +1,55 @@
package graphql
import (
"encoding/json"
"alpha.dagger.io/alpine"
"alpha.dagger.io/dagger"
"alpha.dagger.io/docker"
"alpha.dagger.io/os"
"alpha.dagger.io/http"
)
TestDockersocket: dagger.#Stream & dagger.#Input
TestQuery: {
run: docker.#Run & {
name: "graphql-faker"
ref: "apisguru/graphql-faker"
socket: TestDockersocket
ports: ["8080:9002"]
}
// Waits for TestRun to finish initializing
Testhealth: http.#Wait & {
url: "http://localhost:8080/graphql?query={%7BallCompanies%20%7B%0A%20%20%20%20id%0A%20%20%7D%0A%7D}"
}
queryWithoutToken: #Query & {
url: Testhealth.url
query: #"""
{
company(id: "NjExNjAwMjE5Nw==") {
id
}
}
"""#
}
testRaw: os.#Container & {
image: alpine.#Image & {
package: jq: true
}
env: STATUS: "\(queryWithoutToken.post.response.statusCode)"
shell: args: ["--noprofile", "--norc", "-eo", "pipefail", "-c"]
files: "/content.json": {
content: json.Marshal(queryWithoutToken.data)
mode: 0o500
}
command: #"""
test "$STATUS" = "200"
test "$(cat /content.json | jq '.allCompanies | length')" -gt 1
"""#
}
}