From f30761ee0dae1d80a8554a791faa6ac500589e23 Mon Sep 17 00:00:00 2001 From: Shoubhik Bose Date: Fri, 18 Dec 2020 15:59:52 -0500 Subject: [PATCH] remove unused code Signed-off-by: Shoubhik Bose --- pkg/action/action_test.go | 35 ----------------------------- pkg/action/install.go | 47 --------------------------------------- 2 files changed, 82 deletions(-) diff --git a/pkg/action/action_test.go b/pkg/action/action_test.go index fedf260fb..89aa17f6a 100644 --- a/pkg/action/action_test.go +++ b/pkg/action/action_test.go @@ -114,32 +114,6 @@ var manifestWithTestHook = `kind: Pod cmd: fake-command ` -var rbacManifests = `apiVersion: rbac.authorization.k8s.io/v1 -kind: Role -metadata: - name: schedule-agents -rules: -- apiGroups: [""] - resources: ["pods", "pods/exec", "pods/log"] - verbs: ["*"] - ---- - -apiVersion: rbac.authorization.k8s.io/v1 -kind: RoleBinding -metadata: - name: schedule-agents - namespace: {{ default .Release.Namespace}} -roleRef: - apiGroup: rbac.authorization.k8s.io - kind: Role - name: schedule-agents -subjects: -- kind: ServiceAccount - name: schedule-agents - namespace: {{ .Release.Namespace }} -` - type chartOptions struct { *chart.Chart } @@ -247,15 +221,6 @@ func withSampleIncludingIncorrectTemplates() chartOption { } } -func withMultipleManifestTemplate() chartOption { - return func(opts *chartOptions) { - sampleTemplates := []*chart.File{ - {Name: "templates/rbac", Data: []byte(rbacManifests)}, - } - opts.Templates = append(opts.Templates, sampleTemplates...) - } -} - func withKube(version string) chartOption { return func(opts *chartOptions) { opts.Metadata.KubeVersion = version diff --git a/pkg/action/install.go b/pkg/action/install.go index 4de0b64e6..7f8880e1d 100644 --- a/pkg/action/install.go +++ b/pkg/action/install.go @@ -21,7 +21,6 @@ import ( "fmt" "io/ioutil" "os" - "path" "path/filepath" "strings" "text/template" @@ -63,8 +62,6 @@ const releaseNameMaxLen = 53 // since there can be filepath in front of it. const notesFileSuffix = "NOTES.txt" -const defaultDirectoryPermission = 0755 - // Install performs an installation operation. type Install struct { cfg *Configuration @@ -485,50 +482,6 @@ func (i *Install) replaceRelease(rel *release.Release) error { return i.recordRelease(last) } -// write the to /. controls if the file is created or content will be appended -func writeToFile(outputDir string, name string, data string, append bool) error { - outfileName := strings.Join([]string{outputDir, name}, string(filepath.Separator)) - - err := ensureDirectoryForFile(outfileName) - if err != nil { - return err - } - - f, err := createOrOpenFile(outfileName, append) - if err != nil { - return err - } - - defer f.Close() - - _, err = f.WriteString(fmt.Sprintf("---\n# Source: %s\n%s\n", name, data)) - - if err != nil { - return err - } - - fmt.Printf("wrote %s\n", outfileName) - return nil -} - -func createOrOpenFile(filename string, append bool) (*os.File, error) { - if append { - return os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, 0600) - } - return os.Create(filename) -} - -// check if the directory exists to create file. creates if don't exists -func ensureDirectoryForFile(file string) error { - baseDir := path.Dir(file) - _, err := os.Stat(baseDir) - if err != nil && !os.IsNotExist(err) { - return err - } - - return os.MkdirAll(baseDir, defaultDirectoryPermission) -} - // NameAndChart returns the name and chart that should be used. // // This will read the flags and handle name generation if necessary.