Skip to content

Commit

Permalink
fix: Fixed baseurl read write issues (#28)
Browse files Browse the repository at this point in the history
* fix: baseurl read write fix

* fix: baseurl read write fix

* fix: removed unused files
  • Loading branch information
devinder-harness authored Jul 19, 2023
1 parent 5f380f8 commit 4694c7b
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 66 deletions.
2 changes: 0 additions & 2 deletions install_scripts/darwin/install.sh

This file was deleted.

2 changes: 0 additions & 2 deletions install_scripts/linux/install.sh

This file was deleted.

2 changes: 1 addition & 1 deletion login.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
func Login(ctx *cli.Context) (err error) {
fmt.Println("Welcome to Harness CLI!")
PromptAccountDetails(ctx)
getAccountDetails(ctx)
saveCredentials(ctx)
getAccountDetails(ctx)
return nil
}
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ func main() {
Usage: "Login with account identifier and api key.",
Flags: globalFlags,
Action: func(context *cli.Context) error {

return cliWrapper(Login, context)
},
Before: func(ctx *cli.Context) error {
Expand Down
15 changes: 9 additions & 6 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ func writeToFile(text string, filename string, overwrite bool) {
func readFromFile(filepath string) (s string) {
var _fileContents = ""

file, fileError := os.OpenFile(filepath, os.O_RDONLY, 0644)
file, _ := os.OpenFile(filepath, os.O_RDONLY, 0644)
defer file.Close()

byteValue, readError := io.ReadAll(file)
if readError != nil {
log.Println("Error reading from file:", fileError)
//log.Println("Error reading from file:", fileError)
}
_fileContents = string(byteValue)

Expand All @@ -102,7 +102,6 @@ func readFromFile(filepath string) (s string) {

func saveCredentials(c *cli.Context) (err error) {
baseURL := c.String("base-url")

if baseURL == "" {
baseURL = cliCdRequestData.BaseUrl
}
Expand All @@ -112,7 +111,7 @@ func saveCredentials(c *cli.Context) (err error) {
authCredentials := SecretStore{
ApiKey: cliCdRequestData.AuthToken,
AccountId: cliCdRequestData.Account,
BaseURL: cliCdRequestData.BaseUrl,
BaseURL: baseURL,
}
jsonObj, err := json.MarshalIndent(authCredentials, "", " ")
if err != nil {
Expand Down Expand Up @@ -152,8 +151,12 @@ func hydrateCredsFromPersistence(params ...interface{}) {
return
}
if hydrateOnlyURL {

cliCdRequestData.BaseUrl = secretstore.BaseURL
baseURL := c.String("base-url")
if baseURL == "" {
cliCdRequestData.BaseUrl = secretstore.BaseURL
} else {
cliCdRequestData.BaseUrl = baseURL
}
} else {
cliCdRequestData.AuthToken = secretstore.ApiKey
cliCdRequestData.Account = secretstore.AccountId
Expand Down
54 changes: 0 additions & 54 deletions workflows/release.yaml

This file was deleted.

0 comments on commit 4694c7b

Please sign in to comment.