-
-
Notifications
You must be signed in to change notification settings - Fork 98
fix: correct decoding logic for GitLab clientSpec to allow overwriting #5811
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@hebestreit I tried your example both with your code and the latest Updatecli version and in both cases I have the same result running
|
@olblak do you mean that you were not able to reproduce it? I don't know if the output of the name: TEST.YAML
pipelineid: 223989165bed2b42fd29f4aca958d868c934ef019a0656abed5ed4fb7c7c4f46
actions:
default:
title: my-title
kind: gitlab/mergerequest
spec:
removesourcebranch: true
# spec:
# token: gplat-mr-token
# username: mr
scmid: gitlab
scms:
gitlab:
kind: gitlab
spec:
owner: owner
repository: my-group/my-repository
token: xxx
username: gitlab-ci-token
disabled: false I was mainly checking the value inside the debugger where the // mapstructure.Decode cannot handle embedded fields
// hence we decode it in two steps
err := mapstructure.Decode(spec, &clientSpec)
if err != nil {
return Gitlab{}, err
}
err = mapstructure.Decode(spec, &s)
if err != nil {
return Gitlab{}, nil
}
if scm != nil {
if len(clientSpec.Token) == 0 && len(scm.Spec.Token) > 0 {
clientSpec.Token = scm.Spec.Token
}
// ... After changing the order and referencing to |
Well, it was a combination of multiple issues here The Gitlab action spec has an embedded struct for the client configuration. In the file By the way this current issue also highlighted that I need to migrate from Then within the gitlab mergerequest I was decoding the wrong empty object... |
For simplicity, I am also adding the fix for the other action Gitea/Bitbucket/Stash in this PR |
In this PR I switched the order of decoding to reference the
clientSpec
to the action's sub spec when decoding.I was trying to overwrite the username and token inside the GitLab Merge Request action's spec using below config but it was not passed to the
clientSpec
correctly. That's why the scm credentials were used instead.Test
To test this pull request, you can run the following commands:
Additional Information
Checklist
Tradeoff
Potential improvement