@@ -27,6 +27,7 @@ import (
2727 "github.com/pulumi/pulumi/pkg/v3/cmd/pulumi/packageinstallation"
2828 "github.com/pulumi/pulumi/pkg/v3/cmd/pulumi/packageresolution"
2929 "github.com/pulumi/pulumi/pkg/v3/cmd/pulumi/packageworkspace"
30+ "github.com/pulumi/pulumi/pkg/v3/pluginstorage"
3031 "github.com/pulumi/pulumi/pkg/v3/registry"
3132 "github.com/pulumi/pulumi/sdk/v3/go/common/apitype"
3233 "github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
@@ -48,7 +49,7 @@ func TestInstallAlreadyInstalledPackage(t *testing.T) {
4849 Kind : apitype .ResourcePlugin ,
4950 },
5051 downloaded : true ,
51- installed : true ,
52+ state : pluginstorage . PluginInstalled ,
5253 hasBinary : true ,
5354 },
5455 })
@@ -83,7 +84,7 @@ func TestInstallAlreadyInstalledPlugin(t *testing.T) {
8384 Kind : apitype .ResourcePlugin ,
8485 },
8586 downloaded : true ,
86- installed : true ,
87+ state : pluginstorage . PluginInstalled ,
8788 hasBinary : true ,
8889 },
8990 })
@@ -115,7 +116,7 @@ func TestDoNotInstallDependenciesOfAlreadyInstalledPackage(t *testing.T) {
115116 Kind : apitype .ResourcePlugin ,
116117 },
117118 downloaded : true ,
118- installed : true ,
119+ state : pluginstorage . PluginInstalled ,
119120 project : & workspace.PluginProject {
120121 Runtime : workspace .NewProjectRuntimeInfo ("go" , nil ),
121122 Packages : map [string ]workspace.PackageSpec {
@@ -910,9 +911,11 @@ func TestInstallPluginWithMultipleVersions(t *testing.T) {
910911 pluginBPath := "$HOME/.pulumi/plugins/resource-plugin-b"
911912
912913 require .True (t , ws .plugins [sharedV1Path ].downloaded , "shared-plugin v1.0.0 should be downloaded" )
913- require .True (t , ws .plugins [sharedV1Path ].installed , "shared-plugin v1.0.0 should be installed" )
914+ require .Equal (t , pluginstorage .PluginInstalled , ws .plugins [sharedV1Path ].state ,
915+ "shared-plugin v1.0.0 should be installed" )
914916 require .True (t , ws .plugins [sharedV2Path ].downloaded , "shared-plugin v2.0.0 should be downloaded" )
915- require .True (t , ws .plugins [sharedV2Path ].installed , "shared-plugin v2.0.0 should be installed" )
917+ require .Equal (t , pluginstorage .PluginInstalled , ws .plugins [sharedV2Path ].state ,
918+ "shared-plugin v2.0.0 should be installed" )
916919
917920 // Verify that plugin-a is linked to v1.0.0 and plugin-b is linked to v2.0.0
918921 require .Contains (t , ws .plugins [pluginAPath ].linked , sharedV1Path + "/sdk-<nil>" ,
@@ -1333,9 +1336,10 @@ func TestInstallPluginWithRequiredPackages(t *testing.T) {
13331336 pluginBPath := "$HOME/.pulumi/plugins/resource-plugin-b-v2.0.0"
13341337
13351338 require .True (t , ws .plugins [pluginAPath ].downloaded , "plugin-a should be downloaded" )
1336- require .True (t , ws .plugins [pluginAPath ].installed , "plugin-a should be installed" )
1339+ require .Equal (t , pluginstorage . PluginInstalled , ws .plugins [pluginAPath ].state , "plugin-a should be installed" )
13371340 require .True (t , ws .plugins [pluginBPath ].downloaded , "plugin-b should be downloaded (as a required package)" )
1338- require .True (t , ws .plugins [pluginBPath ].installed , "plugin-b should be installed (as a required package)" )
1341+ require .Equal (t , pluginstorage .PluginInstalled , ws .plugins [pluginBPath ].state ,
1342+ "plugin-b should be installed (as a required package)" )
13391343}
13401344
13411345// TestInstallPluginWithRequiredPackageSpecs tests that the package specs returned as the
@@ -1406,9 +1410,10 @@ func TestInstallPluginWithRequiredPackageSpecs(t *testing.T) {
14061410 pluginBPath := "$HOME/.pulumi/plugins/resource-plugin-b-v2.0.0"
14071411
14081412 require .True (t , ws .plugins [pluginAPath ].downloaded , "plugin-a should be downloaded" )
1409- require .True (t , ws .plugins [pluginAPath ].installed , "plugin-a should be installed" )
1413+ require .Equal (t , pluginstorage . PluginInstalled , ws .plugins [pluginAPath ].state , "plugin-a should be installed" )
14101414 require .True (t , ws .plugins [pluginBPath ].downloaded , "plugin-b should be downloaded (as a required spec)" )
1411- require .True (t , ws .plugins [pluginBPath ].installed , "plugin-b should be installed (as a required spec)" )
1415+ require .Equal (t , pluginstorage .PluginInstalled , ws .plugins [pluginBPath ].state ,
1416+ "plugin-b should be installed (as a required spec)" )
14121417
14131418 require .Contains (t , ws .plugins [pluginAPath ].linked , pluginBPath + "/sdk-<nil>" ,
14141419 "plugin-a should have a local SDK for plugin-b linked in (as a required spec)" )
@@ -1726,9 +1731,9 @@ func TestInstallSharedDependencyInParallel(t *testing.T) {
17261731 pluginCSDK := "$HOME/.pulumi/plugins/resource-plugin-c/sdk-<nil>"
17271732 pluginDSDK := "$HOME/.pulumi/plugins/resource-plugin-d/sdk-<nil>"
17281733
1729- require .True (t , baselineWs .plugins [componentAPath ].installed ,
1734+ require .Equal (t , pluginstorage . PluginInstalled , baselineWs .plugins [componentAPath ].state ,
17301735 "component-a should be installed in baseline" )
1731- require .True (t , baselineWs .plugins [componentBPath ].installed ,
1736+ require .Equal (t , pluginstorage . PluginInstalled , baselineWs .plugins [componentBPath ].state ,
17321737 "component-b should be installed in baseline" )
17331738
17341739 require .Contains (t , baselineWs .plugins [componentAPath ].linked , pluginCSDK ,
@@ -1838,9 +1843,9 @@ func TestRequiredPackagesDeclaredInProjectPackagesNotDownloaded(t *testing.T) {
18381843 providerPath := "/work/provider"
18391844 providerNestedPath := "/work/provider-nested"
18401845
1841- require .True (t , ws .plugins [providerPath ].installed ,
1846+ require .Equal (t , pluginstorage . PluginInstalled , ws .plugins [providerPath ].state ,
18421847 "provider should be installed" )
1843- require .True (t , ws .plugins [providerNestedPath ].installed ,
1848+ require .Equal (t , pluginstorage . PluginInstalled , ws .plugins [providerNestedPath ].state ,
18441849 "provider-nested should be installed (via provider's packages)" )
18451850}
18461851
@@ -1906,6 +1911,44 @@ func TestInstallPluginSet(t *testing.T) {
19061911 require .True (t , ws .plugins [specPath ].downloaded , "spec plugin should be downloaded" )
19071912}
19081913
1914+ // A provider that is attached with PULUMI_DEBUG_PROVIDERS already runs. It has no
1915+ // directory in the plugin cache, so the install must not download it or look for its
1916+ // path on disk.
1917+ func TestInstallPluginSetAttachedProvider (t * testing.T ) {
1918+ t .Parallel ()
1919+
1920+ attached := workspace.PluginDescriptor {
1921+ Name : "attached-provider" ,
1922+ Kind : apitype .ResourcePlugin ,
1923+ }
1924+ ws := newInvariantWorkspace (t , []string {"/project" }, nil , []invariantPlugin {
1925+ {d : attached , state : pluginstorage .PluginAttached },
1926+ })
1927+
1928+ rws := & recordingWorkspace {ws , nil }
1929+ defer rws .save (t )
1930+
1931+ _ , err := packageinstallation .InstallPluginSet (t .Context (),
1932+ []workspace.PackageDescriptor {{PluginDescriptor : attached }},
1933+ nil ,
1934+ & workspace.Project {
1935+ Name : "test-project" ,
1936+ Runtime : workspace .NewProjectRuntimeInfo ("go" , nil ),
1937+ }, "/project" , packageinstallation.Options {
1938+ Options : packageresolution.Options {
1939+ ResolveVersionWithLocalWorkspace : true ,
1940+ AllowNonInvertableLocalWorkspaceResolution : true ,
1941+ },
1942+ Concurrency : 1 ,
1943+ }, nil , rws )
1944+ require .NoError (t , err )
1945+
1946+ assert .Equal (t , invariantPlugin {
1947+ d : attached ,
1948+ state : pluginstorage .PluginAttached ,
1949+ }, * ws .plugins ["$HOME/.pulumi/plugins/resource-attached-provider" ])
1950+ }
1951+
19091952// TestInstallPluginSetRemotePackageOverride checks that a remote (registry)
19101953// package in the project's `packages:` block - the kind written by `pulumi
19111954// package add` - is installed via the normal descriptor download path rather
0 commit comments