wip config work

This commit is contained in:
Fraser Waters 2021-11-23 16:43:27 +00:00
parent 94bf0840df
commit 8f959a03b0
4 changed files with 15 additions and 6 deletions

View file

@ -28,6 +28,7 @@ import (
"github.com/pulumi/pulumi/pkg/v3/resource/graph"
"github.com/pulumi/pulumi/sdk/v3/go/common/diag"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/config"
"github.com/pulumi/pulumi/sdk/v3/go/common/resource/plugin"
"github.com/pulumi/pulumi/sdk/v3/go/common/tokens"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/contract"
@ -150,9 +151,9 @@ type resourcePlans struct {
plans Plan
}
func newResourcePlan() *resourcePlans {
func newResourcePlan(config config.Map) *resourcePlans {
return &resourcePlans{
plans: NewPlan(),
plans: NewPlan(config),
}
}
@ -384,7 +385,7 @@ func NewDeployment(ctx *plugin.Context, target *Target, prev *Snapshot, plan *Pl
providers: reg,
goals: newGoals,
news: newResources,
newPlans: newResourcePlan(),
newPlans: newResourcePlan(target.Config),
}, nil
}

View file

@ -97,7 +97,7 @@ func NewImportDeployment(ctx *plugin.Context, target *Target, projectName tokens
source: NewErrorSource(projectName),
preview: preview,
providers: reg,
newPlans: newResourcePlan(),
newPlans: newResourcePlan(target.Config),
}, nil
}

View file

@ -26,10 +26,10 @@ type Plan struct {
// Any environment variables that were set when the plan was created. Values are encrypted.
EnvironmentVariables map[string][]byte
// The configuration in use during the plan.
Config map[string]config.Value
Config config.Map
}
func NewPlan() Plan {
func NewPlan(config config.Map) Plan {
manifest := Manifest{
Time: time.Now(),
Version: version.Version,
@ -40,6 +40,7 @@ func NewPlan() Plan {
return Plan{
ResourcePlans: make(map[resource.URN]*ResourcePlan),
Manifest: manifest,
Config: config,
}
}

View file

@ -78,6 +78,13 @@ func SerializePlan(plan *deploy.Plan, enc config.Encrypter, showSecrets bool) (a
resourcePlans[urn] = serializedPlan
}
config := make(map[string]Value, len(plan.Config))
for value := range plan.Config {
for k, v := range m {
rawMap[k.String()] = v
}
}
return apitype.DeploymentPlanV1{
Manifest: plan.Manifest.Serialize(),
ResourcePlans: resourcePlans,