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

Method Parse

internal/format/target.go:96–120  ·  view source on GitHub ↗

Parse creates a new Target given the provided target name.

(given string)

Source from the content-addressed store, hash-verified

94
95// Parse creates a new Target given the provided target name.
96func (tm *TargetParser) Parse(given string) (*Target, error) {
97 target := Target{writer: tm.defaultWriter}
98
99 formatAndPath, opts, foundOpts := strings.Cut(given, "?")
100
101 target.Options = tm.defaultOptions
102 if foundOpts {
103 if err := target.Options.mutate(opts); err != nil {
104 return nil, err
105 }
106 }
107
108 var path string
109 target.Format, path, _ = strings.Cut(formatAndPath, "=")
110
111 if target.Format == "" {
112 target.Format = tm.defaultFormat
113 }
114
115 if path != "" {
116 target.writer = &fileWriter{path: path, fs: tm.fs}
117 }
118
119 return &target, nil
120}
121
122// fileWriter implements a simple Writer wrapper for afero.Fs.
123type fileWriter struct {

Callers 15

TestTargetParserFunction · 0.95
IsAuthorizedMethod · 0.80
TestImageFunction · 0.80
TestLayerFunction · 0.80
determineAttestationTimeFunction · 0.80
TestNewPolicyFunction · 0.80
TestNewInputPolicyFunction · 0.80
parseEffectiveTimeFunction · 0.80
TestOCITracingFunction · 0.80
TestDelegationFunction · 0.80
WriteAllMethod · 0.80

Calls 1

mutateMethod · 0.80

Tested by 12

TestTargetParserFunction · 0.76
TestImageFunction · 0.64
TestLayerFunction · 0.64
TestNewPolicyFunction · 0.64
TestNewInputPolicyFunction · 0.64
TestOCITracingFunction · 0.64
TestDelegationFunction · 0.64
TestOCIImageReferrersFunction · 0.64