Commit Graph

55 Commits

Author SHA1 Message Date
Thomas Gummerer f120630fbe hack hack hack 2024-12-19 12:44:25 +01:00
Thomas Gummerer 6256b927d0 WIP 2024-12-18 17:51:48 +01:00
Fraser Waters 878c5fe445
Move GetRequiredPlugins from sdk/go/common to pkg/engine ()
This is only used in pkg and so can be moved out of the sdk package.

I've also simplified it a bit because we only ever called it with
`AllPlugins` so I've removed that parameter and constant, and also
removed the unused project parameter.
2024-12-11 09:58:07 +00:00
Fraser Waters 7ff5c18216
Add GetRequiredPackages to the language host ()
Next part of https://github.com/pulumi/pulumi/issues/17507

This adds a new `GetRequiredPackages` method to the language hosts. This
will replace `GetRequiredPlugins`. This change set adds the method, and
the required handling in the engine without making use of the new
information returned by the package form, and without updating the
language hosts to return that information.

This should continue to work by hitting all the compatibility paths.
I'll follow this change up with updating the conformance tests to check
against this, and fixing the language hosts to return the new package
information.
2024-12-02 20:24:23 +00:00
Will Jones 15184d702e
Add `Handshake` to the provider protocol ()
Fixes https://github.com/pulumi/pulumi/issues/16876

The pulumi provider protocol gRPC always starts by calling CheckConfig
and then Configure. The problem is that CheckConfig accepts a property
bag, which could contain secrets or outputs or resource references, etc.
However, the engine doesn't know if the provider supports these items
(and vice versa) until Configure is called, since Configure is the call
where the engine and the provider agree on which parts of the protocol
they support.

This introduces a Handshake component to the provider protocol that
establishes which version of the protocol the provider and engine
support. This also adds the plugins root and program directories to that
handshake request allowing a provider to know where it was started up
from. This _also_ replaces `Provider.Attach` as the handshake request
includes the engine address to connect to.

Tasting notes:

* Add `Handshake` with request/response to the protocol. `Handshake`
starts as a high watermark for accepts secrets, accepts resources, etc
but includes the plugins root and program directories (if possible), as
well as the engine address. This pretty much replaces the need for
`Attach`.
* Modify `dialPlugin` (where the engine establishes gRPC connections to
plugins) to take a callback that is used to initialise the connection
* For non-provider plugins, pass `testConnection`, which captures the
logic we have today -- call a dummy gRPC method and observed not
implemented error to confirm connection is live
* For provider plugins, pass `handshake`, which sends a `Handshake` and
captures the response
* All providers thus handshake at boot, as opposed to `Configure`, which
a. happens later and b. is asynchronous
* Modify provider implementation to track a `protocol`; move
`acceptSecrets` and company from `configSource` to there
* If `Handshake` is implemented, populate `protocol` on `dialPlugin`. If
not, fallback to populating in `Configure`
* Invariant: `Configure` implies `protocol`
* The rest is largely plumbing
* We can add similar Handshake methods for the other plugin types as
well

---------

Co-authored-by: Fraser Waters <fraser@pulumi.com>
2024-11-26 17:35:47 +00:00
Julien a3cdbad64c
Allow accessing configuration in Python dynamic providers ()
Python dynamic providers get serialised and deserialised, and run in the
`pulumi-python` plugin process. This causes issues when trying to use
`pulumi.config.Config` in a dynamic provider:

* Using `Config` at runtime fails because the process is not setup with
the current configuration
* When the dynamic provider implementation is in the `__main__` module,
the dynamic provider serialization attempts to serialize the global
`SETTINGS` object, which pulls in protobuf definitions, which are not
serializable by `dill`.

To provide a stable API to access configuration in dynamic providers,
the provider classes (ResourceProvider) can now implement a `configure`
method which is called during provider initialization.
```python
class SimpleProvider(ResourceProvider):
    password: str

    def configure(self, req: ConfigureRequest):
        self.password = req.config.get("password")

    def create(self, props):
        # Use `self.password`.
        ...
```

The `configure` method is called when a provider is deserialized. Since
we cache the deserialization result, we guarantee that this is only
called once per program, and this process level cache serves as a plugin
registry.

Fixes https://github.com/pulumi/pulumi/issues/17050

---------

Co-authored-by: Will Jones <will@sacharissa.co.uk>
2024-11-07 10:12:24 +00:00
Will Jones b85a92cd5c
Have `Host.Provider` accept a `PackageDescriptor` ()
Plugins are the core means by which Pulumi may be extended. Language
hosts, resource providers, analyzers, and converters, for instance, are
all kinds of plugin. Plugins are loaded by a plugin `Host`, which also
offers convenience methods for loading specific kinds of plugin such as
those mentioned above.

The `Provider` method on `Host` currently accepts a name and version.
This is not ideal, since there are several other parameters that may
affect the plugin to be loaded, as well as what operations may be run on
it when it is loaded:

* Custom download URLs and checksums may be desirable to control where a
plugin is retrieved from, and to verify a plugin's integrity.
* Parameterization means that while the `aws` provider is desired, it is
actually provided by a dynamically-bridging `terraform` plugin which is
to be supplied with a parameter such as
`{"name":"aws","version":"..."}`.

This PR begins reworking the `Host` interface so that its `Provider`
method accepts a more complete `PackageDescriptor`, consisting of a full
`PluginSpec` and an optional `Parameterization`. Presently this PR just
replicates existing call sites to use the new data structure -- if this
merges successfully then several of these call sites can likely be
cleaned up further by moving duplicated logic that handles things like
custom download URLs, etc. _into_ the newly capable `Provider`
implementation.
2024-09-12 13:17:30 +00:00
Fraser Waters ca1c332274
Lookup language plugin versions by querying the plugin ()
Fixes https://github.com/pulumi/pulumi/issues/17215.

I think every language plugin should respond ok to GetPluginInfo but to
be defensive I've made it a warning if the call fails and we just fall
back the current behavior of not setting the version.

---------

Co-authored-by: Will Jones <will@sacharissa.co.uk>
2024-09-10 21:38:36 +00:00
Fraser Waters 4a1fa7846f
Replace pkg/errors.Wrap with fmt.Errorf ()
Also replace a couple of cases of `errors.Cause` with `errors.Is`.
2024-09-09 11:11:46 +00:00
Thomas Gummerer d51c0bdd87
implement the engine bits for debugging support ()
We want to introduce dubugging support for Pulumi programs. This PR
implements the engine changes necessary for that. Namely, we pass the
information whether we expect a debugger to be started to the language
runtime, and introduce a way for the language runtime plugins to report
to the engine that we're waiting for a debugger to attach. The language
runtime is expected to include the information relevant for the user to
be able to attach to the debugger, as well as a shortened message.

The idea is that the configuration can be picked up by an IDE, and the
debugger can attach automatically. Meanwhile the short message should
contain enough information to be able to attach a debugger manually,
while being short enough to be displayed to the user in the CLI output.
(this will commonly be either the port of the debugger, or the PID of
the process being debugged).

The implementation of the CLI flags and each of the language runtimes
will follow in subsequent PRs.

