Skip to content

Add actions to provider interface #37006

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Add actions to provider interface #37006

wants to merge 2 commits into from

Conversation

DanielMSchmidt
Copy link
Contributor

This PR adds actions to the provider interface and implements the basic functionality against the provider protocol.

Fixes #

Target Release

1.13.x

CHANGELOG entry

  • This change is user-facing and I added a changelog entry.
  • This change is not user-facing.

Copy link

@SBGoods SBGoods left a comment

Choose a reason for hiding this comment

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

Approving the protocol changes

@ansgarm
Copy link
Member

ansgarm commented May 21, 2025

Will the version of the protocol version stay at 6.10?

}
}


Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick: extra newline

Copy link
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

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

I left a couple of questions and comments - I won't make a fuss about the nitpicks (like newlines) so feel free to fix or ignore those as you will. Overall this looks reasonable to me!

@@ -875,3 +932,80 @@ message ConfigureStateStore {
repeated Diagnostic diagnostics = 1;
}
}


Copy link
Contributor

Choose a reason for hiding this comment

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

extra newlines

}
}


Copy link
Contributor

Choose a reason for hiding this comment

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

(2) extra newlines

linkedResouceSchemas := actionSchema.LinkedResources()
inputLinkedResources := make([]providers.LinkedResourcePlanData, 0, len(req.LinkedResources))

for i, lr := range req.LinkedResources {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add some comments (here or in top-level method comments) that explain why we aren't sending the planned_state to the provider, when we do for the protocol v5 version? I remember seeing you and James chat about it and I think it would help if that was captured somewhere here


priorState, err := decodeDynamicValue6(lr.PriorState, linkedResourceTy)
if err != nil {
return nil, fmt.Errorf("failed to decode prior state for linked resource #%d (%q) in action %q: %w", i+1, linkedResouceSchemas[i].TypeName, req.ActionType, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is i+1 the correct thing to show the user here? I thought terraform generally always used [0] for the first item in a list and it seems like it'd be odd if we switched that just for actions (I could also be wrong about that given this context!)

return resp
}

func (p *GRPCProvider) InvokeAction(r providers.InvokeActionRequest) (resp providers.InvokeActionResponse) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This one is just a genuine question I'm curious about, not a review:

How will the action event stream get cancelled from the terraform side (ie user ctrl-c or a timeout)? Does that get handled by the provider when tf calls Stop()?

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: BUSL-1.1

package mock_tfplugin5
Copy link
Contributor

Choose a reason for hiding this comment

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

mock.go is generated, is there a reason these methods can't also be generated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog-needed Add this to your PR if the change does not require a changelog entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants