Skip to content

feat(core): apply new ref scheme for directories and files - #7609

Closed
grouville wants to merge 4 commits into
dagger:mainfrom
grouville:unify-git-source-ref
Closed

grouville wants to merge 4 commits into
dagger:mainfrom
grouville:unify-git-source-ref

Conversation

@grouville

@grouville grouville commented Jun 11, 2024 •

Copy link
Copy Markdown
Member

Follow-up of #7511 (rebased on top of it)

This applies the new ref scheme to directories and files (moving out from the buildkit syntax), whilst remaining retrocompatible

Implementation

This does not change the cmd/flags logic as we only convert the new ref scheme to buildkit's ref scheme whilst remaining retrocompatible

As part of the implementation, we move the parseRefString implementation to the vcs package, to avoid dependency hell issue between the core and the CLI.

We introduce a ParseRef Func type, aimed to be used by ConvertToBuildKitRef to handle the two specific use-cases:
parseRefStringDir and parseRefStringFile

We rename parseRefString to parseRefStringDir, as it was intended for directory ref parsing, and we duplicate its logic for files. The only difference is the stat type: parseRefStringFile makes sure that the file exists locally as part of the implicit local file interpolation

@grouville grouville changed the title feat(core): apply new ref schema for directories and files feat(core): apply new ref scheme for directories and files Jun 11, 2024
Comment thread engine/vcs/convert_test.go Outdated
Comment on lines 72 to 82

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.

Hm, this shouldn't be a valid syntax.

The supported syntaxes should either be:

  • The older buildkit ref style
  • The newer module ref style

I don't think this is either of the above?

@grouville grouville Jun 12, 2024 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ok 👌
I wanted to cover all the test cases of the current TestParseGit whilst adding the version / subdir:
https://github.com/dagger/dagger/blob/main/cmd/dagger/module_test.go#L148

As they seemed permitted, some users might be using such implicit ssh ref, with the version in old style I agree ?

I understand, so no ssh ref style on the new ref scheme ?

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.

Oh agreed, it's just that this specific case isn't in there.

@grouville
grouville force-pushed the unify-git-source-ref branch 2 times, most recently from e54954a to f22fa51 Compare June 13, 2024 06:14
@grouville
grouville requested a review from jedevc June 13, 2024 06:23
@grouville
grouville marked this pull request as ready for review June 13, 2024 06:52
@grouville
grouville requested review from a team as code owners June 13, 2024 06:52
@grouville
grouville requested a review from marcosnils June 13, 2024 06:53
…directory ref style

This reimplements in a far better way the conversion logic from previous
ref to the new ref scheme.

As part of it, we move the parseRefString implementation to the vcs
package, to avoid dependency hell issue between the core and the CLI.

We introduce a ParseRef Func type, aimed to be used by
ConvertToBuildKitRef to handle the two specific use-cases:
parseRefStringDir and parseRefStringFile

We rename parseRefString to parseRefStringDir, as it was intended for
directory ref parsing, and we duplicate its logic for files. The only
difference is the stat type: parseRefStringFile makes sure that the file
exists locally as part of the implicit local file interpolation

An in-depth test suite is also implemented to ensure retrocompatibility as well as proper conversion of those local / remote refs

Signed-off-by: Guillaume de Rouville <[email protected]>
There used to be a few cases in which the repoRoot.Repo did not have a
.git suffix (e.g. GitLab).

We unify its output to manually make sure it is never present:

Signed-off-by: Guillaume de Rouville <[email protected]>
@grouville
grouville force-pushed the unify-git-source-ref branch from c731862 to e493cff Compare June 13, 2024 18:40
Signed-off-by: Guillaume de Rouville <[email protected]>
@grouville
grouville force-pushed the unify-git-source-ref branch from e493cff to 138f114 Compare June 13, 2024 23:41
The CLI now relies on modulesourcekind to isolate the kind of module
being loaded. This helps us have a consistent behavior regarding
local file / dir refs that resembles remote ones

However, as the enum implementation was part of the core package, it
introduced build constraints. Moving the implementation to the core/modules subpackage solves it

Signed-off-by: Guillaume de Rouville <[email protected]>
@grouville

Copy link
Copy Markdown
Member Author

Failure seems unrelated to implementation

@gerhard

gerhard commented Jun 18, 2024

Copy link
Copy Markdown
Contributor

Want to rebase @grouville as soon as we have upgraded our CI to v0.11.8? Pretty sure there will be a PR from @jedevc for this later today.

@grouville grouville mentioned this pull request Jun 19, 2024
3 of 5 tasks
@grouville
grouville marked this pull request as draft June 19, 2024 06:10
@grouville

Copy link
Copy Markdown
Member Author

Want to rebase @grouville as soon as we have upgraded our CI to v0.11.8? Pretty sure there will be a PR from @jedevc for this later today.

I think we should review / rebase it once #7708 gets merged as it will impose the ref style for private git repo

@jedevc

jedevc commented Jun 24, 2024

Copy link
Copy Markdown
Contributor

x-linking #6957 - not entirely sure how these should interact.

Comment thread cmd/dagger/flags.go
if subdir := parsedGit.Fragment.Subdir; subdir != "" {
gitDir = gitDir.Directory(subdir)
bk := &osBuildkitClient{}
ref, kind := vcs.ConvertToBuildKitRef(ctx, v.String(), bk, vcs.ParseRefStringDir)

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 should be able to remove this function. Instead, we have parseGit call vcs.ParseRef, and then we can extract host, subpath, etc from there 🎉

We should avoid the dance of converting a parsed string into a raw string to parse it again - that's going to more error prone and difficult to follow 😱

@github-actions

github-actions Bot commented Jul 9, 2024

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions Bot closed this Jul 24, 2024
@grouville grouville reopened this Jul 24, 2024
@github-actions

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions

Copy link
Copy Markdown
Contributor

This PR was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions Bot closed this Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants