-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor code into ui package
- Loading branch information
Showing
17 changed files
with
243 additions
and
122 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 was deleted.
Oops, something went wrong.
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,54 @@ | ||
package ui | ||
|
||
import ( | ||
"context" | ||
"os" | ||
|
||
"github.com/aws/aws-sdk-go-v2/aws" | ||
|
||
"github.com/aws/aws-sdk-go-v2/config" | ||
"github.com/aws/aws-sdk-go-v2/service/cloudformation" | ||
) | ||
|
||
func GetAWSConfigKey(stack Stack) string { | ||
return stack.AwsProfile + ":" + stack.AwsRegion | ||
} | ||
|
||
func GetAWSConfig(profile string, region string) (aws.Config, error) { | ||
if profile == "default" { | ||
cfg, err := config.LoadDefaultConfig(context.TODO(), | ||
config.WithRegion(region)) | ||
return cfg, err | ||
} else { | ||
cfg, err := config.LoadDefaultConfig(context.TODO(), | ||
config.WithRegion(region), | ||
config.WithSharedConfigProfile(profile)) | ||
return cfg, err | ||
} | ||
} | ||
|
||
func CheckStackSyncStatus(awsConfig AwsConfig, stack Stack) StackSyncResult { | ||
if awsConfig.Err != nil { | ||
return StackSyncResult{stack, "", false, awsConfig.Err} | ||
} | ||
|
||
svc := cloudformation.NewFromConfig(awsConfig.Config) | ||
|
||
templateInput := cloudformation.GetTemplateInput{ | ||
StackName: &stack.Name, | ||
} | ||
templOut, err := svc.GetTemplate(context.TODO(), &templateInput) | ||
if err != nil { | ||
return StackSyncResult{stack, "", false, err} | ||
} | ||
|
||
templBody := *templOut.TemplateBody | ||
|
||
localFile, err := os.ReadFile(stack.Local) | ||
if err != nil { | ||
return StackSyncResult{stack, "", false, err} | ||
} | ||
localFileContent := string(localFile) | ||
outtaSync := localFileContent != templBody | ||
return StackSyncResult{stack, templBody, outtaSync, err} | ||
} |
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
Oops, something went wrong.