Skip to content

Split project data source#119

Open
sarahhodne wants to merge 1 commit into
CircleCI-Public:mainfrom
sarahhodne:sarah/split-project-settings
Open

Split project data source#119
sarahhodne wants to merge 1 commit into
CircleCI-Public:mainfrom
sarahhodne:sarah/split-project-settings

Conversation

@sarahhodne

@sarahhodne sarahhodne commented Jul 9, 2026

Copy link
Copy Markdown

The circleci_project data source currently fetches both project information and project settings, primarily the latter.

Reading project settings requires permission to trigger builds, so it cannot be done by a user with only read-only permissions.

Having a way to look up project information (especially project slug -> project ID mapping) is quite useful, and should be doable with a read-only user.

I went with splitting the project settings out to a separate data source, and keeping circleci_project to just the project information.

This is a breaking change, but since we're still pre-1.0, I think now is a good time to make those changes. Since this is just a data source, fixing the breaking change is also not too complicated, compared to a resource with state that needs to be ported over.

I ran the acceptance tests for these two data sources locally:

=== RUN   TestAccProjectDataSource
2026/07/09 13:55:15 [DEBUG] GET https://circleci.com/api/v2/project/circleci/8e4z1Akd74woxagxnvLT5q/V29Cenkg8EaiSZARmWm8Lz
2026/07/09 13:55:15 [DEBUG] GET https://circleci.com/api/v2/project/circleci/8e4z1Akd74woxagxnvLT5q/V29Cenkg8EaiSZARmWm8Lz
2026/07/09 13:55:16 [DEBUG] GET https://circleci.com/api/v2/project/circleci/8e4z1Akd74woxagxnvLT5q/V29Cenkg8EaiSZARmWm8Lz
--- PASS: TestAccProjectDataSource (1.85s)
=== RUN   TestAccProjectSettingsDataSource
2026/07/09 13:55:16 [DEBUG] GET https://circleci.com/api/v2/project/circleci/8e4z1Akd74woxagxnvLT5q/V29Cenkg8EaiSZARmWm8Lz/settings
2026/07/09 13:55:17 [DEBUG] GET https://circleci.com/api/v2/project/circleci/8e4z1Akd74woxagxnvLT5q/V29Cenkg8EaiSZARmWm8Lz/settings
2026/07/09 13:55:17 [DEBUG] GET https://circleci.com/api/v2/project/circleci/8e4z1Akd74woxagxnvLT5q/V29Cenkg8EaiSZARmWm8Lz/settings
--- PASS: TestAccProjectSettingsDataSource (1.63s)
PASS
ok      terraform-provider-circleci/internal/provider   (cached)

DONE 2 tests in 0.000s

The `circleci_project` data source currently fetches both project information and project settings, primarily the latter.

Reading project settings requires permission to trigger builds, so it cannot be done by a user with only read-only permissions.

Having a way to look up project information (especially project slug -> project ID mapping) is quite useful, and should be doable with a read-only user.

I went with splitting the project settings out to a separate data source, and keeping `circleci_project` to just the project information.

This is a breaking change, but since we're still pre-1.0, I think now is a good time to make those changes. Since this is just a data source, fixing the breaking change is also not too complicated, compared to a resource with state that needs to be ported over.
@sarahhodne sarahhodne marked this pull request as ready for review July 9, 2026 12:57
func (d *ProjectDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
MarkdownDescription: "Fetches information about a CircleCI project and its settings.",
Description: "Fetches information about a CircleCI project.",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Any particular reason why you are setting Description instead of MarkdownDescription? All the other files use MarkdownDescription as far as I can tell

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I based it off the documentation, which states:

At the moment, if the MarkdownDescription property is set it will always be used instead of the Description property. It is possible that a different strategy may be employed in the future to surface descriptions to other tooling in a different format, so we recommend specifying both fields.

So it seems like the "correct" thing to do is to set Description or both MarkdownDescription, but not only MarkdownDescription. Since most of the fields don't use any markdown formatting at all, I went with Description for most of them, and added an additional MarkdownDescription field to the few fields that have a bit of formatting.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

(But I can revert that if you'd like, and maybe pull it into a separate PR and do it for all the various resources and data soruces, I just decided it was a decent opportunity to check that these data sources were following the documented recommendations)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

yeah, reverting it and possibly making a separate PR for updating the field in the resources sounds reasonable to me.

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.

2 participants