-
Notifications
You must be signed in to change notification settings - Fork 612
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
Conversation
Unit tests are failing on windows because file path delimiter is "\" not "/". |
// 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) |
There was a problem hiding this comment.
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))) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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))) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
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.