This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
dagger/mod/require.go

100 lines
2.3 KiB
Go
Raw Normal View History

Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
package mod
import (
"fmt"
"os"
"path"
"path/filepath"
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
"regexp"
"strings"
"go.dagger.io/dagger/pkg"
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
)
type Require struct {
repo string
path string
cloneRepo string
clonePath string
version string
versionConstraint string
checksum string
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
}
func newRequire(repoName, versionConstraint string) (*Require, error) {
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
switch {
case strings.HasPrefix(repoName, pkg.UniverseModule):
return parseDaggerRepoName(repoName, versionConstraint)
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
default:
return parseGitRepoName(repoName, versionConstraint)
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
}
}
var gitRepoNameRegex = regexp.MustCompile(`([a-zA-Z0-9_.-]+(?::\d*)?/[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+)([a-zA-Z0-9/_.-]*)@?([0-9a-zA-Z.-]*)`)
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
func parseGitRepoName(repoName, versionConstraint string) (*Require, error) {
repoMatches := gitRepoNameRegex.FindStringSubmatch(repoName)
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
if len(repoMatches) < 4 {
return nil, fmt.Errorf("issue when parsing github repo")
}
return &Require{
repo: strings.TrimSuffix(repoMatches[1], ".git"),
path: repoMatches[2],
version: repoMatches[3],
versionConstraint: versionConstraint,
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
cloneRepo: repoMatches[1],
clonePath: repoMatches[2],
}, nil
}
var daggerRepoNameRegex = regexp.MustCompile(pkg.UniverseModule + `([a-zA-Z0-9/_.-]*)@?([0-9a-zA-Z.-]*)`)
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
func parseDaggerRepoName(repoName, versionConstraint string) (*Require, error) {
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
repoMatches := daggerRepoNameRegex.FindStringSubmatch(repoName)
if len(repoMatches) < 3 {
return nil, fmt.Errorf("issue when parsing dagger repo")
}
return &Require{
repo: pkg.UniverseModule,
path: repoMatches[1],
version: repoMatches[2],
versionConstraint: versionConstraint,
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
cloneRepo: "github.com/dagger/examples",
clonePath: path.Join("/helloapp", repoMatches[1]),
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
}, nil
}
func (r *Require) String() string {
return fmt.Sprintf("%s@%s", r.fullPath(), r.version)
}
func (r *Require) fullPath() string {
return path.Join(r.repo, r.path)
}
func replace(r *Require, sourceRepoPath, destPath string) error {
// remove previous package directory
if err := os.RemoveAll(destPath); err != nil {
return err
}
// Make sure the destination exists
if err := os.MkdirAll(filepath.Dir(destPath), 0755); err != nil {
return err
}
Vendoring improved * update dagger init with package manager downloading stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * split mod get and update functions Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * write to package checksum to dagger.sum when installing/updating Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * encure checksums are valid when compiling input Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove references to github.com/tjovicic in docs 1010 and 1011 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * refactor mod get command Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update logic of moving dir when installing packages Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * revert changes to 1010 docs Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * updating error log line in mod/get Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix ci tests when using vendoring Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update alpha.dagger.io version to v0.1 Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix mod repo test Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * return error if package already installed Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * remove already installed packages when installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix issue when vendoring stdlib Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * update mod command with filelock while installing Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix linting errors Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> * fix path of mod lock file Signed-off-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Co-authored-by: Tihomir Jovicic <tihomir.jovicic.develop@gmail.com> Signed-off-by: Sam Alba <sam.alba@gmail.com>
2021-10-13 23:32:06 +02:00
if err := os.Rename(path.Join(sourceRepoPath, r.clonePath), destPath); err != nil {
return err
}
return nil
}