Skip to content

Commit

Permalink
Merge pull request #100 from openebs/tidy-helm-utils
Browse files Browse the repository at this point in the history
chore: tidy: move helm util code
  • Loading branch information
blaisedias authored Dec 2, 2024
2 parents 19cdec1 + fcad90c commit f7d5e9d
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 263 deletions.
248 changes: 0 additions & 248 deletions apps/helm_utils.go

This file was deleted.

12 changes: 12 additions & 0 deletions apps/k8s_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
)

const (
Standalone Architecture = "standalone"
Replicaset Architecture = "replicaset"
Replication Architecture = "replication"
)

type Architecture string

func (a Architecture) String() string {
return string(a)
}

func CreateStorageClass(mb *mongoBuilder) (string, error) {
var err error
var poolsInCluster []common.MayastorPool
Expand Down
10 changes: 5 additions & 5 deletions apps/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ func (mb *mongoBuilder) WithYcsb() *mongoBuilder {
}

func (mb *mongoBuilder) Build() (MongoApp, error) {
var latest Chart
latest, err := GetLatestHelmChartVersion(e2e_config.GetConfig().Product.MongoHelmRepo)
var latest k8stest.Chart
latest, err := k8stest.GetLatestHelmChartVersion(e2e_config.GetConfig().Product.MongoHelmRepo)
if err != nil && mb.helmVersion == "" {
logf.Log.Error(err, "switching to default bitnami/mongo chart version", "defaultChart", e2e_config.GetConfig().Product.MongoDefaultChartVersion)
mb.helmVersion = e2e_config.GetConfig().Product.MongoDefaultChartVersion
Expand All @@ -194,11 +194,11 @@ func (mb *mongoBuilder) Build() (MongoApp, error) {
mb.scName = scName
logf.Log.Info("StorageClass has been created", "storageClassName", scName)
}
err = AddHelmRepository(e2e_config.GetConfig().Product.MongoHelmRepoName, e2e_config.GetConfig().Product.MongoHelmRepoUrl)
err = k8stest.AddHelmRepository(e2e_config.GetConfig().Product.MongoHelmRepoName, e2e_config.GetConfig().Product.MongoHelmRepoUrl)
if err != nil {
return MongoApp{}, err
}
err = InstallHelmChart(e2e_config.GetConfig().Product.MongoHelmRepo, mb.helmVersion, mb.namespace, mb.releaseName, mb.values)
err = k8stest.InstallHelmChart(e2e_config.GetConfig().Product.MongoHelmRepo, mb.helmVersion, mb.namespace, mb.releaseName, mb.values)
if err != nil {
return MongoApp{}, err
}
Expand Down Expand Up @@ -248,7 +248,7 @@ func (mb *mongoBuilder) Build() (MongoApp, error) {
}

func (mb *mongoBuilder) Upgrade(app *MongoApp) (MongoApp, error) {
err := UpgradeHelmChartForValues(e2e_config.GetConfig().Product.MongoHelmRepo, mb.namespace, app.Mongo.ReleaseName, mb.values)
err := k8stest.UpgradeHelmChartForValues(e2e_config.GetConfig().Product.MongoHelmRepo, mb.namespace, app.Mongo.ReleaseName, mb.values)
if err != nil {
return MongoApp{}, err
}
Expand Down
8 changes: 4 additions & 4 deletions apps/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,11 @@ func (pb *postgresBuilder) WithPgBench() *postgresBuilder {
}

func (pb *postgresBuilder) Create() (PostgresApp, error) {
var latest Chart
var latest k8stest.Chart
var err error

if pb.helmVersion == "" {
latest, err = GetLatestHelmChartVersion(e2e_config.GetConfig().Product.PostgresHelmRepo)
latest, err = k8stest.GetLatestHelmChartVersion(e2e_config.GetConfig().Product.PostgresHelmRepo)
if err != nil {
logf.Log.Error(err, "switching to default bitnami/postgresql chart version", "defaultChart", e2e_config.GetConfig().Product.PostgresDefaultChartVersion)
pb.helmVersion = e2e_config.GetConfig().Product.PostgresDefaultChartVersion
Expand Down Expand Up @@ -267,12 +267,12 @@ func (pb *postgresBuilder) Create() (PostgresApp, error) {
}

func (pb *postgresBuilder) Install() error {
err := AddHelmRepository(e2e_config.GetConfig().Product.PostgresHelmRepoName, e2e_config.GetConfig().Product.PostgresHelmRepoUrl)
err := k8stest.AddHelmRepository(e2e_config.GetConfig().Product.PostgresHelmRepoName, e2e_config.GetConfig().Product.PostgresHelmRepoUrl)
if err != nil {
return err
}

err = InstallHelmChart(e2e_config.GetConfig().Product.PostgresHelmRepo, pb.helmVersion, pb.namespace, pb.releaseName, pb.values)
err = k8stest.InstallHelmChart(e2e_config.GetConfig().Product.PostgresHelmRepo, pb.helmVersion, pb.namespace, pb.releaseName, pb.values)
if err != nil {
return err
}
Expand Down
11 changes: 5 additions & 6 deletions common/k8sinstall/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"
"time"

"github.com/openebs/openebs-e2e/apps"
"github.com/openebs/openebs-e2e/common"
"github.com/openebs/openebs-e2e/common/e2e_config"
"github.com/openebs/openebs-e2e/common/k8stest"
Expand Down Expand Up @@ -60,17 +59,17 @@ func installTheProduct() error {
// Helm repository is up-to-date with the latest charts. By removing and re-adding the repository, we make
// sure that the subsequent Helm commands (like `helm install`) interact with the correct and current version
// of the repository.
err = apps.RemoveHelmRepository(e2e_config.GetConfig().Product.OpenEBSHelmRepoName, e2e_config.GetConfig().Product.OpenEBSHelmRepoUrl)
err = k8stest.RemoveHelmRepository(e2e_config.GetConfig().Product.OpenEBSHelmRepoName, e2e_config.GetConfig().Product.OpenEBSHelmRepoUrl)
if err != nil {
logf.Log.Info("failed to remove helm repository")
}

err = apps.AddHelmRepository(e2e_config.GetConfig().Product.OpenEBSHelmRepoName, e2e_config.GetConfig().Product.OpenEBSHelmRepoUrl)
err = k8stest.AddHelmRepository(e2e_config.GetConfig().Product.OpenEBSHelmRepoName, e2e_config.GetConfig().Product.OpenEBSHelmRepoUrl)
if err != nil {
logf.Log.Info("failed to add helm repository")
}

err = apps.UpdateHelmRepository(e2e_config.GetConfig().Product.OpenEBSHelmRepoName)
err = k8stest.UpdateHelmRepository(e2e_config.GetConfig().Product.OpenEBSHelmRepoName)
if err != nil {
logf.Log.Info("failed to update helm repository")
}
Expand Down Expand Up @@ -136,7 +135,7 @@ func ScaleLvmControllerViaHelm(expected_replica int32) (int32, error) {
"lvm-localpv.lvmController.replicas": expected_replica,
}

err = apps.UpgradeHelmChartForValues(e2eCfg.Product.OpenEBSHelmChartName,
err = k8stest.UpgradeHelmChartForValues(e2eCfg.Product.OpenEBSHelmChartName,
common.NSOpenEBS(),
e2eCfg.Product.OpenEBSHelmReleaseName,
values,
Expand Down Expand Up @@ -185,7 +184,7 @@ func ScaleZfsControllerViaHelm(expected_replica int32) (int32, error) {
"zfs-localpv.zfsController.replicas": expected_replica,
}

err = apps.UpgradeHelmChartForValues(e2eCfg.Product.OpenEBSHelmChartName,
err = k8stest.UpgradeHelmChartForValues(e2eCfg.Product.OpenEBSHelmChartName,
common.NSOpenEBS(),
e2eCfg.Product.OpenEBSHelmReleaseName,
values,
Expand Down
Loading

0 comments on commit f7d5e9d

Please sign in to comment.