MCPcopy Create free account
hub / github.com/cloudnative-pg/cloudnative-pg / GetPostgresqlMajorVersion

Method GetPostgresqlMajorVersion

api/v1/cluster_funcs.go:470–489  ·  view source on GitHub ↗

GetPostgresqlMajorVersion gets the PostgreSQL image major version detecting it from the image name or from the ImageCatalogRef.

()

Source from the content-addressed store, hash-verified

468// GetPostgresqlMajorVersion gets the PostgreSQL image major version detecting it from the
469// image name or from the ImageCatalogRef.
470func (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

Callers 15

upgradeSubCommandMethod · 0.95
setDefaultsMethod · 0.95
ReconcileFunction · 0.80
handleRollbackIfNeededFunction · 0.80
BuildPodMonitorMethod · 0.80
CreatePrimaryJobFunction · 0.80
buildInstanceFunction · 0.80
CreateClusterAnyServiceFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected