mirror of
https://github.com/caddyserver/xcaddy.git
synced 2024-11-04 16:30:12 +00:00
Assume Caddy v2 if no semantic version is available
Useful if providing just a commit SHA
This commit is contained in:
parent
01dba9ce94
commit
362c34597d
2 changed files with 10 additions and 11 deletions
13
builder.go
13
builder.go
|
@ -106,7 +106,7 @@ func newTempFolder() (string, error) {
|
|||
return "", err
|
||||
}
|
||||
}
|
||||
ts := time.Now().Format(YearMonthDayHourMin)
|
||||
ts := time.Now().Format(yearMonthDayHourMin)
|
||||
return ioutil.TempDir(parentDir, fmt.Sprintf("buildenv_%s.", ts))
|
||||
}
|
||||
|
||||
|
@ -148,16 +148,9 @@ func versionedModulePath(modulePath, moduleVersion string) (string, error) {
|
|||
var moduleVersionRegexp = regexp.MustCompile(`.+/v(\d+)$`)
|
||||
|
||||
const (
|
||||
// YearMonthDayHourMin is the date format
|
||||
// yearMonthDayHourMin is the date format
|
||||
// used for temporary folder paths.
|
||||
YearMonthDayHourMin = "2006-01-02-1504"
|
||||
|
||||
// // ParallelBuildOps is how many build operations
|
||||
// // to perform in parallel (`go build -p` value)
|
||||
// ParallelBuildOps = 4
|
||||
|
||||
// CaddyRepo is the repository path of the Caddy package.
|
||||
CaddyRepo = "https://github.com/caddyserver/caddy.git"
|
||||
yearMonthDayHourMin = "2006-01-02-1504"
|
||||
|
||||
defaultCaddyModulePath = "github.com/caddyserver/caddy"
|
||||
)
|
||||
|
|
|
@ -23,11 +23,17 @@ import (
|
|||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func newEnvironment(caddyVersion string, plugins []CaddyPlugin) (*environment, error) {
|
||||
caddyModulePath, err := versionedModulePath(defaultCaddyModulePath, caddyVersion)
|
||||
// assume v2 if no semantic version is provided
|
||||
caddyModulePath := defaultCaddyModulePath
|
||||
if !strings.HasPrefix(caddyVersion, "v") || !strings.Contains(caddyVersion, ".") {
|
||||
caddyModulePath += "/v2"
|
||||
}
|
||||
caddyModulePath, err := versionedModulePath(caddyModulePath, caddyVersion)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue