Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

envfiles: create directory where the envfile will be written #2407

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

jy19
Copy link
Contributor

@jy19 jy19 commented Mar 25, 2020

Summary

creates the directories for where environment files will be written

Implementation details

Testing

make test successful - running agent locally i can see the envfiles are created.

New tests cover the changes: yes

Description for the changelog

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@yhlee-aws
Copy link
Contributor

yhlee-aws commented Mar 26, 2020

Unit tests are failing on windows because file path delimiter is "\" not "/".
Use string(filepath.Separator)

@yhlee-aws yhlee-aws self-requested a review March 26, 2020 04:32
// createEnvfileDirectory creates the directory that we will be writing the
// envfile to - needs to be called for each different bucket
func (envfile *EnvironmentFileResource) createEnvfileDirectory(bucket string) error {
envfileDir := filepath.Join(envfile.resourceDir, bucket)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to include key as subdirectory path too

// envfile to - needs to be called for each different envfile
func (envfile *EnvironmentFileResource) createEnvfileDirectory(bucket, key string) error {
// create directories to include bucket and key but not the actual resulting file
envfileDir := filepath.Join(envfile.resourceDir, bucket, strings.TrimRight(key, string(filepath.Separator)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use filepath.Dir instead of strings.TrimRight.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

// envfile to - needs to be called for each different envfile
func (envfile *EnvironmentFileResource) createEnvfileDirectory(bucket, key string) error {
// create directories to include bucket and key but not the actual resulting file
envfileDir := filepath.Join(envfile.resourceDir, bucket, strings.TrimRight(key, string(filepath.Separator)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@@ -129,10 +130,12 @@ func TestCreateWithEnvVarFile(t *testing.T) {
},
}

envDirectories := filepath.Join(resourceDir, s3Bucket)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should test s3Key being more than just the file name, to test that we are creating all the subdirectories correctly. And for verification, I wouldn't use the same api as what the code we are trying to test is using, but instead of known fixed value.

@jy19 jy19 merged commit 986b8ac into aws:env_files Mar 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants