Apply does not need remarking
Apply, at this moment, appears that it does not require the remarking strategy, as the plan has already been printed
This commit is contained in:
parent
5b0b1a13a5
commit
3e8b125e53
|
@ -78,26 +78,6 @@ func (n *EvalApply) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy paste from eval_diff
|
|
||||||
var markedPath cty.Path
|
|
||||||
// var marks cty.ValueMarks
|
|
||||||
if configVal.ContainsMarked() {
|
|
||||||
// store the marked values so we can re-mark them later after
|
|
||||||
// we've sent things over the wire. Right now this stores
|
|
||||||
// one path for proof of concept, but we should store multiple
|
|
||||||
cty.Walk(configVal, func(p cty.Path, v cty.Value) (bool, error) {
|
|
||||||
if v.IsMarked() {
|
|
||||||
markedPath = p
|
|
||||||
return false, nil
|
|
||||||
// marks = v.Marks()
|
|
||||||
}
|
|
||||||
return true, nil
|
|
||||||
})
|
|
||||||
// Unmark the value for sending over the wire
|
|
||||||
// to providers as marks cannot be serialized
|
|
||||||
configVal, _ = configVal.UnmarkDeep()
|
|
||||||
}
|
|
||||||
|
|
||||||
metaConfigVal := cty.NullVal(cty.DynamicPseudoType)
|
metaConfigVal := cty.NullVal(cty.DynamicPseudoType)
|
||||||
if n.ProviderMetas != nil {
|
if n.ProviderMetas != nil {
|
||||||
log.Printf("[DEBUG] EvalApply: ProviderMeta config value set")
|
log.Printf("[DEBUG] EvalApply: ProviderMeta config value set")
|
||||||
|
@ -125,14 +105,23 @@ func (n *EvalApply) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
|
|
||||||
log.Printf("[DEBUG] %s: applying the planned %s change", n.Addr.Absolute(ctx.Path()), change.Action)
|
log.Printf("[DEBUG] %s: applying the planned %s change", n.Addr.Absolute(ctx.Path()), change.Action)
|
||||||
|
|
||||||
// HACK The after val is also marked so let's fix that
|
// If our config or After value contain any marked values,
|
||||||
unmarked, _ := change.After.UnmarkDeep()
|
// ensure those are stripped out before sending
|
||||||
|
// this to the provider
|
||||||
|
unmarkedConfigVal := configVal
|
||||||
|
if configVal.ContainsMarked() {
|
||||||
|
unmarkedConfigVal, _ = configVal.UnmarkDeep()
|
||||||
|
}
|
||||||
|
unmarkedAfter := change.After
|
||||||
|
if change.After.ContainsMarked() {
|
||||||
|
unmarkedAfter, _ = change.After.UnmarkDeep()
|
||||||
|
}
|
||||||
|
|
||||||
resp := provider.ApplyResourceChange(providers.ApplyResourceChangeRequest{
|
resp := provider.ApplyResourceChange(providers.ApplyResourceChangeRequest{
|
||||||
TypeName: n.Addr.Resource.Type,
|
TypeName: n.Addr.Resource.Type,
|
||||||
PriorState: change.Before,
|
PriorState: change.Before,
|
||||||
Config: configVal,
|
Config: unmarkedConfigVal,
|
||||||
PlannedState: unmarked,
|
PlannedState: unmarkedAfter,
|
||||||
PlannedPrivate: change.Private,
|
PlannedPrivate: change.Private,
|
||||||
ProviderMeta: metaConfigVal,
|
ProviderMeta: metaConfigVal,
|
||||||
})
|
})
|
||||||
|
@ -149,16 +138,6 @@ func (n *EvalApply) Eval(ctx EvalContext) (interface{}, error) {
|
||||||
// incomplete.
|
// incomplete.
|
||||||
newVal := resp.NewState
|
newVal := resp.NewState
|
||||||
|
|
||||||
// Add the mark back to the planned new value
|
|
||||||
if len(markedPath) != 0 {
|
|
||||||
newVal, _ = cty.Transform(newVal, func(p cty.Path, v cty.Value) (cty.Value, error) {
|
|
||||||
if p.Equals(markedPath) {
|
|
||||||
return v.Mark("sensitive"), nil
|
|
||||||
}
|
|
||||||
return v, nil
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if newVal == cty.NilVal {
|
if newVal == cty.NilVal {
|
||||||
// Providers are supposed to return a partial new value even when errors
|
// Providers are supposed to return a partial new value even when errors
|
||||||
// occur, but sometimes they don't and so in that case we'll patch that up
|
// occur, but sometimes they don't and so in that case we'll patch that up
|
||||||
|
|
Loading…
Reference in New Issue