Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

Commit 60aed92

Browse files
author
aiordache
committed
remove redundant API interface
Signed-off-by: aiordache <[email protected]>
1 parent f09a573 commit 60aed92

File tree

2 files changed

+13
-34
lines changed

2 files changed

+13
-34
lines changed

kube/charts/charts.go

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
package charts
2020

2121
import (
22-
"context"
2322
"os"
2423
"path/filepath"
2524
"strings"
@@ -34,40 +33,20 @@ import (
3433
helmenv "helm.sh/helm/v3/pkg/cli"
3534
)
3635

37-
// API defines management methods for helm charts
38-
type API interface {
39-
GetDefaultEnv() *helmenv.EnvSettings
40-
Connect(ctx context.Context) error
41-
GenerateChart(project *types.Project, dirname string) error
42-
GetChartInMemory(project *types.Project) (*chart.Chart, error)
43-
SaveChart(project *types.Project, dest string) error
44-
45-
Install(project *types.Project) error
46-
Uninstall(projectName string) error
47-
List(projectName string) ([]compose.Stack, error)
48-
}
49-
50-
type sdk struct {
36+
type SDK struct {
5137
h *helm.HelmActions
5238
environment map[string]string
5339
}
5440

55-
// sdk implement API
56-
var _ API = sdk{}
57-
58-
func NewSDK(ctx store.KubeContext) (sdk, error) {
59-
return sdk{
41+
func NewSDK(ctx store.KubeContext) (SDK, error) {
42+
return SDK{
6043
environment: environment(),
6144
h: helm.NewHelmActions(nil),
6245
}, nil
6346
}
6447

65-
func (s sdk) Connect(ctx context.Context) error {
66-
return nil
67-
}
68-
6948
// Install deploys a Compose stack
70-
func (s sdk) Install(project *types.Project) error {
49+
func (s SDK) Install(project *types.Project) error {
7150
chart, err := s.GetChartInMemory(project)
7251
if err != nil {
7352
return err
@@ -76,21 +55,21 @@ func (s sdk) Install(project *types.Project) error {
7655
}
7756

7857
// Uninstall removes a runnign compose stack
79-
func (s sdk) Uninstall(projectName string) error {
58+
func (s SDK) Uninstall(projectName string) error {
8059
return s.h.Uninstall(projectName)
8160
}
8261

8362
// List returns a list of compose stacks
84-
func (s sdk) List(projectName string) ([]compose.Stack, error) {
63+
func (s SDK) List(projectName string) ([]compose.Stack, error) {
8564
return s.h.ListReleases()
8665
}
8766

8867
// GetDefault initializes Helm EnvSettings
89-
func (s sdk) GetDefaultEnv() *helmenv.EnvSettings {
68+
func (s SDK) GetDefaultEnv() *helmenv.EnvSettings {
9069
return helmenv.New()
9170
}
9271

93-
func (s sdk) GetChartInMemory(project *types.Project) (*chart.Chart, error) {
72+
func (s SDK) GetChartInMemory(project *types.Project) (*chart.Chart, error) {
9473
// replace _ with - in volume names
9574
for k, v := range project.Volumes {
9675
volumeName := strings.ReplaceAll(k, "_", "-")
@@ -107,15 +86,15 @@ func (s sdk) GetChartInMemory(project *types.Project) (*chart.Chart, error) {
10786
return helm.ConvertToChart(project.Name, objects)
10887
}
10988

110-
func (s sdk) SaveChart(project *types.Project, dest string) error {
89+
func (s SDK) SaveChart(project *types.Project, dest string) error {
11190
chart, err := s.GetChartInMemory(project)
11291
if err != nil {
11392
return err
11493
}
11594
return util.SaveDir(chart, dest)
11695
}
11796

118-
func (s sdk) GenerateChart(project *types.Project, dirname string) error {
97+
func (s SDK) GenerateChart(project *types.Project, dirname string) error {
11998
if strings.Contains(dirname, ".") {
12099
splits := strings.SplitN(dirname, ".", 2)
121100
dirname = splits[0]

kube/compose.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ import (
3030

3131
// NewComposeService create a kubernetes implementation of the compose.Service API
3232
func NewComposeService(ctx store.KubeContext) (compose.Service, error) {
33-
apiclient, err := charts.NewSDK(ctx)
33+
chartsApi, err := charts.NewSDK(ctx)
3434
if err != nil {
3535
return nil, err
3636
}
3737
return &composeService{
3838
ctx: ctx,
39-
sdk: apiclient,
39+
sdk: chartsApi,
4040
}, nil
4141
}
4242

4343
type composeService struct {
4444
ctx store.KubeContext
45-
sdk charts.API
45+
sdk charts.SDK
4646
}
4747

4848
// Up executes the equivalent to a `compose up`

0 commit comments

Comments
 (0)