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

Use .oktetoignore in deploy and destroy remote #4316

Merged
merged 3 commits into from
May 27, 2024

Conversation

maroshii
Copy link
Contributor

We now inject rules for destroy and deploy remote a we do for test. This is merged with the contents of .oktetodeployignore file.

Updated docs as part of this: okteto/docs#743

Validation

Create the following folders:

mkdir report-never && echo never > report-never/never
mkdir report-deploy && echo deploy > report-deploy/deploy
mkdir report-destroy && echo destroy > report-destroy/destroy

Using the following .oktetoignore file:

report-never

[deploy]
report-destroy

[destroy]
report-deploy

with an ls in the deploy and destroy sections:

deploy:
  - ls

destroy:
  - ls

For deploy we should only get report-deploy and for destroy we should only get report-destroy

@maroshii maroshii requested a review from a team as a code owner May 23, 2024 15:46
Copy link

codecov bot commented May 23, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 43.10%. Comparing base (c09877c) to head (13799ee).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4316      +/-   ##
==========================================
- Coverage   43.10%   43.10%   -0.01%     
==========================================
  Files         371      371              
  Lines       30021    30042      +21     
==========================================
+ Hits        12940    12949       +9     
- Misses      15954    15960       +6     
- Partials     1127     1133       +6     

Copy link
Member

@ifbyol ifbyol left a comment

Choose a reason for hiding this comment

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

If both files are defined, we are merging both, which I think it is misleading. If the new file is defined, it should mean that users are migrated to new file, so I don't think we should keep taking into account .oktetodeployignore.

WDYT @pchico83 @codyjlandstrom ?

@@ -483,7 +473,7 @@ func createDockerignoreFileWithFilesystem(cwd, tmpDir string, rules []string, us
if !errors.Is(err, os.ErrNotExist) {
return err
}

oktetoLog.Warning("Ignoring files through %s is deprecated and will be removed in future versions. Please use .oktetoignore. More info here: https://www.okteto.com/docs/core/remote-execution/#ignoring-files", oktetoDockerignoreName)
Copy link
Member

Choose a reason for hiding this comment

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

I think this warning is not located in the right place. We are adding the warning if .oktetodeployignore file doesn't exist in the working directory instead of showing it if it exists

Screenshot 2024-05-24 at 20 47 56

As you can see if the screenshot, there is a .oktetodeployignore file but the warning is not present. If I run the command without that file, the warning is displayed

if err != nil {
return "", err
}
manifestPathDir := filepath.Dir(filepath.Clean(fmt.Sprintf("/%s", manifestPath)))
Copy link
Member

Choose a reason for hiding this comment

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

Does this work on windows? (referring to /%s)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume that's what Clean is for. I simply moved this function to be a global in this package (it was previously a member of runner).

From Clean docs:

On Windows, Clean does not modify the volume name other than to replace occurrences of "/" with \.
For example, Clean("//host/share/../x") returns \\host\share\x.

@pchico83
Copy link
Contributor

If both files are defined, we are merging both, which I think it is misleading. If the new file is defined, it should mean that users are migrated to new file, so I don't think we should keep taking into account .oktetodeployignore.

WDYT @pchico83 @codyjlandstrom ?

Both options sound good to me. But for simplicity, I would also go with one file or the other, without merging tham

Copy link
Contributor

@andreafalzetti andreafalzetti left a comment

Choose a reason for hiding this comment

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

Code changes LGTM. I've also tested the scenario described and it works both on Mac and Windows.

As already mentioned the warning for .oktetodeployignore appears when I don't have it, and it should be fixed before merging.

About the "merge" vs "override" I think both options are good, I defer to Product the final call, however I would go for now with the current implementation as it's good, and we can just drop the support for the old format in the future.

@maroshii
Copy link
Contributor Author

I think what we have is ok (merging) until we fully deprecate the old file. User could be using .oktetoignore only for okteto test and not for deploy in which case no rules would be included.

@pchico83
Copy link
Contributor

I think what we have is ok (merging) until we fully deprecate the old file. User could be using .oktetoignore only for okteto test and not for deploy in which case no rules would be included.

@maroshii SGTM

@maroshii maroshii merged commit f7c5a22 into master May 27, 2024
11 of 12 checks passed
@maroshii maroshii deleted the fran/oktetoignore-deploy-destroy branch May 27, 2024 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants