Skip to content

Commit 51bedeb

Browse files
authored
feat: Add missing values_editable_by field for organization custom properties (#3164)
1 parent 87c3716 commit 51bedeb

File tree

4 files changed

+64
-32
lines changed

4 files changed

+64
-32
lines changed

github/github-accessors.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/github-accessors_test.go

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

github/orgs_properties.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,19 @@ type CustomProperty struct {
1515
// PropertyName is required for most endpoints except when calling CreateOrUpdateCustomProperty;
1616
// where this is sent in the path and thus can be omitted.
1717
PropertyName *string `json:"property_name,omitempty"`
18-
// Possible values for ValueType are: string, single_select
19-
ValueType string `json:"value_type"`
20-
Required *bool `json:"required,omitempty"`
21-
DefaultValue *string `json:"default_value,omitempty"`
22-
Description *string `json:"description,omitempty"`
18+
// The type of the value for the property. Can be one of: string, single_select.
19+
ValueType string `json:"value_type"`
20+
// Whether the property is required.
21+
Required *bool `json:"required,omitempty"`
22+
// Default value of the property.
23+
DefaultValue *string `json:"default_value,omitempty"`
24+
// Short description of the property.
25+
Description *string `json:"description,omitempty"`
26+
// An ordered list of the allowed values of the property. The property can have up to 200
27+
// allowed values.
2328
AllowedValues []string `json:"allowed_values,omitempty"`
29+
// Who can edit the values of the property. Can be one of: org_actors, org_and_repo_actors, nil (null).
30+
ValuesEditableBy *string `json:"values_editable_by,omitempty"`
2431
}
2532

2633
// RepoCustomPropertyValue represents a repository custom property value.

github/orgs_properties_test.go

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) {
3030
"allowed_values":[
3131
"production",
3232
"development"
33-
]
33+
],
34+
"values_editable_by": "org_actors"
3435
},
3536
{
3637
"property_name": "service",
@@ -52,12 +53,13 @@ func TestOrganizationsService_GetAllCustomProperties(t *testing.T) {
5253

5354
want := []*CustomProperty{
5455
{
55-
PropertyName: String("name"),
56-
ValueType: "single_select",
57-
Required: Bool(true),
58-
DefaultValue: String("production"),
59-
Description: String("Prod or dev environment"),
60-
AllowedValues: []string{"production", "development"},
56+
PropertyName: String("name"),
57+
ValueType: "single_select",
58+
Required: Bool(true),
59+
DefaultValue: String("production"),
60+
Description: String("Prod or dev environment"),
61+
AllowedValues: []string{"production", "development"},
62+
ValuesEditableBy: String("org_actors"),
6163
},
6264
{
6365
PropertyName: String("service"),
@@ -162,7 +164,8 @@ func TestOrganizationsService_GetCustomProperty(t *testing.T) {
162164
"allowed_values":[
163165
"production",
164166
"development"
165-
]
167+
],
168+
"values_editable_by": "org_actors"
166169
}`)
167170
})
168171

@@ -173,12 +176,13 @@ func TestOrganizationsService_GetCustomProperty(t *testing.T) {
173176
}
174177

175178
want := &CustomProperty{
176-
PropertyName: String("name"),
177-
ValueType: "single_select",
178-
Required: Bool(true),
179-
DefaultValue: String("production"),
180-
Description: String("Prod or dev environment"),
181-
AllowedValues: []string{"production", "development"},
179+
PropertyName: String("name"),
180+
ValueType: "single_select",
181+
Required: Bool(true),
182+
DefaultValue: String("production"),
183+
Description: String("Prod or dev environment"),
184+
AllowedValues: []string{"production", "development"},
185+
ValuesEditableBy: String("org_actors"),
182186
}
183187
if !cmp.Equal(property, want) {
184188
t.Errorf("Organizations.GetCustomProperty returned %+v, want %+v", property, want)
@@ -210,29 +214,32 @@ func TestOrganizationsService_CreateOrUpdateCustomProperty(t *testing.T) {
210214
"allowed_values":[
211215
"production",
212216
"development"
213-
]
217+
],
218+
"values_editable_by": "org_actors"
214219
}`)
215220
})
216221

217222
ctx := context.Background()
218223
property, _, err := client.Organizations.CreateOrUpdateCustomProperty(ctx, "o", "name", &CustomProperty{
219-
ValueType: "single_select",
220-
Required: Bool(true),
221-
DefaultValue: String("production"),
222-
Description: String("Prod or dev environment"),
223-
AllowedValues: []string{"production", "development"},
224+
ValueType: "single_select",
225+
Required: Bool(true),
226+
DefaultValue: String("production"),
227+
Description: String("Prod or dev environment"),
228+
AllowedValues: []string{"production", "development"},
229+
ValuesEditableBy: String("org_actors"),
224230
})
225231
if err != nil {
226232
t.Errorf("Organizations.CreateOrUpdateCustomProperty returned error: %v", err)
227233
}
228234

229235
want := &CustomProperty{
230-
PropertyName: String("name"),
231-
ValueType: "single_select",
232-
Required: Bool(true),
233-
DefaultValue: String("production"),
234-
Description: String("Prod or dev environment"),
235-
AllowedValues: []string{"production", "development"},
236+
PropertyName: String("name"),
237+
ValueType: "single_select",
238+
Required: Bool(true),
239+
DefaultValue: String("production"),
240+
Description: String("Prod or dev environment"),
241+
AllowedValues: []string{"production", "development"},
242+
ValuesEditableBy: String("org_actors"),
236243
}
237244
if !cmp.Equal(property, want) {
238245
t.Errorf("Organizations.CreateOrUpdateCustomProperty returned %+v, want %+v", property, want)
@@ -280,7 +287,7 @@ func TestOrganizationsService_ListCustomPropertyValues(t *testing.T) {
280287
fmt.Fprint(w, `[{
281288
"repository_id": 1296269,
282289
"repository_name": "Hello-World",
283-
"repository_full_name": "octocat/Hello-World",
290+
"repository_full_name": "octocat/Hello-World",
284291
"properties": [
285292
{
286293
"property_name": "environment",

0 commit comments

Comments
 (0)