(ctx context.Context, pkgLayout *layout.PackageLayout, component v1alpha1.ZarfComponent, opts DeployOptions)
| 347 | } |
| 348 | |
| 349 | func (d *deployer) deployInitComponent(ctx context.Context, pkgLayout *layout.PackageLayout, component v1alpha1.ZarfComponent, opts DeployOptions) ([]state.InstalledChart, error) { |
| 350 | l := logger.From(ctx) |
| 351 | isSeedRegistry := component.Name == "zarf-seed-registry" |
| 352 | isRegistry := component.Name == "zarf-registry" |
| 353 | isInjector := component.Name == "zarf-injector" |
| 354 | isAgent := component.Name == "zarf-agent" |
| 355 | |
| 356 | // Always init the state before the first component that requires the cluster (on most deployments, the zarf-seed-registry) |
| 357 | if component.RequiresCluster() && d.s == nil { |
| 358 | applianceMode := false |
| 359 | for _, component := range pkgLayout.Pkg.Components { |
| 360 | if component.Name == "k3s" { |
| 361 | applianceMode = true |
| 362 | } |
| 363 | } |
| 364 | var err error |
| 365 | d.s, err = d.c.InitState(ctx, cluster.InitStateOptions{ |
| 366 | GitServer: opts.GitServer, |
| 367 | RegistryInfo: opts.RegistryInfo, |
| 368 | ArtifactServer: opts.ArtifactServer, |
| 369 | ApplianceMode: applianceMode, |
| 370 | StorageClass: opts.StorageClass, |
| 371 | InjectorPort: opts.InjectorPort, |
| 372 | AgentTLS: opts.AgentTLS, |
| 373 | AgentMutationPolicy: opts.AgentMutationPolicy, |
| 374 | InternalServices: internalServicesFor(pkgLayout.Pkg.Components, opts), |
| 375 | }) |
| 376 | if err != nil { |
| 377 | return nil, fmt.Errorf("unable to initialize Zarf state: %w", err) |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | if d.s != nil { |
| 382 | if !d.s.RegistryInfo.IsInternal() && (isSeedRegistry || isInjector || isRegistry) { |
| 383 | l.Info("skipping init package component since external registry information was provided", "component", component.Name) |
| 384 | return nil, nil |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | // Before deploying the seed registry, start the injector |
| 389 | if isSeedRegistry { |
| 390 | switch d.s.RegistryInfo.RegistryMode { |
| 391 | case state.RegistryModeProxy: |
| 392 | var err error |
| 393 | d.s.InjectorInfo.Image, err = d.c.GetInjectorDaemonsetImage(ctx) |
| 394 | if err != nil { |
| 395 | return nil, err |
| 396 | } |
| 397 | |
| 398 | payloadCMs, shasum, err := d.c.CreateInjectorConfigMaps(ctx, pkgLayout.DirPath(), pkgLayout.GetImageDirPath(), component.GetImages(), pkgLayout.Pkg.Metadata.Name) |
| 399 | if err != nil { |
| 400 | return nil, err |
| 401 | } |
| 402 | d.s.InjectorInfo.PayLoadConfigMapAmount = len(payloadCMs) |
| 403 | d.s.InjectorInfo.PayLoadShaSum = shasum |
| 404 | case state.RegistryModeNodePort: |
| 405 | seedImage, seedPort, err := d.c.StartInjection(ctx, pkgLayout.DirPath(), pkgLayout.GetImageDirPath(), component.GetImages(), pkgLayout.Pkg.Metadata.Name, pkgLayout.Pkg.Metadata.Architecture, cluster.ZarfInjectorOptions{ |
| 406 | InjectorNodePort: uint16(d.s.InjectorInfo.Port), |
no test coverage detected