Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: run actions don't accept json-api resource request bodies #388

Merged
merged 1 commit into from May 4, 2022

Conversation

brandonc
Copy link
Collaborator

@brandonc brandonc commented May 2, 2022

Description

According to the docs and in practice, the run actions group of endpoints commonly accept a request body with a single "comment" attribute. This isn't a json-api resource document, and it shouldn't be encoded into a "data" → "attributes" nesting.

As far as I know, these are the only request bodies that aren't compliant, and it's not worthwhile to convert these endpoints from actions to resources.

Testing plan

I added an integration test for this in particular, but I also I wrote a simple program to POST a run apply to a service like requestb.in so you can see the request body:

package main

import (
	"context"

	"github.com/hashicorp/go-tfe"
)

func main() {
	client, err := tfe.NewClient(&tfe.Config{
		Address: "https://env12e9eawjlf.x.pipedream.net",
		Token:   "xxx.atlasv1.xxx",
	})

	if err != nil {
		panic(err)
	}

	err = client.Runs.Apply(context.Background(), "run-NjC97hxkfWZ4eHTA", tfe.RunApplyOptions{
		Comment: tfe.String("hello, world"),
	})

	if err != nil {
		panic(err)
	}
}

External links

@brandonc brandonc force-pushed the brandonc/apply_comment branch from 09897de to 5b06ba0 Compare May 3, 2022
Uk1288
Uk1288 approved these changes May 3, 2022
Copy link
Contributor

@Uk1288 Uk1288 left a comment

LGTM 🎉 , tested the run actions (Discard, apply, cancel) locally.

Copy link
Contributor

@sebasslash sebasslash left a comment

The docs are subtle, excellent catch!

@brandonc brandonc merged commit 4fc5745 into main May 4, 2022
4 checks passed
@brandonc brandonc deleted the brandonc/apply_comment branch May 4, 2022
@github-actions
Copy link

github-actions bot commented May 4, 2022

Reminder to the contributor that merged this PR: if your changes have added important functionality or fixed a relevant bug, open a follow-up PR to update CHANGELOG.md with a note on your changes.

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.

None yet

3 participants