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

Thoughts on moving this to jsr.io? #8

Closed
justinmchase opened this issue Sep 1, 2024 · 7 comments
Closed

Thoughts on moving this to jsr.io? #8

justinmchase opened this issue Sep 1, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@justinmchase
Copy link

I've been using it, it works. It seems like jsr.io is denos long term plan for modules and it would be nice to see this get re-homed there from a maintenance perspective.

@danopia
Copy link
Member

danopia commented Sep 1, 2024

Sounds reasonable. I haven't familiarized myself with the publish process yet. I think jsr has scopes so I suppose I'd make a cloudydeno scope.

@justinmchase
Copy link
Author

Yeah you need a scope and it has a similar feature where you can link it to your repo which grants you OIDC auth access from your workflows.

Here is an example of a super simple publish workflow I did in one of my repos:
https://github.com/justinmchase/type/blob/main/.github/workflows/publish.yml

@danopia danopia added the enhancement New feature or request label Sep 5, 2024
@danopia
Copy link
Member

danopia commented Sep 8, 2024

I've registered a scope etc, but getting this particular module published will take a little longer. Complications include:

  1. Can't import from https:// in JSR modules. I use several of my other modules and I'll likely be migrating those first:

    image

  2. JSR requires listing all entrypoints for the package. I treat each Kubernetes API as its own entrypoint, so I'll have to update my generation pipeline to update the JSR entrypoint list as well.

@danopia
Copy link
Member

danopia commented Sep 9, 2024

I have published my first JSR package :) https://jsr.io/@cloudydeno/stream-observables

Will continue biting a chunk off every day or two. JSR has some new guidelines, even for stream-observables it made me update some of the files to pass the slowtypes check.

@danopia
Copy link
Member

danopia commented Sep 18, 2024

I now have @cloudydeno/kubernetes-client on JSR in parallel with /x/.

(I don't intend to drop /x/ for some time as I expect this module is imported in various scripts/libraries and don't want to suddenly gate updates behind switching those scripts to JSR imports. At least until I get my own scripts happily importing from JSR)

The remaining work here in #13 is JSR's slow-types audit. In particular all functions in the public API must have an explicit return type gets flagged for all of my generated files. So I'll need to amend the codegen to put explicit return types. Especially on the structure validation functions like these:

export function toVerticalPodAutoscalerCheckpoint_spec(input: c.JSONValue) {
const obj = c.checkObj(input);
return {
containerName: c.readOpt(obj["containerName"], c.checkStr),
vpaObjectName: c.readOpt(obj["vpaObjectName"], c.checkStr),
}}
export function toVerticalPodAutoscalerCheckpoint_status(input: c.JSONValue) {
const obj = c.checkObj(input);
return {
cpuHistogram: c.readOpt(obj["cpuHistogram"], toVerticalPodAutoscalerCheckpoint_status_cpuHistogram),
firstSampleStart: c.readOpt(obj["firstSampleStart"], c.toTime),
lastSampleStart: c.readOpt(obj["lastSampleStart"], c.toTime),
lastUpdateTime: c.readOpt(obj["lastUpdateTime"], c.toTime),
memoryHistogram: c.readOpt(obj["memoryHistogram"], toVerticalPodAutoscalerCheckpoint_status_memoryHistogram),
totalSamplesCount: c.readOpt(obj["totalSamplesCount"], c.checkNum),
version: c.readOpt(obj["version"], c.checkStr),
}}
export function toVerticalPodAutoscalerCheckpoint_status_cpuHistogram(input: c.JSONValue) {
const obj = c.checkObj(input);
return {
bucketWeights: c.readOpt(obj["bucketWeights"], c.identity),
referenceTimestamp: c.readOpt(obj["referenceTimestamp"], c.toTime),
totalWeight: c.readOpt(obj["totalWeight"], c.checkNum),
}}
export function toVerticalPodAutoscalerCheckpoint_status_memoryHistogram(input: c.JSONValue) {
const obj = c.checkObj(input);
return {
bucketWeights: c.readOpt(obj["bucketWeights"], c.identity),
referenceTimestamp: c.readOpt(obj["referenceTimestamp"], c.toTime),
totalWeight: c.readOpt(obj["totalWeight"], c.checkNum),
}}

I also need to add a LICENSE, I'm taking Apache-2 from kubernetes project

@danopia
Copy link
Member

danopia commented Sep 20, 2024

Importing from JSR should work now, e.g.:

import { autoDetectClient } from "jsr:@cloudydeno/[email protected]";
import { CoreV1Api } from "jsr:@cloudydeno/[email protected]/core/v1";

const coreV1 = new CoreV1Api(await autoDetectClient());
const podList = await coreV1.namespace("nginx-internet").getPodList()
console.log(podList.items.map(x => x.metadata?.name));

Note that the module exports are a bit different. There's a slash between the apigroup and apiversion.
The jsr docs are actually kind of ok about this, once you pick an entrypoint anyway, e.g. https://jsr.io/@cloudydeno/[email protected]/doc/networking.k8s.io/v1/~

Let me know if you have any issues using it

@justinmchase
Copy link
Author

Very nice, I forgot to mention that the dependent modules sort of needed to be virally updated as well but I had the same experience updating some of my packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants