Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(agent/agentcontainers): generate devcontainer metadata from schema#16881

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
johnstcn merged 8 commits intomainfromcj/gen-devcontainer-schema
Mar 18, 2025

Conversation

johnstcn
Copy link
Member

@johnstcnjohnstcn commentedMar 11, 2025
edited
Loading

Generated usingglideapps/quicktype. This is unlikely to change often, but checking it into the repo and adding the ability to update when required.

@johnstcnjohnstcn self-assigned thisMar 11, 2025
@johnstcnjohnstcnforce-pushed thecj/gen-devcontainer-schema branch from4c2532a to075d291CompareMarch 12, 2025 16:02
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Awesome! Is quicktype already a dependency or should we add it to our image/nix/etc? Are you adding a Makefile entry later?

Hmm.. Speaking of Makefile, I wonder if we should commit the spec.json so that we can ensure in CI that there are no changes by gen.

@@ -183,7 +184,7 @@ func devcontainerEnv(ctx context.Context, execer agentexec.Execer, container str
return nil, nil
}

meta := make([]DevContainerMeta, 0)
meta := make([]dcspec.DevContainer, 0)
if err := json.Unmarshal([]byte(rawMeta), &meta); err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Suggestion: We could first attempt a strict unmarshal viadec := json.NewDecoder(), dec.DisallowUnknownFields(), if it catches an issue we can log it and fall-back to non-strict unmarshaling.

Not strictly necessary, but may help provide hints down the line why something isn't working.

johnstcn reacted with thumbs up emoji
@@ -192,7 +193,10 @@ func devcontainerEnv(ctx context.Context, execer agentexec.Execer, container str
env := make([]string, 0)
for _, m := range meta {
for k, v := range m.RemoteEnv {
env = append(env, fmt.Sprintf("%s=%s", k, v))
if v == nil { // *string per spec
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I interpret this as env vark should be removed. Does the spec specify more concretely what null means in this context (or do we have to try it out)?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Unfortunately, no. I think we'll have to either try it out or read the implementation.

Copy link
Member

@mafredrimafredriMar 14, 2025
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It seems@devcontainer/cli has a poor implementation, from:

"remoteEnv": {"FOO":"bar","NODE_OPTIONS":"","GOPRIVATE":null},

We get this.

NODE_OPTIONS=GOPRIVATE=nullFOO=bar

I'm not a fan of the null handling here. But if we want to retain a similar behavior, we shouldn't just skip it.

I'd suggest setting it to an empty string when "none", does that sound reasonable? Or do we want to mimic@devcontainer/cli exactly here?

johnstcn reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Having anull sneak in is suprising behaviour to me. I'd honestly prefer an empty string, but we can revisit this if it causes compat issues.

@johnstcn
Copy link
MemberAuthor

johnstcn commentedMar 12, 2025
edited
Loading

Awesome! Is quicktype already a dependency or should we add it to our image/nix/etc? Are you adding a Makefile entry later?

I was hoping to avoid adding a new dependency, but I can add it.

Hmm.. Speaking of Makefile, I wonder if we should commit the spec.json so that we can ensure in CI that there are no changes by gen.

I can do that! Depends on how much spec stuff we want lying around inagent/agentcontainers.

@mafredri
Copy link
Member

I was hoping to avoid adding a new dependency, but I can add it.

True. It's just that without locking in the version, it might at some point be hard to reproduce a working copy if the output ever diverges.

I can do that! Depends on how much spec stuff we want lying around inagent/agentcontainers.

My main concern is having code that's never or rarely run and ends up being incompatible by the time its needed.

I suppose we have two options. 1) Keep it download-only and only run it (manually) when we know there's an update, or 2) Commit the spec json and run generate every time.

For 1) a CI cron to check if the output/spec changed would be good. And for 2) we may still want to do CI cron, but in general it will ensure our quicktype dependency remains compatible for when it's needed the next time.

@johnstcnjohnstcnforce-pushed thecj/gen-devcontainer-schema branch from23209fc to2a565b3CompareMarch 13, 2025 21:29
@johnstcn
Copy link
MemberAuthor

  1. Commit the spec json and run generate every time.

I went ahead with option 2!

Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Just a minor nit (as well as? re: null handling), but this is looking great! Thanks for improving the codegen.

Approving, as I don't need to re-review.

mv -v "${TMPDIR}/${DEST_FILENAME}" "${DEST_PATH}"

# Add a header so that Go recognizes this as a generated file.
sed -i '1s/^/\/\/ Code generated by dcspec\/gen.sh. DO NOT EDIT.\n/' "${DEST_PATH}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This transformation could be done in temp still, before the move.

But unfortunately, this is not cross-platform 😔.

If you want a quick fix and not use another tool, see:a1f5468

johnstcn reacted with heart emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Nice callout, thanks!

@johnstcnjohnstcn merged commit13a3ddd intomainMar 18, 2025
31 of 33 checks passed
@johnstcnjohnstcn deleted the cj/gen-devcontainer-schema branchMarch 18, 2025 13:00
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMar 18, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

@SasSwartSasSwartAwaiting requested review from SasSwart

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@johnstcn@mafredri

[8]ページ先頭

©2009-2025 Movatter.jp