-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCM-7594 | test: Fix proxy realated function
- Loading branch information
1 parent
765ad84
commit 36d29e1
Showing
8 changed files
with
94 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package file | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/openshift-online/ocm-common/pkg/log" | ||
) | ||
|
||
func WriteToFile(content string, fileName string, path ...string) (string, error) { | ||
KeyPath, _ := os.UserHomeDir() | ||
|
||
if len(path) != 0 { | ||
KeyPath = path[0] | ||
} | ||
|
||
filePath := fmt.Sprintf("%s/%s", KeyPath, fileName) | ||
if IfFileExists(filePath) { | ||
err := os.Remove(filePath) | ||
if err != nil { | ||
log.LogInfo("Delete file err:%v", err) | ||
return "", err | ||
} | ||
} | ||
err := os.WriteFile(filePath, []byte(content), 0600) | ||
if err != nil { | ||
log.LogInfo("Write to file err:%v", err) | ||
return "", err | ||
} | ||
return filePath, nil | ||
} | ||
|
||
func IfFileExists(path string) bool { | ||
_, err := os.Stat(path) | ||
if err != nil { | ||
return os.IsExist(err) | ||
} | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters