CCM Manifest Provider

This document describes the implementation details of the CCM Manifest provider for resolving and executing child manifests.

Provider Selection

The CCM Manifest provider is the only apply provider. It is always available and returns priority 1 for all apply resources.

Operations

ApplyManifest

Process:

  1. Capture parent state (noop mode, working directory, data)
  2. Strengthen noop mode if the parent is in noop mode or the resource has noop: true
  3. Build execution options for the child manifest
  4. Resolve the child manifest via apply.ResolveManifestUrl()
  5. Execute the resolved manifest via resolvedApply.Execute()
  6. Inspect child resource outcomes (changed, failed, skipped)
  7. Restore parent state via deferred restore

Noop Strengthening:

The provider only strengthens noop mode, never weakens it. If the parent manager is already in noop mode, the child inherits that regardless of its own noop property. If the parent is not in noop mode and the resource sets noop: true, the provider enables noop on the manager before resolution.

Parent noopResource noopAction
truefalseNo change, parent noop already active
truetrueNo change, parent noop already active
falsetrueEnable noop on manager
falsefalseNo change

Health check mode follows the same strengthening pattern. The effective health check mode is true if either the parent or the resource sets it.

Execute Options:

The provider builds these options to control child manifest behavior:

OptionConditionPurpose
WithSkipSession()AlwaysReuse parent session instead of creating a new one
WithCurrentDepth(n)AlwaysTrack recursion depth for nested apply resources
WithOverridingResolvedDatadata property is setMerge resource data into the child’s resolved data
WithDenyApplyResources()allow_apply is falsePrevent child from containing apply resources

State Capture and Restore

The provider saves three pieces of manager state before manifest resolution and restores them after execution via defer. This ensures restoration runs even if resolution or execution fails.

FieldCaptureRestore
Noop modemgr.NoopMode()mgr.SetNoopMode(saved)
Working directorymgr.WorkingDirectory()mgr.SetWorkingDirectory(saved)
Datamgr.Data()mgr.SetData(saved)

State capture happens before any resolve or mutation calls. This ordering is critical because ResolveManifestUrl mutates the manager’s working directory and data during resolution.

Restoration ensures that subsequent resources in the parent manifest see the original manager state. Without it, a child manifest’s working directory and data changes would leak into sibling resources.

Path Resolution

The resource name property specifies a file path relative to the parent manifest’s directory. During resolution, ResolveManifestFilePath joins relative paths with the manager’s current working directory before opening the file.

For nested apply resources, each level sets the working directory to its own manifest’s parent directory. The state restore ensures the working directory returns to the correct value after each child completes.

/opt/ccm/manifest.yaml          WD = /opt/ccm/
  apply: sub/manifest.yaml       resolves to /opt/ccm/sub/manifest.yaml
                                  WD = /opt/ccm/sub/
    apply: lib/manifest.yaml     resolves to /opt/ccm/sub/lib/manifest.yaml
                                  WD = /opt/ccm/sub/lib/
                                  (restore WD to /opt/ccm/sub/)
                                (restore WD to /opt/ccm/)

Child Resource Inspection

After execution, the provider iterates over child resources to count outcomes using the shared session:

OutcomeDetection methodEffect
Failedmgr.IsResourceFailedIncrement fail count
Changedmgr.ShouldRefreshIncrement change count
SkippedNeitherRemainder

The provider builds an ApplyState with the total resource count and reports the outcome:

Child resultProvider behavior
All resources succeededLog informational message, return state
Some resources changedLog warning with counts, return state
Any resource failedLog error, return error with failure count

Logging

The provider creates a child user logger with a manifest key set to the resource name. All child resource log output includes this key, providing attribution for which parent apply resource triggered the execution.