Skip to content

Commit 5521b47

Browse files
authored
Merge branch 'main' into jillirami/IPL-9014-tfe-registry-module-support-any-display-identifier
2 parents bbbe4da + 02472c6 commit 5521b47

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
## Enhancements
44
* Adds `Name` and `Provider` fields to `RegistryModuleCreateWithVCSConnectionOptions` to support explicit module naming for monorepos with non-standard repository names, by @jillirami [#1277](https://github.com/hashicorp/go-tfe/pull/1277)
55

6+
# v1.100.0
7+
8+
## Enhancements
9+
* 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)
10+
611
# v1.99.0
712

813
## Enhancements

mocks/run_trigger_mocks.go

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

run_trigger.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ type RunTriggers interface {
2828
// Read a run trigger by its ID.
2929
Read(ctx context.Context, RunTriggerID string) (*RunTrigger, error)
3030

31+
// ReadWithOptions reads a run trigger by its ID using the options supplied
32+
ReadWithOptions(ctx context.Context, runID string, options *RunTriggerReadOptions) (*RunTrigger, error)
33+
3134
// Delete a run trigger by its ID.
3235
Delete(ctx context.Context, RunTriggerID string) error
3336
}
@@ -100,6 +103,11 @@ type RunTriggerCreateOptions struct {
100103
Sourceable *Workspace `jsonapi:"relation,sourceable"`
101104
}
102105

106+
// RunTriggerCreateOptions represents the options for reading a run.
107+
type RunTriggerReadOptions struct {
108+
Include []RunTriggerIncludeOpt `url:"include,omitempty"` // optional`
109+
}
110+
103111
// List all the run triggers associated with a workspace.
104112
func (s *runTriggers) List(ctx context.Context, workspaceID string, options *RunTriggerListOptions) (*RunTriggerList, error) {
105113
if !validStringID(&workspaceID) {
@@ -156,12 +164,17 @@ func (s *runTriggers) Create(ctx context.Context, workspaceID string, options Ru
156164

157165
// Read a run trigger by its ID.
158166
func (s *runTriggers) Read(ctx context.Context, runTriggerID string) (*RunTrigger, error) {
167+
return s.ReadWithOptions(ctx, runTriggerID, nil)
168+
}
169+
170+
// Read a run trigger by its ID.
171+
func (s *runTriggers) ReadWithOptions(ctx context.Context, runTriggerID string, options *RunTriggerReadOptions) (*RunTrigger, error) {
159172
if !validStringID(&runTriggerID) {
160173
return nil, ErrInvalidRunTriggerID
161174
}
162175

163176
u := fmt.Sprintf("run-triggers/%s", url.PathEscape(runTriggerID))
164-
req, err := s.client.NewRequest("GET", u, nil)
177+
req, err := s.client.NewRequest("GET", u, options)
165178
if err != nil {
166179
return nil, err
167180
}

run_trigger_integration_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,35 @@ func TestRunTriggerRead(t *testing.T) {
233233
})
234234
}
235235

236+
func TestRunTriggerReadWithOptions(t *testing.T) {
237+
client := testClient(t)
238+
ctx := context.Background()
239+
240+
orgTest, orgTestCleanup := createOrganization(t, client)
241+
defer orgTestCleanup()
242+
243+
wTest, wTestCleanup := createWorkspace(t, client, orgTest)
244+
defer wTestCleanup()
245+
246+
sourceableTest, sourceableTestCleanup := createWorkspace(t, client, orgTest)
247+
defer sourceableTestCleanup()
248+
249+
rtTest, rtTestCleanup := createRunTrigger(t, client, wTest, sourceableTest)
250+
defer rtTestCleanup()
251+
252+
t.Run("with include options", func(t *testing.T) {
253+
rt, err := client.RunTriggers.ReadWithOptions(ctx, rtTest.ID, &RunTriggerReadOptions{
254+
Include: []RunTriggerIncludeOpt{RunTriggerSourceable, RunTriggerWorkspace},
255+
})
256+
require.NoError(t, err)
257+
assert.Equal(t, rtTest.ID, rt.ID)
258+
require.NotNil(t, rt.Sourceable)
259+
assert.Equal(t, sourceableTest.ID, rt.Sourceable.ID)
260+
require.NotNil(t, rt.Workspace)
261+
assert.Equal(t, wTest.ID, rt.Workspace.ID)
262+
})
263+
}
264+
236265
func TestRunTriggerDelete(t *testing.T) {
237266
t.Parallel()
238267
client := testClient(t)

0 commit comments

Comments
 (0)