Skip to content

Commit

Permalink
chore: s/k8s-alpha/k8s-libsonnet (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
Duologic authored Jul 2, 2021
1 parent 538ab3c commit 3cad5ef
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 32 deletions.
6 changes: 3 additions & 3 deletions cmd/tk/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func initCmd() *cli.Command {
}

force := cmd.Flags().BoolP("force", "f", false, "ignore the working directory not being empty")
installK8s := cmd.Flags().String("k8s", defaultK8sVersion, "choose the version of k8s-alpha, set to false to skip")
installK8s := cmd.Flags().String("k8s", defaultK8sVersion, "choose the version of k8s-libsonnet, set to false to skip")
inline := cmd.Flags().BoolP("inline", "i", false, "create an inline environment")

cmd.Run = func(cmd *cli.Command, args []string) error {
Expand Down Expand Up @@ -99,11 +99,11 @@ func installK8sLib(version string) error {
}

var initialPackages = []string{
"github.com/jsonnet-libs/k8s-alpha/" + version,
"github.com/jsonnet-libs/k8s-libsonnet/" + version + "@main",
"github.com/grafana/jsonnet-libs/ksonnet-util",
}

if err := writeNewFile("lib/k.libsonnet", "import 'github.com/jsonnet-libs/k8s-alpha/"+version+"/main.libsonnet'\n"); err != nil {
if err := writeNewFile("lib/k.libsonnet", "import 'github.com/jsonnet-libs/k8s-libsonnet/"+version+"/main.libsonnet'\n"); err != nil {
return err
}

Expand Down
6 changes: 3 additions & 3 deletions docs/docs/directory-structure.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Tanka uses the following directories and special files:
├── jsonnetfile.json # direct dependencies
├── jsonnetfile.lock.json # all dependencies with exact versions
├── lib # libraries for this project only
│   └── k.libsonnet # alias file for vendor/github.com/jsonnet-libs/k8s-alpha/1.21/main.libsonnet
│   └── k.libsonnet # alias file for vendor/github.com/jsonnet-libs/k8s-libsonnet/1.21/main.libsonnet
└── vendor # external libraries installed using jb
├── github.com
│   ├── grafana
Expand All @@ -26,11 +26,11 @@ Tanka uses the following directories and special files:
│   │   ├── ...
│   │   └── kausal.libsonnet
│   └── jsonnet-libs
│   └── k8s-alpha
│   └── k8s-libsonnet
│   └── 1.21 # kubernetes library
│   ├── ...
│   └── main.libsonnet
├── 1.21 -> github.com/jsonnet-libs/k8s-alpha/1.21
├── 1.21 -> github.com/jsonnet-libs/k8s-libsonnet/1.21
└── ksonnet-util -> github.com/grafana/jsonnet-libs/ksonnet-util
```

Expand Down
10 changes: 5 additions & 5 deletions docs/docs/known-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ requires your code to be inside of one of the

### Evaluating jsonnet: RUNTIME ERROR: couldn't open import "k.libsonnet": no match locally or in the Jsonnet library paths

This error can occur when the `k8s-alpha` kubernetes libraries are missing in the
import paths. While `k8s-alpha` used to magically include them, Tanka follows a
This error can occur when the `k8s-libsonnet` kubernetes libraries are missing in the
import paths. While `k8s-libsonnet` used to magically include them, Tanka follows a
more explicit approach and requires you to install them using `jb`:

```bash
$ jb install github.com/jsonnet-libs/k8s-alpha/1.21
$ echo "import 'github.com/jsonnet-libs/k8s-alpha/1.21/main.libsonnet'" > lib/k.libsonnet
$ jb install github.com/jsonnet-libs/k8s-libsonnet/1.21@main
$ echo "import 'github.com/jsonnet-libs/k8s-libsonnet/1.21/main.libsonnet'" > lib/k.libsonnet
```

This does 2 things:

1) It installs the `k8s-alpha` library (in `vendor/github.com/jsonnet-libs/k8s-alpha/1.21/`).
1) It installs the `k8s-libsonnet` library (in `vendor/github.com/jsonnet-libs/k8s-libsonnet/1.21/`).
You can replace the `1.21` matching the Kubernetes version you want to run against.

2) It makes an alias for libraries importing `k.libsonnet` directly. See
Expand Down
30 changes: 15 additions & 15 deletions docs/docs/tutorial/k-lib.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@ Writing and maintaining such a library could be a full-time job on it's own.
Luckily, it is possible to generate such a library from the Kubernetes OpenAPI
specification! Even better, it has already been done for you.

## k8s-alpha
## k8s-libsonnet

The library is called `k8s-alpha` (replacing the discontinued `ksonnet-lib`),
currently available at https://github.com/jsonnet-libs/k8s-alpha.
The library is called `k8s-libsonnet` (replacing the discontinued `ksonnet-lib`),
currently available at https://github.com/jsonnet-libs/k8s-libsonnet.

> **Note**: The `ksonnet` project has been abandoned, the library is not maintained
> anymore. However, the community backed by Grafana Labs has picked up on this with
> the `k8s-alpha` library.
> the `k8s-libsonnet` library.
As `k8s-alpha` has broken compatibility in a few places with `ksonnet-lib` (for good
As `k8s-libsonnet` has broken compatibility in a few places with `ksonnet-lib` (for good
reason), we have instrumented the widely used `ksonnet-util` library with a
compatibility layer to improve the developer and user experience:
https://github.com/grafana/jsonnet-libs/tree/master/ksonnet-util

If you do not have any strong reasons against it, just adopt the wrapper as
well, it will ease your work. Many of the original `ksonnet-util` enhancements
have already made their way into `k8s-alpha`.
have already made their way into `k8s-libsonnet`.

The docs for `k8s-alpha` library can be found here:
https://jsonnet-libs.github.io/k8s-alpha/
The docs for `k8s-libsonnet` library can be found here:
https://jsonnet-libs.github.io/k8s-libsonnet/

## Installation

Like every other external library, `k8s-alpha` can be installed using
Like every other external library, `k8s-libsonnet` can be installed using
`jsonnet-bundler`.
However, Tanka already **did this for you** during [project
creation (`tk init`)](/tutorial/jsonnet#creating-a-new-project):

```bash
$ tk init
└─ jb install github.com/jsonnet-libs/k8s-alpha/1.21 github.com/grafana/jsonnet-libs/ksonnet-util
└─ jb install github.com/jsonnet-libs/k8s-libsonnet/1.21@main github.com/grafana/jsonnet-libs/ksonnet-util

```

Expand All @@ -60,11 +60,11 @@ vendor
│   │   ├── ...
│   │   └── kausal.libsonnet # Grafana's wrapper
│   └── jsonnet-libs
│   └── k8s-alpha
│   └── k8s-libsonnet
│   └── 1.21
│   ├── ...
│   └── main.libsonnet # k8s-alpha entrypoint
├── 1.21 -> github.com/jsonnet-libs/k8s-alpha/1.21
│   └── main.libsonnet # k8s-libsonnet entrypoint
├── 1.21 -> github.com/jsonnet-libs/k8s-libsonnet/1.21
└── ksonnet-util -> github.com/grafana/jsonnet-libs/ksonnet-util
```

Expand All @@ -74,7 +74,7 @@ vendor
#### Aliasing
Because of how `jb` works, the library can be imported as
`github.com/jsonnet-libs/k8s-alpha/1.21/main.libsonnet`. Most external
`github.com/jsonnet-libs/k8s-libsonnet/1.21/main.libsonnet`. Most external
libraries (including our wrapper) expect it as a simple `k.libsonnet` (without
the package prefix).

Expand All @@ -84,7 +84,7 @@ alternative name as well.

> **More information**:
> This works, because `import` behaves like copy-pasting. So the contents of
> `k8s-alpha/1.21` are "copied" into our new file, making them behave exactly the
> `k8s-libsonnet/1.21` are "copied" into our new file, making them behave exactly the
> same.
## Using it
Expand Down
4 changes: 2 additions & 2 deletions examples/prom-grafana/jsonnetfile.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
{
"source": {
"git": {
"remote": "https://github.com/jsonnet-libs/k8s-alpha.git",
"remote": "https://github.com/jsonnet-libs/k8s-libsonnet.git",
"subdir": "1.21"
}
},
"version": "master"
"version": "main"
}
],
"legacyImports": true
Expand Down
6 changes: 3 additions & 3 deletions examples/prom-grafana/jsonnetfile.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
{
"source": {
"git": {
"remote": "https://github.com/jsonnet-libs/k8s-alpha.git",
"remote": "https://github.com/jsonnet-libs/k8s-libsonnet.git",
"subdir": "1.21"
}
},
"version": "b3200f1ead8ebb74932673a41748194950564686",
"sum": "QVUm2JrNnhjorXlfsNBDV0uvPgSWUolMYG9UzWLo1qQ="
"version": "e02dc383505f699ba525861303d167387912278e",
"sum": "nwLFNxWjkftavkDSIFcme+t3KowULjBJn/lgcghru+o="
}
],
"legacyImports": false
Expand Down
2 changes: 1 addition & 1 deletion examples/prom-grafana/lib/k.libsonnet
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'github.com/jsonnet-libs/k8s-alpha/1.21/main.libsonnet'
import 'github.com/jsonnet-libs/k8s-libsonnet/1.21/main.libsonnet'

0 comments on commit 3cad5ef

Please sign in to comment.