-
Notifications
You must be signed in to change notification settings - Fork 965
Add support for hidden field to project variables #2065
Add support for hidden field to project variables #2065
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yogeshlonkar thanks for the contribution 🤝 I've left some clarification questions on the correctness of the field / field naming. Back to you 🏓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and tested this against a locally running GitLab with the 2 suggested changes, and the tests pass. If you'd please make those changes, I'm good to merge.
Here is the test I used to test the above 2 suggestions: func TestProjectVariablesService_MaskAndHidden_RealGitLab(t *testing.T) {
client, err := NewClient("<token>",
WithBaseURL("http://localhost:8085"),
)
if err != nil {
t.Fatalf("Failed to create client: %v", err)
}
// create a project
project, _, err := client.Projects.CreateProject(&CreateProjectOptions{
Name: Ptr(fmt.Sprintf("test-%d", time.Now().UnixMicro())),
})
if err != nil {
t.Fatalf("Failed to create project: %v", err)
}
projectVar, _, err := client.ProjectVariables.CreateVariable(project.ID, &CreateProjectVariableOptions{
Key: Ptr("test"),
Value: Ptr("testtesttest"), // must have a min of 8 characters
MaskedAndHidden: Ptr(true),
})
if err != nil {
t.Fatalf("Failed to create project variable: %v", err)
}
assert.True(t, projectVar.Hidden)
} |
GitLab has inconsistent naming of the filed for hidden variables. It seems for keeping UI consistant, GitLab chose to introduce different naming for the same field. This could have been easy handled in UI by setting two variables on API request instead of introducing combined field for UI. I have added 2 test cases for create and update project API as per the gitlab.com API that I manually tested and added similar unit tests.
@RicePatrick @timofurrer can you please review PR again |
Updated code looks good; merging so it's available for the migration tomorrow :) |
Changes made as part of further commits
GitLab has inconsistent naming of the filed for hidden variables.
It seems for keeping UI consistant, GitLab chose to introduce different
naming for the same field. This could have been easy handled in UI by
setting two variables on API request instead of introducing combined
field for UI.
I have added 2 test cases for create and update project API as per the
gitlab.com API that I manually tested and added similar unit tests.