GetPostgresqlMajorVersion gets the PostgreSQL image major version detecting it from the image name or from the ImageCatalogRef.
()
| 468 | // GetPostgresqlMajorVersion gets the PostgreSQL image major version detecting it from the |
| 469 | // image name or from the ImageCatalogRef. |
| 470 | func (cluster *Cluster) GetPostgresqlMajorVersion() (int, error) { |
| 471 | if cluster.Spec.ImageCatalogRef != nil { |
| 472 | return cluster.Spec.ImageCatalogRef.Major, nil |
| 473 | } |
| 474 | |
| 475 | if cluster.Spec.ImageName != "" { |
| 476 | imgVersion, err := version.FromTag(reference.New(cluster.Spec.ImageName).Tag) |
| 477 | if err != nil { |
| 478 | return 0, fmt.Errorf("cannot parse image name %q: %w", cluster.Spec.ImageName, err) |
| 479 | } |
| 480 | return int(imgVersion.Major()), nil //nolint:gosec |
| 481 | } |
| 482 | |
| 483 | // Fallback for unit tests where a cluster is created without status or defaults |
| 484 | imgVersion, err := version.FromTag(reference.New(configuration.Current.PostgresImageName).Tag) |
| 485 | if err != nil { |
| 486 | return 0, fmt.Errorf("cannot parse default image name %q: %w", configuration.Current.PostgresImageName, err) |
| 487 | } |
| 488 | return int(imgVersion.Major()), nil //nolint:gosec |
| 489 | } |
| 490 | |
| 491 | // GetImagePullSecret get the name of the pull secret to use |
| 492 | // to download the PostgreSQL image |
no outgoing calls
no test coverage detected