Add cron jobs to service

This commit is contained in:
dwrz
2026-06-02 12:04:02 +00:00
parent e5238e4081
commit 6fb63c8c90
84 changed files with 3022 additions and 2452 deletions

View File

@@ -61,13 +61,42 @@ func (r *responseDeduper) addAll(dr *DriverResponse) {
}
func (r *responseDeduper) addPackage(p *Package) {
if r.seenPackages[p.ID] != nil {
if prev := r.seenPackages[p.ID]; prev != nil {
// Package already seen in a previous response. Merge the file lists,
// removing duplicates. This can happen when the same package appears
// in multiple driver responses that are being merged together.
prev.GoFiles = appendUniqueStrings(prev.GoFiles, p.GoFiles)
prev.CompiledGoFiles = appendUniqueStrings(prev.CompiledGoFiles, p.CompiledGoFiles)
prev.OtherFiles = appendUniqueStrings(prev.OtherFiles, p.OtherFiles)
prev.IgnoredFiles = appendUniqueStrings(prev.IgnoredFiles, p.IgnoredFiles)
prev.EmbedFiles = appendUniqueStrings(prev.EmbedFiles, p.EmbedFiles)
prev.EmbedPatterns = appendUniqueStrings(prev.EmbedPatterns, p.EmbedPatterns)
return
}
r.seenPackages[p.ID] = p
r.dr.Packages = append(r.dr.Packages, p)
}
// appendUniqueStrings appends elements from src to dst, skipping duplicates.
func appendUniqueStrings(dst, src []string) []string {
if len(src) == 0 {
return dst
}
seen := make(map[string]bool, len(dst))
for _, s := range dst {
seen[s] = true
}
for _, s := range src {
if !seen[s] {
dst = append(dst, s)
}
}
return dst
}
func (r *responseDeduper) addRoot(id string) {
if r.seenRoots[id] {
return
@@ -178,11 +207,10 @@ func goListDriver(cfg *Config, runner *gocommand.Runner, overlay string, pattern
// doesn't exist.
extractQueries:
for _, pattern := range patterns {
eqidx := strings.Index(pattern, "=")
if eqidx < 0 {
query, value, ok := strings.Cut(pattern, "=")
if !ok {
restPatterns = append(restPatterns, pattern)
} else {
query, value := pattern[:eqidx], pattern[eqidx+len("="):]
switch query {
case "file":
containFiles = append(containFiles, value)
@@ -534,8 +562,18 @@ func (state *golistState) createDriverResponse(words ...string) (*DriverResponse
} else {
// golang/go#38990: go list silently fails to do cgo processing
pkg.CompiledGoFiles = nil
var msg strings.Builder
fmt.Fprintf(&msg, "go list failed to return CompiledGoFiles for %q.\n", p.Name)
for _, err := range p.DepsErrors {
msg.WriteString(strings.TrimSpace(err.Err))
msg.WriteByte('\n')
}
msg.WriteString("This may indicate failure to perform cgo processing; try building at the command line. See https://golang.org/issue/38990.")
pkg.Errors = append(pkg.Errors, Error{
Msg: "go list failed to return CompiledGoFiles. This may indicate failure to perform cgo processing; try building at the command line. See https://golang.org/issue/38990.",
Msg: msg.String(),
Kind: ListError,
})
}
@@ -832,6 +870,8 @@ func golistargs(cfg *Config, words []string, goVersion int) []string {
// go list doesn't let you pass -test and -find together,
// probably because you'd just get the TestMain.
fmt.Sprintf("-find=%t", !cfg.Tests && cfg.Mode&findFlags == 0 && !usesExportData(cfg)),
// VCS information is not needed when not printing Stale or StaleReason fields
"-buildvcs=false",
}
// golang/go#60456: with go1.21 and later, go list serves pgo variants, which

View File

@@ -284,6 +284,8 @@ func Load(cfg *Config, patterns ...string) ([]*Package, error) {
}
}
ld.externalDriver = external
return ld.refine(response)
}
@@ -401,6 +403,10 @@ func mergeResponses(responses ...*DriverResponse) *DriverResponse {
if len(responses) == 0 {
return nil
}
// No dedup needed
if len(responses) == 1 {
return responses[0]
}
response := newDeduper()
response.dr.NotHandled = false
response.dr.Compiler = responses[0].Compiler
@@ -533,6 +539,11 @@ type Package struct {
// depsErrors is the DepsErrors field from the go list response, if any.
depsErrors []*packagesinternal.PackageError
// exportDataError is the error encountered reading export data, if any.
// Decoding export data should ordinarily be infallible, so this typically
// indicates a producer/consumer version skew.
exportDataError error
}
// Module provides module information for a package.
@@ -692,10 +703,11 @@ type loaderPackage struct {
type loader struct {
pkgs map[string]*loaderPackage // keyed by Package.ID
Config
sizes types.Sizes // non-nil if needed by mode
parseCache map[string]*parseValue
parseCacheMu sync.Mutex
exportMu sync.Mutex // enforces mutual exclusion of exportdata operations
sizes types.Sizes // non-nil if needed by mode
parseCache map[string]*parseValue
parseCacheMu sync.Mutex
exportMu sync.Mutex // enforces mutual exclusion of exportdata operations
externalDriver bool // true if an external GOPACKAGESDRIVER handled the request
// Config.Mode contains the implied mode (see impliedLoadMode).
// Implied mode contains all the fields we need the data for.
@@ -1066,10 +1078,11 @@ func (ld *loader) loadPackage(lpkg *loaderPackage) {
}
// TODO(adonovan): this condition looks wrong:
// I think it should be lpkg.needtypes && !lpg.needsrc,
// I think it should be lpkg.needtypes && !lpkg.needsrc,
// so that NeedSyntax without NeedTypes can be satisfied by export data.
if !lpkg.needsrc {
if err := ld.loadFromExportData(lpkg); err != nil {
lpkg.exportDataError = err
lpkg.Errors = append(lpkg.Errors, Error{
Pos: "-",
Msg: err.Error(),
@@ -1208,7 +1221,13 @@ func (ld *loader) loadPackage(lpkg *loaderPackage) {
if ipkg.Types != nil && ipkg.Types.Complete() {
return ipkg.Types, nil
}
log.Fatalf("internal error: package %q without types was imported from %q", path, lpkg)
// If types are unavailable, there must be an export data error.
if ipkg.exportDataError != nil {
return nil, ipkg.exportDataError
}
log.Fatalf("internal error: expected complete types for package %q", path)
panic("unreachable")
})
@@ -1226,6 +1245,10 @@ func (ld *loader) loadPackage(lpkg *loaderPackage) {
}
if lpkg.Module != nil && lpkg.Module.GoVersion != "" {
tc.GoVersion = "go" + lpkg.Module.GoVersion
} else if ld.externalDriver && lpkg.goVersion != 0 {
// Module information is missing when GOPACKAGESDRIVER is used,
// so use the go version from the driver response.
tc.GoVersion = fmt.Sprintf("go1.%d", lpkg.goVersion)
}
if (ld.Mode & typecheckCgo) != 0 {
if !typesinternal.SetUsesCgo(tc) {