Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
cue/load: make cue.mod the default desitination
Browse files Browse the repository at this point in the history
This effects generation, for instance.

- also update Kubernetes tutorial to use `cue mod init`

Change-Id: I9ff9f023f6771057e86f9f51f6c9c35c095939ce

Closes #168
#168

GitOrigin-RevId: ff720b2
Change-Id: I978632c1697e053c12f51729d6abe9f778b771aa
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/3867
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
  • Loading branch information
mpvl committed Oct 25, 2019
1 parent 9707302 commit b13155b
Show file tree
Hide file tree
Showing 57 changed files with 23 additions and 12 deletions.
8 changes: 4 additions & 4 deletions cue/load/loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ err: relative import paths not allowed ("./file")
path: ""
module: example.org/test
root: $CWD/testdata
dir: $CWD/testdata/pkg
dir: $CWD/testdata/cue.mod/gen
display:`,
}, {
cfg: dirCfg,
Expand Down Expand Up @@ -192,7 +192,7 @@ err: cannot find package "non-existing"
path: non-existing
module: example.org/test
root: $CWD/testdata
dir: $CWD/testdata/pkg/non-existing
dir: $CWD/testdata/cue.mod/gen/non-existing
display:non-existing`,
}, {
cfg: dirCfg,
Expand All @@ -216,8 +216,8 @@ display:./imports
files:
$CWD/testdata/imports/imports.cue
imports:
acme.com/catch: $CWD/testdata/pkg/acme.com/catch/catch.cue
acme.com/helper:helper1: $CWD/testdata/pkg/acme.com/helper/helper1.cue`,
acme.com/catch: $CWD/testdata/cue.mod/pkg/acme.com/catch/catch.cue
acme.com/helper:helper1: $CWD/testdata/cue.mod/pkg/acme.com/helper/helper1.cue`,
}, {
cfg: dirCfg,
args: args("./toolonly"),
Expand Down
File renamed without changes.
17 changes: 9 additions & 8 deletions doc/tutorial/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,24 @@ We first make a copy of the data directory.

```
$ cp -a original tmp
$ cd tmp/services
$ cd tmp
```

<!-- TODO
Although not strictly necessary, we mark the root of the configuration tree
for good measure.
We initialize a module so that we can treat all our configuration files
in the subdirectories as part of one package.
We do that later by giving all the same package name.

```
$ touch ../cue.mod
cue mod init
$ cue mod init
```
-->

Creating a module also allows our packages import external packages.

Let's try to use the `cue import` command to convert the given YAML files
into CUE.

```
$ cd services
$ cue import ./...
Import failed: must specify package name with the -p flag
```
Expand Down Expand Up @@ -1051,7 +1052,7 @@ $ cue get go k8s.io/api/apps/v1beta1
```

Now that we have the Kubernetes definitions in `pkg`, we can import and use them:
Now that we have the Kubernetes definitions in our module, we can import and use them:

```
$ cat <<EOF > k8s_defs.cue
Expand Down
Empty file.
1 change: 1 addition & 0 deletions doc/tutorial/kubernetes/quick/cue.mod/module.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module: ""
9 changes: 9 additions & 0 deletions doc/tutorial/kubernetes/tut_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ func TestTutorial(t *testing.T) {
t.Fatal(err)
}

cuetest.Run(t, dir, "cue mod init", &cuetest.Config{
// Stdin: strings.NewReader(input),
})

if *update {
// The test environment won't work in all environments. We create
// a fake go.mod so that Go will find the module root. By default
Expand Down Expand Up @@ -152,6 +156,11 @@ func TestTutorial(t *testing.T) {
// Don't execute the kubernetes dry run.
break
}
if strings.HasPrefix(cmd, "cue mod init") {
// Already ran this at setup.
break
}

if !*update && strings.HasPrefix(cmd, "cue get") {
// Don't fetch stuff in normal mode.
break
Expand Down

0 comments on commit b13155b

Please sign in to comment.