mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-06 17:40:58 +00:00
container credentials (#868)
* Chore: add a snapshot target * Update: support credentials for private containers Resolves: #788 * fix: rework container credentials Signed-off-by: hackercat <me@hackerc.at> * fix: check if Credentials are not nil * fix: return on missing credentials key Co-authored-by: hackercat <me@hackerc.at> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
3a14671ab0
commit
d2ef16b698
3 changed files with 81 additions and 11 deletions
|
@ -99,6 +99,36 @@ jobs:
|
|||
assert.Contains(t, workflow.Jobs["test2"].Container().Env["foo"], "bar")
|
||||
}
|
||||
|
||||
func TestReadWorkflow_ObjectContainer(t *testing.T) {
|
||||
yaml := `
|
||||
name: local-action-docker-url
|
||||
|
||||
jobs:
|
||||
test:
|
||||
container:
|
||||
image: r.example.org/something:latest
|
||||
credentials:
|
||||
username: registry-username
|
||||
password: registry-password
|
||||
env:
|
||||
HOME: /home/user
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: ./actions/docker-url
|
||||
`
|
||||
|
||||
workflow, err := ReadWorkflow(strings.NewReader(yaml))
|
||||
assert.NoError(t, err, "read workflow should succeed")
|
||||
assert.Len(t, workflow.Jobs, 1)
|
||||
|
||||
container := workflow.GetJob("test").Container()
|
||||
|
||||
assert.Contains(t, container.Image, "r.example.org/something:latest")
|
||||
assert.Contains(t, container.Env["HOME"], "/home/user")
|
||||
assert.Contains(t, container.Credentials["username"], "registry-username")
|
||||
assert.Contains(t, container.Credentials["password"], "registry-password")
|
||||
}
|
||||
|
||||
func TestReadWorkflow_StepsTypes(t *testing.T) {
|
||||
yaml := `
|
||||
name: invalid step definition
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue