Skip to content

replace FS by RootFS - #3882

Merged
aluzzardi merged 5 commits into
dagger:mainfrom
aluzzardi:core-replace-fs-with-rootfs
Nov 17, 2022
Merged

aluzzardi merged 5 commits into
dagger:mainfrom
aluzzardi:core-replace-fs-with-rootfs

Conversation

@aluzzardi

@aluzzardi aluzzardi commented Nov 16, 2022 •

Copy link
Copy Markdown
Contributor
  • Add support for @deprecated GraphQL directive in the API
  • Add support for handling @deprecated fields in the Go SDK codegen
  • Renamed fs -> rootfs and withFS -> withRootfs
  • Kept backward compat with deprecated fs / withFS fields

@helderco @slumbering @dolanor: The same @deprecated support needs to be added to Python and NodeJS as well. We're going to have a bunch like this.

@aluzzardi
aluzzardi requested a review from sipsma November 16, 2022 21:20
@aluzzardi

aluzzardi commented Nov 16, 2022 •

Copy link
Copy Markdown
Contributor Author

Nice -- CI is failing because I forgot to update the code and the Go linter is catching that:

Error: #17 87.65 docs/current/sdk/go/snippets/multiplatform-support/build-images-cross-compilation/main.go:84:16: SA1019: client.
[214](https://github.com/dagger/dagger/actions/runs/3483199821/jobs/5826422113#step:4:215)
#17 87.65 	Container(dagger.ContainerOpts{Platform: platform}).
[215](https://github.com/dagger/dagger/actions/runs/3483199821/jobs/5826422113#step:4:216)
#17 87.65 	WithFS is deprecated: replaced by withRootfs (staticcheck)
[216](https://github.com/dagger/dagger/actions/runs/3483199821/jobs/5826422113#step:4:217)
#17 87.65 		binaryCtr := client.
[217](https://github.com/dagger/dagger/actions/runs/3483199821/jobs/5826422113#step:4:218)
#17 87.65

@aluzzardi
aluzzardi force-pushed the core-replace-fs-with-rootfs branch from c95d2c7 to ce12d93 Compare November 16, 2022 21:26
Comment thread core/schema/container.graphqls Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Let the bike shed commence.

I wasn't sure whether this should be rootfs, rootFs or rootFS.

This becomes Rootfs() and WithRootfs() in Go which is not ideal.

Which one works best in GraphQL and respective languages, @helderco @slumbering?

(note: if we were to call this rootFs, it would be converted as rootFS by Go codegen)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In Python both rootfs and root_fs feel natural. I'm partial to rootfs but I see what you mean in Go.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @helderco!

@sipsma @shykes Any thoughts on this?

  • rootfs (graphql) ->Rootfs() (Go) -> rootfs (Python) -> ?? (Node)
  • rootFS (graphql) -> RootFS() (Go) -> root_fs (Python) -> ?? (Node)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

rootfs (graphql) ->Rootfs() (Go) -> rootfs (Python) -> ?? (Node)

That's my vote, I think it's pretty typical to write "rootfs"/"Rootfs" as a single word rather than emphasizing that "FS" is a acronym. Also just slightly easier to type.

Not a strong opinion though, either is fine with me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For typescript, based on: https://www.typescriptlang.org/tsconfig#watch-watchFile
I would say it would be either rootfs or rootFs.
I would prefer rootfs, but I'll let @slumbering have the last word :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We are using camelCase mostly. So I would go for:
rootfs (graphql) ->Rootfs() (Go) -> rootfs (Python) -> rootFs (so rootFS) (Node)

@aluzzardi
aluzzardi force-pushed the core-replace-fs-with-rootfs branch from ce12d93 to 0df0195 Compare November 16, 2022 21:34
@aluzzardi

This comment was marked as resolved.

@aluzzardi
aluzzardi force-pushed the core-replace-fs-with-rootfs branch from 0df0195 to a0af444 Compare November 16, 2022 22:00
Comment thread internal/mage/util/util.go Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

FYI @sipsma

@helderco

Copy link
Copy Markdown
Contributor

@aluzzardi It's easy enough to add the deprecation notice but I have an issue with the reference documentation. In Sphinx a version is required. I may use a simple warning instead.

@helderco
helderco force-pushed the core-replace-fs-with-rootfs branch from 13b0e8e to ae49436 Compare November 17, 2022 15:24
Comment thread core/schema/container.graphqls Outdated

@helderco helderco Nov 17, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks better if in proper english:
Screen Shot 2022-11-17 at 14 46 04

Suggested change
@deprecated(reason: "replaced by withRootfs")
@deprecated(reason: "Replaced by withRootfs.")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nice! Will do

@helderco helderco Nov 17, 2022 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just noticed an issue... Since the reason references a GraphQL name, when you codegen as is you don't get it through the proper naming conventions for the SDK.

@aluzzardi aluzzardi Nov 17, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I noticed that as well when doing this.

I was thinking having a somewhat "wrong" name is better than not suggesting an alternative at all. And instead of picking the name in a given SDK, I just picked the GraphQL field name. WDYT?

Alternatively, we could structure this e.g. Replaced by @withRootfs and have codegen resolve the symbol

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Implemented the suggestion above in the last commit -- @helderco thoughts?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I like that it enables me to format and turn it into a link, but I'm wondering about the playground. If you go to the GraphQL API directly the @ will look alien there.

Not too alien I think? Maybe `field` would look more natural?

Maybe if we have a set of formatted strings: Replaced by . and any others that we may need. So an SDK regex could match against Replaced by withRootfs. and extract the field from that pattern.

Not sure I fully understand this. What would we write as the reason in GraphQL and how would we know which field it is?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed this to

Replaced by `withRootFs`

Looks just fine in raw GraphQL

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure I fully understand this. What would we write as the reason in GraphQL and how would we know which field it is?

In GraphQL it would be just Replaced by withRootfs. Then in the SDKs you would match by the whole phrase like Replaced by (.*). instead of just the subject.

Anyway, I'm good with the backticks, I'm going to update Python now quickly so you don't get blocked on it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see!

Well, I assumed this could be more dynamic. For instance, we're about to deprecate Host().Workdir(). Depreciation reason could be:

Use `directory` with `path` set to . instead.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To be able to cross-reference in python it's simpler to assume backticks only for other methods:

Use `directory` with path set to '.' instead.

In another object:

Use `Container.directory` instead.

Andrea Luzzardi and others added 3 commits November 17, 2022 11:07
Signed-off-by: Andrea Luzzardi <[email protected]>
Signed-off-by: Andrea Luzzardi <[email protected]>
Signed-off-by: Helder Correia <[email protected]>
Signed-off-by: Andrea Luzzardi <[email protected]>
@aluzzardi
aluzzardi force-pushed the core-replace-fs-with-rootfs branch from fe00d9b to b9ecaa4 Compare November 17, 2022 19:08
@aluzzardi
aluzzardi force-pushed the core-replace-fs-with-rootfs branch from a78fcbc to 99fa2ce Compare November 17, 2022 22:27

@aluzzardi aluzzardi left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added support for NodeJS

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@dolanor Please take a look! Is this the correct pattern?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be.

Question is, what if there is no description but it is deprecated? Then we would generate nothing.

I guess we would need something like that:

Suggested change
{{- if .Description -}}
{{- if or .Description .DeprecationReason -}}

Comment thread sdk/nodejs/api/client.gen.ts Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@slumbering Is this the correct way to do this in TS?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

After investigating, yes it seems to be that format.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes it is @aluzzardi

@sipsma sipsma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Go parts of the changes and the naming of the api lgtm!

Signed-off-by: Andrea Luzzardi <[email protected]>
@aluzzardi

Copy link
Copy Markdown
Contributor Author

About to merge this

@helderco Can you make the field changes in a follow up?
@dolanor @slumbering I implemented the NodeJS part to get this unblocked, could you review/make a follow up if needed?

/cc @kpenfound @jpadams @vikram-dagger FYI of the change

@aluzzardi
aluzzardi merged commit 38bbfd2 into dagger:main Nov 17, 2022
@aluzzardi
aluzzardi deleted the core-replace-fs-with-rootfs branch November 17, 2022 23:42

@dolanor dolanor left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

small comments after the fact.
Maybe the one on the comment generation should be fixed or we might not generate deprecation notice in case there is no description in the first place

Comment thread sdk/nodejs/api/client.gen.ts Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

After investigating, yes it seems to be that format.

Comment thread core/schema/container.graphqls Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For typescript, based on: https://www.typescriptlang.org/tsconfig#watch-watchFile
I would say it would be either rootfs or rootFs.
I would prefer rootfs, but I'll let @slumbering have the last word :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be.

Question is, what if there is no description but it is deprecated? Then we would generate nothing.

I guess we would need something like that:

Suggested change
{{- if .Description -}}
{{- if or .Description .DeprecationReason -}}

@aluzzardi aluzzardi added the kind/breaking Breaking Change label Nov 18, 2022
@helderco helderco mentioned this pull request Apr 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/breaking Breaking Change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants