MCPcopy Create free account
hub / github.com/conforma/cli / NewInputPolicy

Function NewInputPolicy

internal/policy/policy.go:222–236  ·  view source on GitHub ↗

NewInputPolicy constructs and returns a new instance of Policy that doesn't perform strict checks on the consistency of the policy, but can evaluate based on provided effectiveTime The policyRef parameter is expected to be either a YAML/JSON-encoded instance of EnterpriseContractPolicySpec, or refe

(ctx context.Context, policyRef string, effectiveTime string)

Source from the content-addressed store, hash-verified

220//
221// If policyRef is blank, an empty EnterpriseContractPolicySpec is used.
222func NewInputPolicy(ctx context.Context, policyRef string, effectiveTime string) (Policy, error) {
223 if efn, err := parseEffectiveTime(effectiveTime); err == nil {
224 p := policy{
225 choosenTime: effectiveTime,
226 checkOpts: &cosign.CheckOpts{},
227 }
228 if err := p.loadPolicy(ctx, policyRef); err != nil {
229 return nil, err
230 }
231 p.effectiveTime = efn
232 return &p, nil
233 } else {
234 return nil, err
235 }
236}
237
238// NewPolicy construct and return a new instance of Policy.
239//

Callers 3

createTestPolicyFunction · 0.92
validateInputCmdFunction · 0.92
TestNewInputPolicyFunction · 0.85

Calls 2

loadPolicyMethod · 0.95
parseEffectiveTimeFunction · 0.85

Tested by 2

createTestPolicyFunction · 0.74
TestNewInputPolicyFunction · 0.68