From 23623265e858bec43565f514ac2a8eae0f244d71 Mon Sep 17 00:00:00 2001 From: Mark DeCrane Date: Wed, 28 Jan 2026 15:59:15 -0500 Subject: [PATCH 1/3] Add ReadWithOptions function to RunTriggers --- run_trigger.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/run_trigger.go b/run_trigger.go index ab65ea6be..96b4df502 100644 --- a/run_trigger.go +++ b/run_trigger.go @@ -28,6 +28,9 @@ type RunTriggers interface { // Read a run trigger by its ID. Read(ctx context.Context, RunTriggerID string) (*RunTrigger, error) + // ReadWithOptions reads a run trigger by its ID using the options supplied + ReadWithOptions(ctx context.Context, runID string, options *RunTriggerReadOptions) (*RunTrigger, error) + // Delete a run trigger by its ID. Delete(ctx context.Context, RunTriggerID string) error } @@ -100,6 +103,11 @@ type RunTriggerCreateOptions struct { Sourceable *Workspace `jsonapi:"relation,sourceable"` } +// RunTriggerCreateOptions represents the options for reading a run. +type RunTriggerReadOptions struct { + Include []RunTriggerIncludeOpt `url:"include,omitempty"` // optional` +} + // List all the run triggers associated with a workspace. func (s *runTriggers) List(ctx context.Context, workspaceID string, options *RunTriggerListOptions) (*RunTriggerList, error) { if !validStringID(&workspaceID) { @@ -156,12 +164,17 @@ func (s *runTriggers) Create(ctx context.Context, workspaceID string, options Ru // Read a run trigger by its ID. func (s *runTriggers) Read(ctx context.Context, runTriggerID string) (*RunTrigger, error) { + return s.ReadWithOptions(ctx, runTriggerID, nil) +} + +// Read a run trigger by its ID. +func (s *runTriggers) ReadWithOptions(ctx context.Context, runTriggerID string, options *RunTriggerReadOptions) (*RunTrigger, error) { if !validStringID(&runTriggerID) { return nil, ErrInvalidRunTriggerID } u := fmt.Sprintf("run-triggers/%s", url.PathEscape(runTriggerID)) - req, err := s.client.NewRequest("GET", u, nil) + req, err := s.client.NewRequest("GET", u, options) if err != nil { return nil, err } From be1134c1a0ece32cfa039f73a8aae09d5baf522d Mon Sep 17 00:00:00 2001 From: Mark DeCrane Date: Wed, 28 Jan 2026 15:59:24 -0500 Subject: [PATCH 2/3] test --- run_trigger_integration_test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/run_trigger_integration_test.go b/run_trigger_integration_test.go index d2e6c3bc1..ea2111c0c 100644 --- a/run_trigger_integration_test.go +++ b/run_trigger_integration_test.go @@ -230,6 +230,35 @@ func TestRunTriggerRead(t *testing.T) { }) } +func TestRunTriggerReadWithOptions(t *testing.T) { + client := testClient(t) + ctx := context.Background() + + orgTest, orgTestCleanup := createOrganization(t, client) + defer orgTestCleanup() + + wTest, wTestCleanup := createWorkspace(t, client, orgTest) + defer wTestCleanup() + + sourceableTest, sourceableTestCleanup := createWorkspace(t, client, orgTest) + defer sourceableTestCleanup() + + rtTest, rtTestCleanup := createRunTrigger(t, client, wTest, sourceableTest) + defer rtTestCleanup() + + t.Run("with include options", func(t *testing.T) { + rt, err := client.RunTriggers.ReadWithOptions(ctx, rtTest.ID, &RunTriggerReadOptions{ + Include: []RunTriggerIncludeOpt{RunTriggerSourceable, RunTriggerWorkspace}, + }) + require.NoError(t, err) + assert.Equal(t, rtTest.ID, rt.ID) + require.NotNil(t, rt.Sourceable) + assert.Equal(t, sourceableTest.ID, rt.Sourceable.ID) + require.NotNil(t, rt.Workspace) + assert.Equal(t, wTest.ID, rt.Workspace.ID) + }) +} + func TestRunTriggerDelete(t *testing.T) { client := testClient(t) ctx := context.Background() From 1f85aed77b5e80ffc8bc3a6b5003e7063877091a Mon Sep 17 00:00:00 2001 From: Mark DeCrane Date: Wed, 28 Jan 2026 16:01:57 -0500 Subject: [PATCH 3/3] changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34680207d..2a31cc35d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Unreleased ## Enhancements +* Adds `ReadWithOptions` method to `RunTriggers` to support including related resources when reading a run trigger by @Maed223 [#1275](https://github.com/hashicorp/go-tfe/pull/1275) * Adds `UserTokensEnabled` field to `Organization` to support enabling/disabling user tokens for an organization by @JarrettSpiker [#1225](https://github.com/hashicorp/go-tfe/pull/1225) * Adds `DeploymentRunStatus` and `DeploymentStepStatus` types by @Maed223 [#1261](https://github.com/hashicorp/go-tfe/pull/1261)