Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support to accept values file #161

Merged
merged 4 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: refine helm package
1. Rename helm.Manager to helm.Loader;

2. Add 'pkg/helm/values*" to make values operation more flexiable;

3. Update unit test cases;

Signed-off-by: zyy17 <zyylsxm@gmail.com>
  • Loading branch information
zyy17 committed Oct 9, 2023
commit 088282be4bcfba19d6a51fa2fb0db928d6d47caf
49 changes: 38 additions & 11 deletions pkg/deployer/k8s/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import (
)

type deployer struct {
helmManager *helm.Manager
client *kube.Client
timeout time.Duration
logger logger.Logger
dryRun bool
helmLoader *helm.Loader
client *kube.Client
timeout time.Duration
logger logger.Logger
dryRun bool
}

const (
Expand All @@ -46,14 +46,14 @@ var _ Interface = &deployer{}
type Option func(*deployer)

func NewDeployer(l logger.Logger, opts ...Option) (Interface, error) {
hm, err := helm.NewManager(l)
hc, err := helm.NewLoader(l)
if err != nil {
return nil, err
}

d := &deployer{
helmManager: hm,
logger: l,
helmLoader: hc,
logger: l,
}

for _, opt := range opts {
Expand Down Expand Up @@ -127,7 +127,16 @@ func (d *deployer) CreateGreptimeDBCluster(ctx context.Context, name string, opt
options.ConfigValues += fmt.Sprintf("image.registry=%s,initializer.registry=%s,", AliCloudRegistry, AliCloudRegistry)
}

manifests, err := d.helmManager.LoadAndRenderChart(ctx, resourceName, resourceNamespace, artifacts.GreptimeDBChartName, options.GreptimeDBChartVersion, options.UseGreptimeCNArtifacts, *options)
opts := &helm.LoadOptions{
ReleaseName: resourceName,
Namespace: resourceNamespace,
ChartName: artifacts.GreptimeDBChartName,
ChartVersion: options.GreptimeDBChartVersion,
FromCNRegion: options.UseGreptimeCNArtifacts,
ValuesOptions: *options,
EnableCache: true,
}
manifests, err := d.helmLoader.LoadAndRenderChart(ctx, opts)
if err != nil {
return err
}
Expand Down Expand Up @@ -186,7 +195,16 @@ func (d *deployer) CreateEtcdCluster(ctx context.Context, name string, options *
options.ConfigValues += fmt.Sprintf("image.registry=%s,", AliCloudRegistry)
}

manifests, err := d.helmManager.LoadAndRenderChart(ctx, resourceName, resourceNamespace, artifacts.EtcdChartName, artifacts.DefaultEtcdChartVersion, options.UseGreptimeCNArtifacts, *options)
opts := &helm.LoadOptions{
ReleaseName: resourceName,
Namespace: resourceNamespace,
ChartName: artifacts.EtcdChartName,
ChartVersion: artifacts.DefaultEtcdChartVersion,
FromCNRegion: options.UseGreptimeCNArtifacts,
ValuesOptions: *options,
EnableCache: true,
}
manifests, err := d.helmLoader.LoadAndRenderChart(ctx, opts)
if err != nil {
return fmt.Errorf("error while loading helm chart: %v", err)
}
Expand Down Expand Up @@ -222,7 +240,16 @@ func (d *deployer) CreateGreptimeDBOperator(ctx context.Context, name string, op
options.ConfigValues += fmt.Sprintf("image.registry=%s,", AliCloudRegistry)
}

manifests, err := d.helmManager.LoadAndRenderChart(ctx, resourceName, resourceNamespace, artifacts.GreptimeDBOperatorChartName, options.GreptimeDBOperatorChartVersion, options.UseGreptimeCNArtifacts, *options)
opts := &helm.LoadOptions{
ReleaseName: resourceName,
Namespace: resourceNamespace,
ChartName: artifacts.GreptimeDBOperatorChartName,
ChartVersion: options.GreptimeDBOperatorChartVersion,
FromCNRegion: options.UseGreptimeCNArtifacts,
ValuesOptions: *options,
EnableCache: true,
}
manifests, err := d.helmLoader.LoadAndRenderChart(ctx, opts)
if err != nil {
return err
}
Expand Down
207 changes: 0 additions & 207 deletions pkg/helm/helm_test.go

This file was deleted.

Loading