MCPcopy
hub / github.com/roboll/helmfile / apply

Method apply

pkg/app/app.go:1224–1387  ·  view source on GitHub ↗
(r *Run, c ApplyConfigProvider)

Source from the content-addressed store, hash-verified

1222}
1223
1224func (a *App) apply(r *Run, c ApplyConfigProvider) (bool, bool, []error) {
1225 st := r.state
1226 helm := r.helm
1227
1228 selectedReleases, selectedAndNeededReleases, err := a.getSelectedReleases(r, c.IncludeTransitiveNeeds())
1229 if err != nil {
1230 return false, false, []error{err}
1231 }
1232 if len(selectedReleases) == 0 {
1233 return false, false, nil
1234 }
1235
1236 // This is required when you're trying to deduplicate releases by the selector.
1237 // Without this, `PlanReleases` conflates duplicates and return both in `batches`,
1238 // even if we provided `SelectedReleases: selectedReleases`.
1239 // See https://github.com/roboll/helmfile/issues/1818 for more context.
1240 st.Releases = selectedAndNeededReleases
1241
1242 plan, err := st.PlanReleases(state.PlanOptions{Reverse: false, SelectedReleases: selectedReleases, SkipNeeds: c.SkipNeeds(), IncludeNeeds: c.IncludeNeeds(), IncludeTransitiveNeeds: c.IncludeTransitiveNeeds()})
1243 if err != nil {
1244 return false, false, []error{err}
1245 }
1246
1247 var toApplyWithNeeds []state.ReleaseSpec
1248
1249 for _, rs := range plan {
1250 for _, r := range rs {
1251 toApplyWithNeeds = append(toApplyWithNeeds, r.ReleaseSpec)
1252 }
1253 }
1254
1255 // Do build deps and prepare only on selected releases so that we won't waste time
1256 // on running various helm commands on unnecessary releases
1257 st.Releases = toApplyWithNeeds
1258
1259 // helm must be 2.11+ and helm-diff should be provided `--detailed-exitcode` in order for `helmfile apply` to work properly
1260 detailedExitCode := true
1261
1262 diffOpts := &state.DiffOpts{
1263 NoColor: c.NoColor(),
1264 Context: c.Context(),
1265 Output: c.DiffOutput(),
1266 Set: c.Set(),
1267 SkipCleanup: c.RetainValuesFiles() || c.SkipCleanup(),
1268 SkipDiffOnInstall: c.SkipDiffOnInstall(),
1269 }
1270
1271 infoMsg, releasesToBeUpdated, releasesToBeDeleted, errs := r.diff(false, detailedExitCode, c, diffOpts)
1272 if len(errs) > 0 {
1273 return false, false, errs
1274 }
1275
1276 var toDelete []state.ReleaseSpec
1277 for _, r := range releasesToBeDeleted {
1278 toDelete = append(toDelete, r)
1279 }
1280
1281 var toUpdate []state.ReleaseSpec

Callers 1

ApplyMethod · 0.95

Calls 15

getSelectedReleasesMethod · 0.95
WrapWithoutSelectorMethod · 0.95
ReleaseToIDFunction · 0.92
GetArgsFunction · 0.92
withDAGFunction · 0.85
PlanReleasesMethod · 0.80
TriggerCleanupEventMethod · 0.80
askForConfirmationMethod · 0.80
DeleteReleasesForSyncMethod · 0.80
SyncReleasesMethod · 0.80

Tested by

no test coverage detected