MCPcopy
hub / github.com/argoproj/argo-workflows / loadArtifacts

Method loadArtifacts

workflow/executor/executor.go:184–309  ·  view source on GitHub ↗

loadArtifacts loads artifacts from location to a container path pluginName is the name of the plugin to load artifacts from, only one plugin can be used at a time

(ctx context.Context, pluginName wfv1.ArtifactPluginName)

Source from the content-addressed store, hash-verified

182// loadArtifacts loads artifacts from location to a container path
183// pluginName is the name of the plugin to load artifacts from, only one plugin can be used at a time
184func (we *WorkflowExecutor) loadArtifacts(ctx context.Context, pluginName wfv1.ArtifactPluginName) error {
185 logger := logging.RequireLoggerFromContext(ctx)
186 logger.WithFields(logging.Fields{"pluginName": pluginName}).Info(ctx, "Start loading input artifacts...")
187 for _, art := range we.Template.Inputs.Artifacts {
188 logger.WithField("name", art.Name).Info(ctx, "Downloading artifact")
189
190 if !art.HasLocationOrKey() {
191 if art.Optional {
192 logger.WithField("name", art.Name).Info(ctx, "Ignoring optional artifact which was not supplied")
193 continue
194 } else {
195 return argoerrs.Errorf(argoerrs.CodeNotFound, "required artifact '%s' not supplied", art.Name)
196 }
197 }
198 err := art.CleanPath()
199 if err != nil {
200 return err
201 }
202 driverArt, err := we.newDriverArt(&art)
203 if err != nil {
204 return fmt.Errorf("failed to load artifact '%s': %w", art.Name, err)
205 }
206 switch pluginName {
207 // If no plugin is specified only load non-plugin artifacts
208 case "":
209 if driverArt.Plugin != nil {
210 logger.Info(ctx, "Skipping artifact that is from a plugin")
211 continue
212 }
213 // If a plugin is specified only load artifacts from that plugin
214 default:
215 if driverArt.Plugin == nil || driverArt.Plugin.Name != pluginName {
216 logger.WithFields(logging.Fields{"name": driverArt.Name, "plugin": driverArt.Plugin}).Info(ctx, "Skipping artifact that is not from the specified plugin")
217 continue
218 }
219 }
220
221 artDriver, err := we.InitDriver(ctx, driverArt)
222 if err != nil {
223 return err
224 }
225 // Determine the file path of where to load the artifact
226 var artPath string
227 mnt := common.FindOverlappingVolume(&we.Template, art.Path)
228 if mnt == nil {
229 artPath = path.Join(common.ExecutorArtifactBaseDir, art.Name)
230 } else {
231 // If we get here, it means the input artifact path overlaps with a user-specified
232 // volumeMount in the container. Because we also implement input artifacts as volume
233 // mounts, we need to load the artifact into the user specified volume mount,
234 // as opposed to the `input-artifacts` volume that is an implementation detail
235 // unbeknownst to the user.
236 logger.WithFields(logging.Fields{"path": art.Path, "mountPath": mnt.MountPath}).Info(ctx, "Specified artifact path overlaps with volume mount, extracting to volume mount")
237 artPath = path.Join(common.ExecutorMainFilesystemDir, art.Path)
238 }
239
240 // The artifact is downloaded to a temporary location, after which we determine if
241 // the file is a tarball or not. If it is, it is first extracted then renamed to

Calls 15

newDriverArtMethod · 0.95
InitDriverMethod · 0.95
RequireLoggerFromContextFunction · 0.92
FindOverlappingVolumeFunction · 0.92
isTarballFunction · 0.85
untarFunction · 0.85
unzipFunction · 0.85
chmodFunction · 0.85
HasLocationOrKeyMethod · 0.80
CleanPathMethod · 0.80
GetArchiveMethod · 0.80
InfoMethod · 0.65

Tested by 1