(ctx context.Context, pkgLayout *layout.PackageLayout, component v1alpha1.ZarfComponent, noImgChecksum bool, noImgPush bool, opts DeployOptions)
| 437 | } |
| 438 | |
| 439 | func (d *deployer) deployComponent(ctx context.Context, pkgLayout *layout.PackageLayout, component v1alpha1.ZarfComponent, noImgChecksum bool, noImgPush bool, opts DeployOptions) (_ []state.InstalledChart, err error) { |
| 440 | l := logger.From(ctx) |
| 441 | start := time.Now() |
| 442 | |
| 443 | l.Info("deploying component", "name", component.Name) |
| 444 | |
| 445 | hasImages := len(component.GetImages()) > 0 && !noImgPush && !opts.Connected |
| 446 | hasCharts := len(component.Charts) > 0 |
| 447 | hasManifests := len(component.Manifests) > 0 |
| 448 | hasRepos := len(component.Repos) > 0 && !opts.Connected |
| 449 | hasFiles := len(component.Files) > 0 |
| 450 | |
| 451 | onDeploy := component.Actions.OnDeploy |
| 452 | cwd, err := os.Getwd() |
| 453 | if err != nil { |
| 454 | return nil, fmt.Errorf("failed to get working directory: %w", err) |
| 455 | } |
| 456 | |
| 457 | if component.RequiresCluster() { |
| 458 | // Setup the state in the config |
| 459 | if d.s == nil { |
| 460 | var err error |
| 461 | d.s, err = setupState(ctx, d.c, opts.Connected) |
| 462 | if err != nil { |
| 463 | return nil, err |
| 464 | } |
| 465 | } |
| 466 | } |
| 467 | |
| 468 | applicationTemplates, err := ptmpl.GetZarfTemplates(ctx, component.Name, d.s) |
| 469 | if err != nil { |
| 470 | return nil, err |
| 471 | } |
| 472 | d.vc.SetApplicationTemplates(applicationTemplates) |
| 473 | |
| 474 | // Populate objects available to templates in before actions |
| 475 | if err := actions.Run(ctx, cwd, onDeploy.Defaults, onDeploy.Before, d.vc, d.vals, template.StateAccess{State: d.s, AccessKeys: component.StateAccess}); err != nil { |
| 476 | return nil, fmt.Errorf("unable to run component before action: %w", err) |
| 477 | } |
| 478 | |
| 479 | if hasFiles { |
| 480 | if err := processComponentFiles(ctx, pkgLayout, component, d.vc, d.vals, template.StateAccess{State: d.s, AccessKeys: component.StateAccess}); err != nil { |
| 481 | return nil, fmt.Errorf("unable to process the component files: %w", err) |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | if hasImages { |
| 486 | refs := []transform.Image{} |
| 487 | for _, img := range component.GetImages() { |
| 488 | ref, err := transform.ParseImageRef(img) |
| 489 | if err != nil { |
| 490 | return nil, fmt.Errorf("failed to create ref for image %s: %w", img, err) |
| 491 | } |
| 492 | refs = append(refs, ref) |
| 493 | } |
| 494 | pushOpts := images.PushOptions{ |
| 495 | OCIConcurrency: opts.OCIConcurrency, |
| 496 | PlainHTTP: opts.PlainHTTP, |
no test coverage detected