MCPcopy
hub / github.com/carvel-dev/ytt / RunWithFiles

Method RunWithFiles

pkg/cmd/template/cmd.go:104–170  ·  view source on GitHub ↗
(in Input, ui ui.UI)

Source from the content-addressed store, hash-verified

102}
103
104func (o *Options) RunWithFiles(in Input, ui ui.UI) Output {
105 var err error
106
107 in.Files, err = o.FileMarksOpts.Apply(in.Files)
108 if err != nil {
109 return Output{Err: err}
110 }
111
112 rootLibrary := workspace.NewRootLibrary(in.Files)
113 rootLibrary.Print(ui.DebugWriter())
114
115 if o.InspectFiles {
116 return o.inspectFiles(rootLibrary)
117 }
118
119 valuesOverlays, libraryValuesOverlays, err := o.DataValuesFlags.AsOverlays(o.StrictYAML)
120 if err != nil {
121 return Output{Err: err}
122 }
123
124 libraryExecutionFactory := workspace.NewLibraryExecutionFactory(
125 ui,
126 workspace.TemplateLoaderOpts{
127 IgnoreUnknownComments: o.IgnoreUnknownComments,
128 ImplicitMapKeyOverrides: o.ImplicitMapKeyOverrides,
129 StrictYAML: o.StrictYAML,
130 },
131 o.DataValuesFlags.SkipValidation)
132
133 libraryCtx := workspace.LibraryExecutionContext{Current: rootLibrary, Root: rootLibrary}
134 rootLibraryExecution := libraryExecutionFactory.New(libraryCtx)
135
136 schema, librarySchemas, err := rootLibraryExecution.Schemas(nil)
137 if err != nil {
138 return Output{Err: err}
139 }
140
141 if o.DataValuesFlags.InspectSchema {
142 return o.inspectSchema(schema)
143 }
144
145 schemaType, err := o.RegularFilesSourceOpts.OutputType.Schema()
146 if err != nil {
147 return Output{Err: err}
148 }
149 if schemaType == RegularFilesOutputTypeOpenAPI {
150 return Output{Err: fmt.Errorf("Output type currently only supported for data values schema (i.e. include --data-values-schema-inspect)")}
151 }
152
153 values, libraryValues, err := rootLibraryExecution.Values(valuesOverlays, schema)
154 if err != nil {
155 return Output{Err: err}
156 }
157
158 libraryValues = append(libraryValues, libraryValuesOverlays...)
159
160 if o.DataValuesFlags.Inspect {
161 return o.inspectDataValues(values)

Calls 14

inspectFilesMethod · 0.95
NewMethod · 0.95
inspectSchemaMethod · 0.95
inspectDataValuesMethod · 0.95
NewRootLibraryFunction · 0.92
AsOverlaysMethod · 0.80
SchemasMethod · 0.80
SchemaMethod · 0.80
ValuesMethod · 0.80
PrintMethod · 0.65
DebugWriterMethod · 0.65