Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bicep: remove main.parameters.json caching #4363

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions cli/azd/pkg/infra/provisioning/bicep/bicep_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ type BicepProvider struct {
ignoreDeploymentState bool
// compileBicepResult is cached to avoid recompiling the same bicep file multiple times in the same azd run.
compileBicepMemoryCache *compileBicepResult
// prevent resolving parameters multiple times in the same azd run.
ensureParamsInMemoryCache azure.ArmParameters
keyvaultService keyvault.KeyVaultService
portalUrlBase string
keyvaultService keyvault.KeyVaultService
portalUrlBase string
}

// Name gets the name of the infra provider
Expand Down Expand Up @@ -1793,10 +1791,6 @@ func (p *BicepProvider) ensureParameters(
ctx context.Context,
template azure.ArmTemplate,
) (azure.ArmParameters, error) {
if p.ensureParamsInMemoryCache != nil {
return maps.Clone(p.ensureParamsInMemoryCache), nil
}

parameters, err := p.loadParameters(ctx)
if err != nil {
return nil, fmt.Errorf("resolving bicep parameters file: %w", err)
Expand Down Expand Up @@ -1922,19 +1916,15 @@ func (p *BicepProvider) ensureParameters(
configuredParameters[key] = azure.ArmParameterValue{
Value: value,
}
configuredParameters[prompt.key] = azure.ArmParameterValue{
Value: value,
}
}
}
}

if configModified {
if err := p.envManager.Save(ctx, p.env); err != nil {
p.console.Message(ctx, fmt.Sprintf("warning: failed to save configured values: %v", err))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case it isn't clear why ignoring this error may not be ideal:

Suppose that Save() failed due to flakiness once -- this variable ends up getting re-prompted which is confusing behavior to a user. Straight up failing is better here.

A code demonstration.

Here's it live:
Screenshot 2024-09-20 at 1 22 38 PM

return nil, fmt.Errorf("saving prompt values: %w", err)
}
}
p.ensureParamsInMemoryCache = maps.Clone(configuredParameters)
return configuredParameters, nil
}

Expand Down
Loading