| 102 | } |
| 103 | |
| 104 | func (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) |