Commits on Source 24

  • Axel von Bertoldi's avatar
    Add modernize linter · bc84caec
    Axel von Bertoldi authored
    bc84caec
  • Axel von Bertoldi's avatar
    Replace interface{} with any · 643f91ec
    Axel von Bertoldi authored
    Fixes the modernize `any` check. `any` has been an alias for
    `interface{}` since Go 1.18, so this is purely lexical and does not
    change the StepInputs/StepOutputs exported API.
    
    Co-Authored-By: default avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    643f91ec
  • Axel von Bertoldi's avatar
    Use fmt.Appendf instead of []byte(fmt.Sprintf(...)) · 0ed4b1af
    Axel von Bertoldi authored
    Fixes the modernize `fmtappendf` check. fmt.Appendf appends directly
    into a byte slice, avoiding the intermediate string allocation.
    
    Co-Authored-By: default avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    0ed4b1af
  • Axel von Bertoldi's avatar
    Use maps.Copy for map copy loops · 629b8f92
    Axel von Bertoldi authored
    Fixes the modernize `mapsloop` check. In ToStructPbValue this also
    removes the inner loop's shadowing of the outer k/v.
    
    Both call sites keep their explicit make(), so a nil source map still
    yields an empty non-nil map.
    
    Co-Authored-By: default avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    629b8f92
  • Axel von Bertoldi's avatar
    Range over SplitSeq instead of Split · 64c32f04
    Axel von Bertoldi authored
    Fixes the modernize `stringsseq` check. strings.SplitSeq and
    bytes.SplitSeq yield an iterator rather than allocating a slice of all
    parts up front.
    
    In phrasestream_test.go the call is folded into the range clause, since
    the intermediate `parts` variable now holds an iterator rather than the
    slice its name suggests.
    
    Co-Authored-By: default avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    64c32f04
  • Axel von Bertoldi's avatar
    Range over int for counting loops · bb4e7e95
    Axel von Bertoldi authored
    Fixes the modernize `rangeint` check. Loops whose counter is never read
    become `for range n`; the rest become `for i := range n`.
    
    Co-Authored-By: default avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    bb4e7e95
  • Axel von Bertoldi's avatar
    Use slices.Backward for reverse iteration in Environment · 3dec9e54
    Axel von Bertoldi authored
    Fixes the modernize `slicesbackward` check.
    
    ValueOf's outer loop is converted to a plain range in the same commit:
    the index was only used to reach envs[i].mutations, and the inner
    slices.Backward rewrite depends on having the element in hand.
    
    Lock ordering in readLockEnvChain is unchanged -- slices.Backward walks
    deepest to shallowest exactly as the index loop did, and releaseLocks
    still walks forward.
    
    Co-Authored-By: default avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    3dec9e54
  • Axel von Bertoldi's avatar
    Make client.Ptr an inlinable wrapper around new(expr) · 1ef90f8e
    Axel von Bertoldi authored
    Fixes the modernize `newexpr` check. Go 1.26 allows new() to take an
    expression, which lets the compiler inline the wrapper; go.mod already
    requires 1.26.0.
    
    The //go:fix inline directive the linter suggests alongside this is
    deliberately omitted -- it would have gopls/go fix rewrite every
    client.Ptr call site to new(), which is a larger change than intended
    for an exported helper.
    
    Co-Authored-By: default avatarClaude Opus 5 (1M context) <noreply@anthropic.com>
    1ef90f8e
  • Axel von Bertoldi's avatar
    Merge branch 'avonbertoldi/modernize-linter' into 'main' · 94b4c429
    Axel von Bertoldi authored
    chore(lint): enable modernize linter and fix its findings
    
    See merge request !558
    94b4c429
  • Cameron Swords's avatar
    Register default builtins after applying container options · 70051f7c
    Cameron Swords authored
    They were registered before the options loop, relying on a caller's
    WithBuiltinFunc for the same name to overwrite the map entry. Filling in only
    unclaimed names afterwards gives the same precedence without depending on the
    order of the two writes, and leaves a single place to skip them from.
    
    Adds the coverage that pinned neither behaviour before.
    70051f7c
  • Cameron Swords's avatar
    Add resource.WithInProcessOnly to accept only builtin references · 18038852
    Cameron Swords authored
    An embedder hosting the runner in a long-lived process wants the orchestration
    engine and nothing that reaches the network or the filesystem. Under this
    option a step names a registered builtin or it is rejected.
    
    An allowlist of one rather than a list of rejections, so a protocol added later
    is rejected until someone declares it safe.
    18038852
  • Cameron Swords's avatar
    Add function.WithInProcessOnly to reject exec functions · 8149a257
    Cameron Swords authored
    An exec function spawns a subprocess, which is the one function type that
    leaves the process. Nested and builtin functions are untouched, so composition
    still works.
    8149a257
  • Cameron Swords's avatar
    Add step files that refuse to materialize · e103ebc2
    Cameron Swords authored
    Path is the only thing that puts a step file on disk, reached through an
    output_file or export_file expression. A disabled step file errors there
    instead, closing the last write path the container cannot reach.
    
    The knob lives on GlobalContext rather than the container because the embedder
    constructs it, and because every child StepsContext is built from the same one.
    e103ebc2
  • Cameron Swords's avatar
    Add di.WithInProcessOnly · 4e667fbf
    Cameron Swords authored
    Ties together the pieces the container owns: no shipped builtins, only builtin
    references, no exec functions. Embedders register what they want with the
    existing WithBuiltinFunc.
    
    Skipping the git fetcher also removes the container's only eager side effect,
    the git cache dir. GitFetcher and CacheDir now fail rather than quietly handing
    back something that would create it.
    4e667fbf
  • Cameron Swords's avatar
    Cover in-process execution end to end · aca2df08
    Cameron Swords authored
    Pins the guarantee the mode exists for: a job of registered builtins leaves an
    overridden TMPDIR completely empty, no files and no directories, while outputs
    and exports still flow between steps.
    
    The second test pins the failure side, so each rejection keeps naming the mode
    rather than degrading into a generic unsupported-reference error.
    aca2df08
  • Cameron Swords's avatar
    Document in-process execution · ea239857
    Cameron Swords authored
    ea239857
  • Cameron Swords's avatar
    Gate in-process function types with an allowlist · c606e65e
    Cameron Swords authored
    The reference gate in resource.Parser.Parse enumerates what is permitted, so a
    protocol added later is rejected until someone declares it safe. This gate was
    the opposite, a denylist of one: only exec was refused, and any definition type
    added to parseStepType afterwards would be allowed by default.
    
    Hoisting the check above the switch makes both gates fail the same way.
    DescribeType returns the proto enum name, so exec still reports the identical
    message and the integration test asserting it passes unchanged.
    c606e65e
  • Cameron Swords's avatar
    Move errInProcessOnly beside its first user · 053d77e1
    Cameron Swords authored
    Declaring it above type Container detached the DI explanation block from the
    type, so godoc attributed the whole thing to an unexported error variable and
    left Container undocumented.
    
    The message also named the wrong thing at both call sites, neither of which is
    a step source. Reducing it to "disabled: ..." lets the caller's prefix name
    what was refused, matching how the parser and step file errors read.
    053d77e1
  • Cameron Swords's avatar
    Record why the OCI accessors are ungated · 67bcc3f2
    Cameron Swords authored
    GitFetcher and CacheDir fail in this mode but OCIClient, RemoteImageStore and
    CachedImageStore still hand back working objects. That is not a live hole,
    since ResourceParser short-circuits before it reaches them and all three
    constructors only join paths, but the omission reads as an oversight in a
    surface the mode describes as a boundary.
    67bcc3f2
  • Cameron Swords's avatar
    Enforce the nil-dependency contract in resource.NewParser · 5d200f07
    Cameron Swords authored
    The comment sanctioned nil dependencies under WithInProcessOnly but nothing
    enforced the pairing, so NewParser(nil, finder, nil) without the option
    compiled and deferred the failure to a nil dereference inside NewGit or NewOCI
    once a reference was loaded.
    
    The guard compares typed pointers rather than going through
    precond.MustNotBeNil, which takes an any: a nil *git.GitFetcher boxed into an
    interface is not == nil, so that helper would never fire here.
    
    TestParser_Parse_ExecAllowedByDefault built exactly the unguarded parser, so it
    now opts its resource parser into the mode. The function parser under test is
    deliberately left unrestricted.
    5d200f07
  • Cameron Swords's avatar
    Override the temp dir on Windows too · c08106f5
    Cameron Swords authored
    TMPDIR only reaches os.TempDir on Unix; Windows consults TMP, then TEMP. The
    require.Equal guard on the next line would fail the test outright rather than
    skip it.
    c08106f5
  • Cameron Swords's avatar
    Pin shippedBuiltins to defaultBuiltins · bb31c6b7
    Cameron Swords authored
    Writing the list out by hand is what makes it worth asserting against, but the
    cost lands on the neighbouring subtest: a seventh default builtin would
    otherwise slip past "in-process mode registers no builtins", which is the
    assertion the boundary rests on.
    bb31c6b7
  • Cameron Swords's avatar
    Move in_process_test.go to package integration_test · d61c393e
    Cameron Swords authored
    16 of the 20 files in this directory already use the external test package and
    nothing here needs unexported identifiers.
    d61c393e
  • Cameron Swords's avatar
    Merge branch 'cam/in-memory-only-mode' into 'main' · 53c2260c
    Cameron Swords authored
    Add in-process execution mode for embedders
    
    Closes gitlab-org/ci-cd/runner-tools/argo-rollout#22
    
    See merge request !561
    53c2260c
Loading
Loading