Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
removing useless functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hihilla committed Jan 19, 2021
1 parent a6b4d1b commit 3829e9f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 31 deletions.
7 changes: 4 additions & 3 deletions cmd/shipperctl/cmd/chart/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package chart

import (
"fmt"
"io/ioutil"
"os"

Expand Down Expand Up @@ -74,9 +75,9 @@ func renderChartFromApp(cmd *cobra.Command, args []string) error {

}

if err := populateFromApp(shipperClient, &c, application); err != nil {
return err
}
c.ReleaseName = fmt.Sprintf("%s-%s-%d", application.Name, "foobar", 0)
c.ChartSpec = application.Spec.Template.Chart
c.ChartValues = application.Spec.Template.Values
rendered, err := render(c)
if err != nil {
return err
Expand Down
10 changes: 8 additions & 2 deletions cmd/shipperctl/cmd/chart/release.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package chart

import (
"github.com/bookingcom/shipper/cmd/shipperctl/config"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/bookingcom/shipper/cmd/shipperctl/config"
)

var (
Expand Down Expand Up @@ -31,9 +33,13 @@ func renderChartFromRel(cmd *cobra.Command, args []string) error {
return err
}

if err := populateFormRelease(shipperClient, &c); err != nil {
rel, err := shipperClient.ShipperV1alpha1().Releases(namespace).Get(releaseName, metav1.GetOptions{})
if err != nil {
return err
}
c.ReleaseName = rel.Name
c.ChartSpec = rel.Spec.Environment.Chart
c.ChartValues = rel.Spec.Environment.Values

rendered, err := render(c)
if err != nil {
Expand Down
30 changes: 4 additions & 26 deletions cmd/shipperctl/cmd/chart/render.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
package chart

import (
"fmt"
"os"
"path/filepath"
"strings"

"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/bookingcom/shipper/cmd/shipperctl/config"
"github.com/bookingcom/shipper/cmd/shipperctl/configurator"
shipper "github.com/bookingcom/shipper/pkg/apis/shipper/v1alpha1"
shipperchart "github.com/bookingcom/shipper/pkg/chart"
"github.com/bookingcom/shipper/pkg/chart/repo"
shipperclientset "github.com/bookingcom/shipper/pkg/client/clientset/versioned"
)

var (
Expand Down Expand Up @@ -75,11 +72,11 @@ func render(c ChartRenderConfig) (string, error) {
func newChartRenderConfig() (ChartRenderConfig, error) {
c := ChartRenderConfig{
}
clientConfig, _, err := configurator.ClientConfig(kubeConfigFile, managementClusterContext)
if err != nil {
return c, err
}
if namespace == "" {
clientConfig, _, err := configurator.ClientConfig(kubeConfigFile, managementClusterContext)
if err != nil {
return c, err
}
namespace, _, err = clientConfig.Namespace()
if err != nil {
return c, err
Expand All @@ -90,25 +87,6 @@ func newChartRenderConfig() (ChartRenderConfig, error) {
return c, nil
}

func populateFormRelease(shipperClient shipperclientset.Interface, c *ChartRenderConfig) error {
rel, err := shipperClient.ShipperV1alpha1().Releases(namespace).Get(releaseName, metav1.GetOptions{})
if err != nil {
return err
}

c.ReleaseName = releaseName
c.ChartSpec = rel.Spec.Environment.Chart
c.ChartValues = rel.Spec.Environment.Values
return nil
}

func populateFromApp(shipperClient shipperclientset.Interface, c *ChartRenderConfig, app shipper.Application) error {
c.ReleaseName = fmt.Sprintf("%s-%s-%d", app.Name, "foobar", 0)
c.ChartSpec = app.Spec.Template.Chart
c.ChartValues = app.Spec.Template.Values
return nil
}

func newFetchChartFunc() repo.ChartFetcher {
stopCh := make(<-chan struct{})

Expand Down
1 change: 1 addition & 0 deletions cmd/shipperctl/cmd/chart/render_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package chart

0 comments on commit 3829e9f

Please sign in to comment.