Add manifest to plan
This commit is contained in:
parent
6022b98134
commit
37b22b8d3c
|
@ -21,6 +21,7 @@ import (
|
|||
|
||||
"github.com/pulumi/pulumi/pkg/v3/resource/deploy/providers"
|
||||
"github.com/pulumi/pulumi/pkg/v3/secrets"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/apitype"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/workspace"
|
||||
|
@ -44,6 +45,27 @@ type Manifest struct {
|
|||
Plugins []workspace.PluginInfo // the plugin versions also loaded.
|
||||
}
|
||||
|
||||
func (m Manifest) Serialize() apitype.ManifestV1 {
|
||||
manifest := apitype.ManifestV1{
|
||||
Time: m.Time,
|
||||
Magic: m.Magic,
|
||||
Version: m.Version,
|
||||
}
|
||||
for _, plug := range m.Plugins {
|
||||
var version string
|
||||
if plug.Version != nil {
|
||||
version = plug.Version.String()
|
||||
}
|
||||
manifest.Plugins = append(manifest.Plugins, apitype.PluginInfoV1{
|
||||
Name: plug.Name,
|
||||
Path: plug.Path,
|
||||
Type: plug.Kind,
|
||||
Version: version,
|
||||
})
|
||||
}
|
||||
return manifest
|
||||
}
|
||||
|
||||
// NewMagic creates a magic cookie out of a manifest; this can be used to check for tampering. This ignores
|
||||
// any existing magic value already stored on the manifest.
|
||||
func (m Manifest) NewMagic() string {
|
||||
|
|
|
@ -105,23 +105,7 @@ func SerializeDeployment(snap *deploy.Snapshot, sm secrets.Manager, showSecrets
|
|||
contract.Require(snap != nil, "snap")
|
||||
|
||||
// Capture the version information into a manifest.
|
||||
manifest := apitype.ManifestV1{
|
||||
Time: snap.Manifest.Time,
|
||||
Magic: snap.Manifest.Magic,
|
||||
Version: snap.Manifest.Version,
|
||||
}
|
||||
for _, plug := range snap.Manifest.Plugins {
|
||||
var version string
|
||||
if plug.Version != nil {
|
||||
version = plug.Version.String()
|
||||
}
|
||||
manifest.Plugins = append(manifest.Plugins, apitype.PluginInfoV1{
|
||||
Name: plug.Name,
|
||||
Path: plug.Path,
|
||||
Type: plug.Kind,
|
||||
Version: version,
|
||||
})
|
||||
}
|
||||
manifest := snap.Manifest.Serialize()
|
||||
|
||||
// If a specific secrets manager was not provided, use the one in the snapshot, if present.
|
||||
if sm == nil {
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package stack
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/pulumi/pulumi/pkg/v3/resource/deploy"
|
||||
"github.com/pulumi/pulumi/pkg/v3/version"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/apitype"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
|
||||
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/config"
|
||||
|
@ -77,7 +80,19 @@ func SerializePlan(plan deploy.Plan, enc config.Encrypter, showSecrets bool) (ap
|
|||
}
|
||||
resourcePlans[urn] = serializedPlan
|
||||
}
|
||||
return apitype.DeploymentPlanV1{ResourcePlans: resourcePlans}, nil
|
||||
|
||||
// Bit odd this isn't part of deploy.Plan but that's just a map right now. We need to change that to track config and things so we'll move this then.
|
||||
manifest := deploy.Manifest{
|
||||
Time: time.Now(),
|
||||
Version: version.Version,
|
||||
// Plugins: sm.plugins, - Explicitly dropped, since we don't use the plugin list in the manifest anymore.
|
||||
}
|
||||
manifest.Magic = manifest.NewMagic()
|
||||
|
||||
return apitype.DeploymentPlanV1{
|
||||
Manifest: manifest.Serialize(),
|
||||
ResourcePlans: resourcePlans,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func DeserializeResourcePlan(
|
||||
|
|
Loading…
Reference in a new issue