fix: image credentials for services must not override container image credentials #181

Merged
earl-warren merged 3 commits from earl-warren/act:wip-credentials into main 2025-07-15 20:55:38 +00:00
Contributor
  • do not override username and password when looping over services
  • split prepareJobContainer out of startJobContainer
  • split getNetworkName out as it is used by both
  • add unit tests for prepareJobContainer
  • make containre.NewContainer mockable
  • add MockVariable helper

Closes forgejo/runner#575


Note to reviewers: do not show whitespace change, the refactor will show in a minimal way. When the fix is reverted the tests fail as follows:

        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -81,4 +81,4 @@
        	            	   Image: (string) (len=10) "some:image",
        	            	-  Username: (string) (len=17) "containerusername",
        	            	-  Password: (string) (len=17) "containerpassword",
        	            	+  Username: (string) (len=16) "service2username",
        	            	+  Password: (string) (len=16) "service2password",
        	            	   Entrypoint: ([]string) (len=3) {
        	Test:       	TestStartJobContainer/Overlapping
- do not override username and password when looping over services - split prepareJobContainer out of startJobContainer - split getNetworkName out as it is used by both - add unit tests for prepareJobContainer - make containre.NewContainer mockable - add MockVariable helper Closes forgejo/runner#575 --- Note to reviewers: do not show whitespace change, the refactor will show in a minimal way. When the fix is reverted the tests fail as follows: ``` Diff: --- Expected +++ Actual @@ -81,4 +81,4 @@ Image: (string) (len=10) "some:image", - Username: (string) (len=17) "containerusername", - Password: (string) (len=17) "containerpassword", + Username: (string) (len=16) "service2username", + Password: (string) (len=16) "service2password", Entrypoint: ([]string) (len=3) { Test: TestStartJobContainer/Overlapping ```
fix: image credentials for services must not override container image credentials
All checks were successful
checks / unit (pull_request) Successful in 1m57s
checks / integration (pull_request) Successful in 1m9s
/ cascade (pull_request_target) Successful in 33m30s
544c7e58f8
Closes forgejo/runner#575
Author
Contributor

Now to the hard part... testing.

Now to the hard part... testing.
Contributor

cascading-pr updated at forgejo/runner#700

cascading-pr updated at https://code.forgejo.org/forgejo/runner/pulls/700
earl-warren changed title from WIP: fix: image credentials for services must not override container image credentials to WIP: fix: image credentials for services must not override container image credentials [skip cascade] 2025-07-15 18:21:42 +00:00
earl-warren force-pushed wip-credentials from 352508b798
Some checks failed
/ cascade (pull_request_target) Has been skipped
checks / unit (pull_request) Failing after 37s
checks / integration (pull_request) Has been skipped
to a82bc9ebbe
All checks were successful
/ cascade (pull_request_target) Has been skipped
checks / unit (pull_request) Successful in 1m17s
checks / integration (pull_request) Successful in 1m8s
2025-07-15 18:30:22 +00:00
Compare
Author
Contributor

It was difficult in the sense that there was nothing to get inspiration from. But in the end it is not so bad. Continuations and closures inspired from JavaScript could have made it almost impossible. But the state passed along in the chain of Executor is stored in structs that can be examined by tests. Some would argue this is not how functional programming should work but that serves the purpose of adding tests after the fact so there is no reason to complain.

It was difficult in the sense that there was nothing to get inspiration from. But in the end it is not so bad. Continuations and closures inspired from JavaScript could have made it almost impossible. But the state passed along in the chain of Executor is stored in structs that can be examined by tests. Some would argue this is not how functional programming should work but that serves the purpose of adding tests after the fact so there is no reason to complain.
earl-warren changed title from WIP: fix: image credentials for services must not override container image credentials [skip cascade] to fix: image credentials for services must not override container image credentials [skip cascade] 2025-07-15 18:37:23 +00:00
earl-warren changed title from fix: image credentials for services must not override container image credentials [skip cascade] to fix: image credentials for services must not override container image credentials 2025-07-15 18:37:46 +00:00
earl-warren changed title from fix: image credentials for services must not override container image credentials to fix: image credentials for services must not override container image credentials [skip cascade] 2025-07-15 18:38:41 +00:00
earl-warren force-pushed wip-credentials from a82bc9ebbe
All checks were successful
/ cascade (pull_request_target) Has been skipped
checks / unit (pull_request) Successful in 1m17s
checks / integration (pull_request) Successful in 1m8s
to 4a56a5247b
Some checks failed
checks / unit (pull_request) Successful in 1m19s
checks / integration (pull_request) Successful in 1m30s
/ cascade (pull_request_target) Failing after 34s
2025-07-15 18:39:48 +00:00
Compare
viceice approved these changes 2025-07-15 18:50:36 +00:00
viceice left a comment
Owner

LGTM

LGTM
earl-warren changed title from fix: image credentials for services must not override container image credentials [skip cascade] to fix: image credentials for services must not override container image credentials 2025-07-15 20:24:33 +00:00
earl-warren deleted branch wip-credentials 2025-07-15 20:55:38 +00:00
Commenting is not possible because the repository is archived.
No reviewers
No milestone
No project
No assignees
3 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
forgejo/act!181
No description provided.