Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2805 from 2opremio/cache-generators-for-patchupda…
Browse files Browse the repository at this point in the history
…ted-configs

Cache the generators of patchUpdated configurations
  • Loading branch information
squaremo authored Apr 1, 2020
2 parents 70ab5bc + 7d07df0 commit 6e6f3a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func (d *Daemon) updatePolicies(spec update.Spec, updates resource.PolicyUpdates
Status: update.ReleaseStatusSkipped,
}
}
if policy.Set(u.Add).Has(policy.Automated) {
if u.Add.Has(policy.Automated) {
anythingAutomated = true
}
cm, err := d.getManifestStore(working)
Expand Down
17 changes: 11 additions & 6 deletions pkg/manifests/configfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ type PolicyUpdater struct {
// maintaining a patch, which is calculating from, and applied to, the
// generated manifests.
type PatchUpdated struct {
Generators []Generator `json:"generators"`
PatchFile string `json:"patchFile,omitempty"`
Generators []Generator `json:"generators"`
PatchFile string `json:"patchFile,omitempty"`
generatorsResultCache []byte
}

// ScanForFiles represents a config in which the directory should be
Expand Down Expand Up @@ -324,11 +325,15 @@ type ConfigFileCombinedExecResult struct {
// getGeneratedAndPatchedManifests is used to generate manifests when
// the config is patchUpdated.
func (cf *ConfigFile) getGeneratedAndPatchedManifests(ctx context.Context, manifests Manifests) ([]byte, []byte, string, error) {
generatedManifests, err := cf.getGeneratedManifests(ctx, manifests, cf.PatchUpdated.Generators)
if err != nil {
return nil, nil, "", err
generatedManifests := cf.PatchUpdated.generatorsResultCache
if generatedManifests == nil {
var err error
generatedManifests, err = cf.getGeneratedManifests(ctx, manifests, cf.PatchUpdated.Generators)
if err != nil {
return nil, nil, "", err
}
cf.PatchUpdated.generatorsResultCache = generatedManifests
}

// The patch file is given in the config file as a path relative
// to the working directory
relPatchFilePath := cf.PatchUpdated.PatchFile
Expand Down

0 comments on commit 6e6f3a8

Please sign in to comment.