Skip to content

Commit

Permalink
Remove k8s trim (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
adelinag08 authored Mar 7, 2024
1 parent 67d5c5d commit 2efd96f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 0 additions & 4 deletions pkg/cmd/spark/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"github.com/SneaksAndData/esd-services-api-client-go/spark"
"github.com/spf13/cobra"
"snd-cli/pkg/cmdutil"
"strings"
)

var name string
Expand All @@ -15,9 +14,6 @@ func NewCmdConfiguration(authServiceFactory *cmdutil.AuthServiceFactory, service
Use: "configuration",
Short: "Get a deployed SparkJob configuration",
RunE: func(cmd *cobra.Command, args []string) error {
if strings.HasPrefix(authProvider, "k8s") {
authProvider = strings.TrimPrefix("k8s-", authProvider)
}
authService, err := cmdutil.InitializeAuthService(url, env, authProvider, *authServiceFactory)
if err != nil {
return err
Expand Down
9 changes: 8 additions & 1 deletion pkg/cmd/util/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os"
"path"
"path/filepath"
)

Expand Down Expand Up @@ -36,7 +37,7 @@ func (f File) IsValidPath() bool {

// CreateDirectory creates a directory by using the specified path.
func (f File) CreateDirectory() error {
err := os.MkdirAll(f.FilePath, 0755) // Use MkdirAll to simplify
err := os.MkdirAll(path.Dir(f.FilePath), 0755) // Use MkdirAll to simplify
if err != nil {
return fmt.Errorf("failed to create directory: %w", err)
}
Expand All @@ -45,6 +46,12 @@ func (f File) CreateDirectory() error {

// WriteToFile writes data to the specified file path.
func (f File) WriteToFile(data string) error {
if !f.IsValidPath() {
err := f.CreateDirectory()
if err != nil {
return err
}
}
file, err := os.OpenFile(f.FilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
return fmt.Errorf("failed to open file: %w", err)
Expand Down

0 comments on commit 2efd96f

Please sign in to comment.