Skip to content

Add support for setting enterprise properties#3292

Open
jackmtpt wants to merge 5 commits intointegrations:mainfrom
jackmtpt:enterprise-props
Open

Add support for setting enterprise properties#3292
jackmtpt wants to merge 5 commits intointegrations:mainfrom
jackmtpt:enterprise-props

Conversation

@jackmtpt
Copy link
Copy Markdown

@jackmtpt jackmtpt commented Mar 19, 2026

Resolves #3230

I've basically copied the existing org resource/data source and adjusted it for the enterprise API calls. The tests pass for me and I can see the properties appear briefly in my enterprise while the tests are running.


Before the change?

  • Enterprise custom properties are not supported.

After the change?

  • They now are.

Pull request checklist

  • [] Schema migrations have been created if needed (example)
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes / features)

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

@github-actions
Copy link
Copy Markdown

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@jackmtpt jackmtpt marked this pull request as ready for review March 19, 2026 16:48
@jackmtpt
Copy link
Copy Markdown
Author

I'm quite new to this so I'm not really sure how I can get a build and hook up my actual terraform code to use it - do the CI builds of providers in this repo get published to the registry so they can be used for testing?

Copy link
Copy Markdown
Collaborator

@deiga deiga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review


func dataSourceGithubEnterpriseCustomProperties() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceGithubEnterpriseCustomPropertiesRead,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add top-level Description field

Comment on lines +23 to +51
"value_type": {
Type: schema.TypeString,
Optional: true,
},
"required": {
Type: schema.TypeBool,
Optional: true,
},
"default_value": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"description": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
"allowed_values": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"values_editable_by": {
Type: schema.TypeString,
Optional: true,
Computed: true,
},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of these should be Optional as you don't use them in the data fetching

return diag.Errorf("error querying GitHub custom properties %s: %v", entSlug, err)
}

// TODO: Add support for other types of default values
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't submit PRs with missing implementation


func TestAccGithubEnterpriseCustomPropertiesDataSource(t *testing.T) {
randomID := acctest.RandStringFromCharSet(5, acctest.CharSetAlpha)
propertyName := fmt.Sprintf("test-%s", randomID)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use testResourcePrefix

testAccConf.enterpriseSlug,
)

check := resource.ComposeTestCheckFunc(
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't use a variable

"enterprise_slug": {
Type: schema.TypeString,
Required: true,
Description: "The slug of the enterprise to which the custom property belongs",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have ForceNew as well

Description: "The description of the custom property",
Type: schema.TypeString,
Optional: true,
Computed: true,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would this be computed? I doubt the API has a default value for this field

}

d.SetId(*customProperty.PropertyName)
return resourceGithubEnterpriseCustomPropertiesRead(d, meta)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never call any of the CRUD functions

Comment on lines +133 to +139
_ = d.Set("allowed_values", customProperty.AllowedValues)
_ = d.Set("default_value", defaultValue)
_ = d.Set("description", customProperty.Description)
_ = d.Set("property_name", customProperty.PropertyName)
_ = d.Set("required", customProperty.Required)
_ = d.Set("value_type", string(customProperty.ValueType))
_ = d.Set("values_editable_by", customProperty.ValuesEditableBy)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't swallow errors


_, err := client.Enterprise.RemoveCustomProperty(context.Background(), entSlug, d.Get("property_name").(string))
if err != nil {
return err
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add 404 handling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: Add support for defining custom properties for an enterprise

3 participants