Fix dev mode for yumrepofs

This commit is contained in:
Mustafa Gezen 2022-11-04 03:26:30 +01:00
parent 26ab9cbdb2
commit 8d2116dfeb
Signed by untrusted user who does not match committer: mustafa
GPG Key ID: DCDF010D946438C1
2 changed files with 11 additions and 2 deletions

View File

@ -60,7 +60,7 @@ func init() {
} }
func mn(_ *cobra.Command, _ []string) { func mn(_ *cobra.Command, _ []string) {
sess, err := utils.NewAwsSession(&aws.Config{}) sess, err := utils.NewAwsSessionNoLocalStack(&aws.Config{})
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }

View File

@ -39,7 +39,7 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
func NewAwsSession(cfg *aws.Config) (*session.Session, error) { func awsConfigInternal(cfg *aws.Config) {
if accessKey := viper.GetString("s3-access-key"); accessKey != "" { if accessKey := viper.GetString("s3-access-key"); accessKey != "" {
cfg.Credentials = credentials.NewStaticCredentials(accessKey, viper.GetString("s3-secret-key"), "") cfg.Credentials = credentials.NewStaticCredentials(accessKey, viper.GetString("s3-secret-key"), "")
} }
@ -63,7 +63,16 @@ func NewAwsSession(cfg *aws.Config) (*session.Session, error) {
if os.Getenv("AWS_REGION") != "" { if os.Getenv("AWS_REGION") != "" {
cfg.Region = aws.String(os.Getenv("AWS_REGION")) cfg.Region = aws.String(os.Getenv("AWS_REGION"))
} }
}
func NewAwsSessionNoLocalStack(cfg *aws.Config) (*session.Session, error) {
awsConfigInternal(cfg)
return session.NewSession(cfg)
}
func NewAwsSession(cfg *aws.Config) (*session.Session, error) {
awsConfigInternal(cfg)
if os.Getenv("LOCALSTACK_ENDPOINT") != "" && os.Getenv("RESF_ENV") == "dev" { if os.Getenv("LOCALSTACK_ENDPOINT") != "" && os.Getenv("RESF_ENV") == "dev" {
cfg.Endpoint = aws.String(os.Getenv("LOCALSTACK_ENDPOINT")) cfg.Endpoint = aws.String(os.Getenv("LOCALSTACK_ENDPOINT"))
cfg.Credentials = credentials.NewStaticCredentials("test", "test", "") cfg.Credentials = credentials.NewStaticCredentials("test", "test", "")