Skip to content

Commit

Permalink
Fix CacheFile
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
  • Loading branch information
ArangoGutierrez committed Jan 8, 2024
1 parent e9bc1f8 commit 9e66797
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions cmd/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ func runProvision(opts *options) error {
}

func createAWS(opts *options) error {
cachefile := filepath.Join(opts.cachePath, opts.cfg.Name+".yaml")
client, err := aws.New(opts.cfg, cachefile)
client, err := aws.New(opts.cfg, opts.cachefile)
if err != nil {
return err
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/provider/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ type Client struct {
Tags []types.Tag
ec2 *ec2.Client
r53 *route53.Client
cachePath string
cacheFile string

*v1alpha1.Environment
}

func New(env v1alpha1.Environment, cachePath string) (*Client, error) {
func New(env v1alpha1.Environment, cacheFile string) (*Client, error) {
// Create an AWS session and configure the EC2 client
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(env.Spec.Region))
if err != nil {
Expand All @@ -97,7 +97,7 @@ func New(env v1alpha1.Environment, cachePath string) (*Client, error) {
},
client,
r53,
cachePath,
cacheFile,
&env,
}

Expand All @@ -109,7 +109,7 @@ func (a *Client) Name() string { return Name }

// unmarsalCache unmarshals the cache file into the AWS struct
func (a *Client) unmarsalCache() (*AWS, error) {
env, err := jyaml.UnmarshalFromFile[v1alpha1.Environment](a.cachePath)
env, err := jyaml.UnmarshalFromFile[v1alpha1.Environment](a.cacheFile)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -162,7 +162,7 @@ func (a *Client) dumpCache(aws *AWS) error {
return err
}

err = os.WriteFile(a.cachePath, data, 0644)
err = os.WriteFile(a.cacheFile, data, 0644)
if err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/provider/aws/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (a *Client) updateStatus(env v1alpha1.Environment, cache *AWS, condition []
return nil
}

return update(envCopy, a.cachePath)
return update(envCopy, a.cacheFile)
}

// update the status of the aws object into a cache file
Expand Down

0 comments on commit 9e66797

Please sign in to comment.