Auto refresh if using plans

This commit is contained in:
Fraser Waters 2021-11-19 14:29:30 +00:00
parent b3d8cd9870
commit 6d02c4adc8
4 changed files with 11 additions and 6 deletions

View file

@ -148,7 +148,7 @@ func newDestroyCmd() *cobra.Command {
targetUrns = append(targetUrns, resource.URN(t))
}
refreshOption, err := getRefreshOption(proj, refresh)
refreshOption, err := getRefreshOption(proj, refresh, "")
if err != nil {
return result.FromError(err)
}

View file

@ -164,7 +164,7 @@ func newPreviewCmd() *cobra.Command {
replaceURNs = append(replaceURNs, resource.URN(tr))
}
refreshOption, err := getRefreshOption(proj, refresh)
refreshOption, err := getRefreshOption(proj, refresh, planFilePath)
if err != nil {
return result.FromError(err)
}

View file

@ -125,7 +125,7 @@ func newUpCmd() *cobra.Command {
replaceURNs = append(replaceURNs, resource.URN(tr))
}
refreshOption, err := getRefreshOption(proj, refresh)
refreshOption, err := getRefreshOption(proj, refresh, planFilePath)
if err != nil {
return result.FromError(err)
}
@ -310,7 +310,7 @@ func newUpCmd() *cobra.Command {
return result.FromError(fmt.Errorf("getting stack configuration: %w", err))
}
refreshOption, err := getRefreshOption(proj, refresh)
refreshOption, err := getRefreshOption(proj, refresh, planFilePath)
if err != nil {
return result.FromError(err)
}

View file

@ -846,7 +846,7 @@ func checkDeploymentVersionError(err error, stackName string) error {
return fmt.Errorf("could not deserialize deployment: %w", err)
}
func getRefreshOption(proj *workspace.Project, refresh string) (bool, error) {
func getRefreshOption(proj *workspace.Project, refresh string, planFilePath string) (bool, error) {
// we want to check for an explicit --refresh or a --refresh=true or --refresh=false
// refresh is assigned the empty string by default to distinguish the difference between
// when the user actually interacted with the cli argument (`NoOptDefVal`)
@ -865,7 +865,12 @@ func getRefreshOption(proj *workspace.Project, refresh string) (bool, error) {
return true, nil
}
// the default functionality right now is to always skip a refresh
// if the user has passed a plan file then the default behaviour is to refresh
if planFilePath != "" {
return true, nil
}
// else the default functionality right now is to always skip a refresh
return false, nil
}