I tried adding a test to this, but I'm not sure it's possible with our
current testing infrastructure. To do this properly, we'd need to make a
RPC call to the engine, but we don't have that available in the
lifecycletests (? please let me know if I'm missing something). Once
more of the feature is implemented we might be able to implement an
integration test for it. (Not straightforward either, as we'll have to
tell the debugger to continue, but that should be more doable).

Another thing that's not clear to me is that @EronWright mentions this
could be used for MLC/provider debugging as well. However I'm not seeing
how that's going to work, as MLCs/providers are being run as a binary
plugin, which we don't compile from pulumi/pulumi, and thus wouldn't
necessarily even know which debugger to launch it under without a bunch
of additional configuration, that might be better in a shim around the
program (or just keeping the debugging the way we're currently doing,
launching the program and then letting the engine attach to it).

---------

Co-authored-by: Eron Wright <eron@pulumi.com>
Co-authored-by: Julien <julien@caffeine.lu>
2024-08-30 10:31:28 +00:00
Ian Wahbe 78c48204e0
Normalize plugin.Provider methods to (Context, Request) -> (Response, error) ()
Normalize methods on plugin.Provider to the form:

```go
Method(context.Context, MethodRequest) (MethodResponse, error)
```

This provides a more consistent and forwards compatible interface for
each of our methods.

---

I'm motivated to work on this because the bridge maintains a copy of
this interface: `ProviderWithContext`. This doubles the pain of dealing
with any breaking change and this PR would allow me to remove the extra
interface. I'm willing to fix consumers of `plugin.Provider` in
`pulumi/pulumi`, but I wanted to make sure that we would be willing to
merge this PR if I get it green.

<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

Fixes # (issue)

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [ ] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-06-07 19:47:49 +00:00
Germán Lena d7f24dfcfb
Refactor: move plugin kind to apitype ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

This PR moves PluginKind to apitype to prevent circular dependencies
when adding apitype as a dependency of the workspace module.
It also re-exports PluginKind to keep backward compatibility

## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-04-25 17:30:30 +00:00
Fraser Waters e42cfbb349
Ensure project plugins are absolute paths ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

Fixes https://github.com/pulumi/pulumi/issues/15467.

This tightens the restriction on paths passed to `NewProgramInfo`.
Previously it allowed relative paths like "./providers/my_provider".
That is now an error. This is correct behaviour. The fields of this
structure are passed via protobuf and the descriptions for them in the
proto spec are that they should always be absolute paths.

Where we build plugin paths we ensure that if they're relative we
resolve them to what they are relative to. That is generally _not_ the
current working directory so `filepath.Abs` doesn't do the right thing
here.


## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [x] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [x] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-02-22 11:43:18 +00:00
Fraser Waters 721d61115b
Add `plugin run` command ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->

Mostly for providers to experiment with, currently hidden behind
"PULUMI_DEV".
2024-02-05 08:35:48 +00:00
Zaid Ajaj bd4e50efdd
[conformance tests] Fix run root and use program info everywhere ()
# Description

This PR introduces `ProgramInfo` to replace the old `ProgInfo` and
consistently use it where we require plugin, install dependencies and
initialize language runtimes.

## Checklist

- [ ] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [ ] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-25 23:28:58 +00:00
Thomas Gummerer baecc85eaf
turn on the golangci-lint exhaustive linter ()
Turn on the golangci-lint exhaustive linter.  This is the first step
towards catching more missing cases during development rather than
in tests, or in production.

This might be best reviewed commit-by-commit, as the first commit turns
on the linter with the `default-signifies-exhaustive: true` option set,
which requires a lot less changes in the current codebase.

I think it's probably worth doing the second commit as well, as that
will get us the real benefits, even though we end up with a little bit
more churn. However it means all the `switch` statements are covered,
which isn't the case after the first commit, since we do have a lot of
`default` statements that just call `assert.Fail`.
 
Fixes  

## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-17 16:50:41 +00:00
Fraser Waters 941f3d0902
Clean up project usage ()
<!--- 
Thanks so much for your contribution! If this is your first time
contributing, please ensure that you have read the
[CONTRIBUTING](https://github.com/pulumi/pulumi/blob/master/CONTRIBUTING.md)
documentation.
-->

# Description

<!--- Please include a summary of the change and which issue is fixed.
Please also include relevant motivation and context. -->


The project field on `GetProgramDependenciesRequest` and
`GetRequiredPluginsRequest` was marked deprecated at the start of
December. None of the language runtimes are using this, so this cleans
up the engine side code so we don't need to thread a
`*workspace.Project` down to the plugin layer to fill in these fields
anymore.

I haven't fully removed them from the Protobuf structs yet, we probably
could but just to give a little more time for people to get a clear
usage error if still using it.

## Checklist

- [x] I have run `make tidy` to update any new dependencies
- [x] I have run `make lint` to verify my code passes the lint check
  - [x] I have formatted my code using `gofumpt`

<!--- Please provide details if the checkbox below is to be left
unchecked. -->
- [ ] I have added tests that prove my fix is effective or that my
feature works
<!--- 
User-facing changes require a CHANGELOG entry.
-->
- [ ] I have run `make changelog` and committed the
`changelog/pending/<file>` documenting my change
<!--
If the change(s) in this PR is a modification of an existing call to the
Pulumi Cloud,
then the service should honor older versions of the CLI where this
change would not exist.
You must then bump the API version in
/pkg/backend/httpstate/client/api.go, as well as add
it to the service.
-->
- [ ] Yes, there are changes in this PR that warrants bumping the Pulumi
Cloud API version
<!-- @Pulumi employees: If yes, you must submit corresponding changes in
the service repo. -->
2024-01-16 17:06:14 +00:00
Fraser Waters 8cc9fbd81c Lock access to the plugin loading channels
Fixes https://github.com/pulumi/pulumi/issues/12371.

This locks access to the plugin request channels with a RWLock.
Before trying to write to the channel we try to take a Read lock (yes
this sounds the wrong way round, carry on). Many loaders are free to
send to the loadRequest channel at once, but we use the read lock to
atomiclly track if any are currently in progress.

When we go to close the plugin host the first thing we do is take a
Write lock. Firstly this can't be taken until all the read locks are
released indicating that no plugins are currently loading, but secondly
while the write lock is taken no more read locks can be taken blocking
any further plugin loads from starting.

We never release this write lock, thus permenatly blocking plugin loads
once `Close` is called. So that we don't indefinently block inside load
calls we do a `TryRLock` and return an error if the read lock can't be
taken.

With this locking in place the rest of `Close` is then free to shut down
all current plugins and close of the request channels, assured that they
shouldn't be posted to again as the lock stays held.
2023-08-10 23:40:23 +01:00
Fraser Waters a691975202 Warn about ambient plugins loaded from $PATH
By default Pulumi will load ambient plugins from $PATH before looking in
the plugins directory or at bundled plugins.

While this is very useful for development it often causes confusion when
people have forgotten that they have plugins left on $PATH.

This makes the use of these $PATH plugins a diagnostic warning to try
and make that failure mode a little less silent.

Normal users shouldn't ever have plugins on $PATH and so won't see this
new warning.

Re-instates https://github.com/pulumi/pulumi/pull/13607 with a fix for
symlinks included.
2023-08-08 13:11:34 +01:00
Kyle Dixler 86ebe1bbd3 Revert "Warn about ambient plugins loaded from $PATH" 2023-08-04 16:54:16 -07:00
Fraser Waters a5b1590499 Warn about ambient plugins loaded from $PATH
By default Pulumi will load ambient plugins from $PATH before looking in
the plugins directory or at bundled plugins.

While this is very useful for development it often causes confusion when
people have forgotten that they have plugins left on $PATH.

This makes the use of these $PATH plugins a diagnostic warning to try
and make that failure mode a little less silent.

Normal users shouldn't ever have plugins on $PATH and so won't see this
new warning.
2023-07-27 17:59:44 +01:00
Fraser Waters 7ecd8a749c Don't try to install provider during schema loading unless missing
Fixes https://github.com/pulumi/pulumi-terraform-bridge/issues/1247

When running tfgen the provider plugin is generally only available on
PATH, not in the plugins directory. The schema loader was only checking
the plugins directory to decided if it had a resource provider already
installed, and so sent off lots of github requests to lookup latest
versions of plugins while running example conversion.

This changes the schema loader to use the same logic we use elsewhere
where we try to use the provider (which will also look at PATH) and then
if we get a missing plugin error we'll do the install and then try
again.

I've also moved the `SetKnownPluginDownloadURL` call into
workspace.InstallPlugin so we don't forget to call it before passing
specs in.

Finally I've also removed the InstallPlugin method from Host as the only
place it was used was in the schema loader, which is now using
workspace.InstallPlugin like everywhere else.
2023-06-28 14:12:17 +01:00
Fraser Waters 591774afb1 Handle installing plugins without versions in the defaultHost
Maybe fixes https://github.com/pulumi/pulumi-terraform-bridge/issues/1209
Fixes https://github.com/pulumi/pulumi-terraform-bridge/issues/1200

When looking up schemas we would call into `defaultHost.InstallPlugin` to
install any missing plugins, and we would generally _not_ have version
information for that. Unfortunately `defaultHost.InstallPlugin` didn't
handle the case of version not being set, double unfortunately it also
didn't error.

This fixes that install path to call `GetLatestVersion` if version isn't
set.
2023-06-12 12:22:08 +01:00
Fraser Waters b5952e4bfd Pass PULUMI_CONFIG through to provider plugins 2023-04-05 10:17:18 +01:00
Abhinav Gupta 7aa5b77a0c
all: Reformat with gofumpt
Per team discussion, switching to gofumpt.

[gofumpt][1] is an alternative, stricter alternative to gofmt.
It addresses other stylistic concerns that gofmt doesn't yet cover.

  [1]: https://github.com/mvdan/gofumpt

See the full list of [Added rules][2], but it includes:

- Dropping empty lines around function bodies
- Dropping unnecessary variable grouping when there's only one variable
- Ensuring an empty line between multi-line functions
- simplification (`-s` in gofmt) is always enabled
- Ensuring multi-line function signatures end with
  `) {` on a separate line.

  [2]: https://github.com/mvdan/gofumpt#Added-rules

gofumpt is stricter, but there's no lock-in.
All gofumpt output is valid gofmt output,
so if we decide we don't like it, it's easy to switch back
without any code changes.

gofumpt support is built into the tooling we use for development
so this won't change development workflows.

- golangci-lint includes a gofumpt check (enabled in this PR)
- gopls, the LSP for Go, includes a gofumpt option
  (see [installation instrutions][3])

  [3]: https://github.com/mvdan/gofumpt#installation

This change was generated by running:

```bash
gofumpt -w $(rg --files -g '*.go' | rg -v testdata | rg -v compilation_error)
```

The following files were manually tweaked afterwards:

- pkg/cmd/pulumi/stack_change_secrets_provider.go:
  one of the lines overflowed and had comments in an inconvenient place
- pkg/cmd/pulumi/destroy.go:
  `var x T = y` where `T` wasn't necessary
- pkg/cmd/pulumi/policy_new.go:
  long line because of error message
- pkg/backend/snapshot_test.go:
  long line trying to assign three variables in the same assignment

I have included mention of gofumpt in the CONTRIBUTING.md.
2023-03-03 09:00:24 -08:00
Abhinav Gupta 7bddec255d
sdk/go: Prefer contract.Assertf over Assert
Migrates all uses of contract.{Assert, AssertNoError, Require} in sdk/
to the `*f` variants that are required to provide more error context.

Step towards deprecating non-f variants entirely.

For context, `contract.Require` is similar to `contract.Assert`,
except it has a required parameter name as an argument:

    func Require(cond bool, param string)
    func Requiref(cond bool, param string, msg string, args ...any)

It includes the parameter name in the error message by default,
so the `msg` and `args` should only describe the constraint
without naming the parameter.

Refs 
2023-02-15 10:22:43 -08:00
Fraser Waters 3f5191f7f1 Try to delete temporary files from plugin downloads
Fixes https://github.com/pulumi/pulumi/issues/12144

There's only three places in the codebase that we call
`workspace.DownloadToFile`. Before this change only one of them tried to
run `os.Remove` to cleanup afterwards.

This unifies all to use `os.Remove` and to also explictly ignore the
error returned by that (if it does fail it will log to `V(3)`).
2023-02-14 10:23:25 +00:00
Ian Wahbe 3ef8068559 Improve err message on an invalid plugin override 2023-01-13 12:47:58 -08:00
Ian Wahbe 69f208e4c9 Example of usage and test injection 2022-12-14 15:41:42 +01:00
Fraser Waters 9e5f1cc618 Engine and Golang support for shimless providers
This allows the pulumi-language-go plugin to start up providers directly
from .go source files.

The other language providers will be extended to support this as well in
time.
2022-11-14 11:25:41 +00:00
Aaron Friel 2d90969b58 feat(ci): Enable fully offline codegen tests with versioned plugins
Commit 1 of 2: this makes the changes to every file except the schemas,
for ease of review.
2022-10-11 05:16:23 -07:00
Fraser Waters 0ebe40a0c9
Fix getOrganization in policy ()
* Fix getOrganization in policy

* Add to CHANGELOG
2022-09-02 11:47:38 +02:00
Fraser Waters 6b496b0d18
Split PluginInfo in Info and Spec ()
Retry of https://github.com/pulumi/pulumi/pull/10492.

This time with a fixed and improved testDeletePlugin function.

This reverts commit 603d859126.
2022-08-26 15:51:14 +01:00
Anton Tayanovskyy 603d859126
Revert "Split PluginInfo in Info and Spec ()" ()
This reverts commit b81207f98c.
2022-08-25 14:56:23 -04:00
Fraser Waters b81207f98c
Split PluginInfo in Info and Spec ()
PluginSpec is used to specifiy a plugin, and is what is passed to things
like "Install". PluginInfo is used to refer to an installed plugin, and
so has extra data like file sizes, and time stamps, but does not include
things like plugin download url.
2022-08-25 12:27:28 +01:00
Fraser Waters 447e8276f1
Use explict ProjectPlugins rather than partially filling PluginInfo () 2022-08-18 15:31:10 +01:00
Fraser Waters be2295c436
Remove config from host, was unused () 2022-07-25 12:34:49 +01:00
Harry bb84532fe6
Plugin Link ()
* demo

* modifications for serialization

* Provisionally changed plugins from map to array

* warnings for duplicate

* avoid breaking change

* avoid null pointer dereference

* added test

* Delete Pulumi.yaml

* ensurePluginsAreInstalled

* lint

* reworked NewContext and added kind

* auto-detect current project for YAML

* lint

* removed debug statement

* automatically modify local paths

* typo

* First return value of GetPluginPath was never used

* Always use the path returned from getPluginInfoAndPath in GetPluginPath

Also assert that Path is the correct directory for PluginInfo.

* address comments

* added language, analyzers

* path tweaks and cosmetic changes

* changelog + tweaks

* changed NewContextWithRoot to accept plugins instead of project

* Fix TestUnmarshalProjectWithProviderList

* Fix NewContext

* Fix comment

Co-authored-by: Fraser Waters <fraser@pulumi.com>
2022-07-22 14:17:43 +01:00
Aaron Friel 3cd0665a2f
[schema] Faster schema loading via caching alongside plugins ()
* [engine] cache schemas in schema loader to files

* [engine] single instance mmapped schemas, preventing use-after-free segfault

* fix: clean up remaining references to close method

* chore: pr feedback
2022-06-13 23:27:11 -07:00
Ian Wahbe f3e430a1da
Respond to SIGINT during plugin install ()
* Respond to SIGINT

With the current state of the PR, crash on SIGINT. This is progress.

* Don't crash responding to SIGINT

* Close on cancel instead of terminate

* CL

* Fix lint

* Add ctx for node

* Be consistent for test context
2022-06-09 14:57:56 -07:00
Fraser Waters ecf65dab20
Load runtime plugins in parallel to other plugins ()
* Load runtime plugins in parallel to other plugins

* Add mutex

* ListPlugins wasn't actually used
2022-05-31 16:57:28 +01:00
pulumi-bot 73a66f48ea [breaking] Changing the version of go.mod in sdk / pkg to be v3 2021-04-14 19:32:18 +01:00
Pat Gavlin 249140242e
Add support for provider-side preview. ()
These changes add support for provider-side previews of create and
update operations, which allows resource providers to supply output
property values for resources that are being created or updated during a
preview.

If a plugin supports provider-side preview, its create/update methods
will be invoked during previews with the `preview` property set to true.
It is the responsibility of the provider to fill in any output
properties that are known before returning. It is a best practice for
providers to only fill in property values that are guaranteed to be
identical if the preview were instead an update (i.e. only those output
properties whose values can be conclusively determined without
actually performing the create/update operation should be populated).
Providers that support previews must accept unknown values in their
create and update methods.

If a plugin does not support provider-side preview, the inputs to a
create or update operation will be propagated to the outputs as they are
today.

Fixes .
2020-10-09 13:13:55 -07:00
Pat Gavlin 855f1fd1cd
Revise host mode. ()
* Revise host mode.

The current implementation of host mode uses a `pulumi host` command and
an ad-hoc communication protocol between the engine and client to
connect a language host after the host has begun listening. The most
significant disadvantages of this approach are the communication
protocol (which currently requires the use of stdout), the host-specific
command, and the difficulty of accommodating the typical program-bound
lifetime for an update.

These changes reimplement host mode by adding engine support for
connecting to an existing language runtime service rather than launching
a plugin. This capability is provided via an engine-specific language
runtime, `client`, which accepts the address of the existing languge
runtime service as a runtime option. The CLI exposes this runtime via
the `--client` flag to the `up` and `preview` commands, which similarly
accepts the address of an existing language runtime service as an
argument. These changes also adjust the automation API to consume the
new host mode implementation.
2020-09-14 17:40:17 -07:00
Justin Van Patten b77ec919d4
Install and use dependencies automatically for new Python projects ()
Automatically create a virtual environment and install dependencies in it with `pulumi new` and `pulumi policy new` for Python templates.

This will save a new `virtualenv` runtime option in `Pulumi.yaml` (`PulumiPolicy.yaml` for policy packs):

```yaml
runtime:
  name: python
  options:
    virtualenv: venv
```

`virtualenv` is the path to a virtual environment that Pulumi will use when running `python` commands.

Existing projects are unaffected and can opt-in to using this by setting `virtualenv`, otherwise, they'll continue to work as-is.
2020-06-09 16:42:53 -07:00
CyrusNajmabadi 66bd3f4aa8
Breaking changes due to Feature 2.0 work
* Make `async:true` the default for `invoke` calls ()

* Switch away from native grpc impl. ()

* Remove usage of the 'deasync' library from @pulumi/pulumi. ()

* Only retry as long as we get unavailable back.  Anything else continues. ()

* Handle all errors for now. ()


* Do not assume --yes was present when using pulumi in non-interactive mode ()

* Upgrade all paths for sdk and pkg to v2

* Backport C# invoke classes and other recent gen changes ()

Adjust C# generation

* Replace IDeployment with a sealed class ()

Replace IDeployment with a sealed class

* .NET: default to args subtype rather than Args.Empty ()

* Adding system namespace for Dotnet code gen

This is required for using Obsolute attributes for deprecations

```
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'ObsoleteAttribute' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
Iam/InstanceProfile.cs(142,10): error CS0246: The type or namespace name 'Obsolete' could not be found (are you missing a using directive or an assembly reference?) [/Users/stack72/code/go/src/github.com/pulumi/pulumi-aws/sdk/dotnet/Pulumi.Aws.csproj]
```

* Fix the nullability of config type properties in C# codegen ()
2020-04-14 09:30:25 +01:00
evanboyle a2b368827f fix internal logging usage 2020-03-19 11:45:10 -07:00
evanboyle c1d3a8524b move pkg/util/cmdutil -> sdk/go/common/util/cmdutil 2020-03-18 15:39:00 -07:00
evanboyle c3f6ae2451 move pkg/util/logging -> sdk/go/common/util/logging 2020-03-18 15:34:58 -07:00
evanboyle 8df534a71e move pkg/diag -> sdk/go/common/diag 2020-03-18 15:09:29 -07:00