-
Couldn't load subscription status.
- Fork 260
Enhance zip-deploy during build for Python/Node #1764
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
Merged
vhvb1989
merged 14 commits into
Azure:main
from
vhvb1989:zip-deploy-enhance-strategy-detection
Mar 23, 2023
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c4a7e72
resolve default after looking at azure.yaml
vhvb1989 7d17634
cl
vhvb1989 0ae2822
fix tests
vhvb1989 01d5a3d
Merge branch 'main' of github.com:Azure/azure-dev
vhvb1989 4fc950d
Merge branch 'main' of github.com:Azure/azure-dev
vhvb1989 adb7229
Merge branch 'main' of github.com:Azure/azure-dev
vhvb1989 4182c62
Merge branch 'main' of github.com:Azure/azure-dev
vhvb1989 c0be074
Merge branch 'main' of github.com:Azure/azure-dev
vhvb1989 12c6e6b
remove internal from project package
vhvb1989 8f255f6
improve exclude files during copying
vhvb1989 b433bcf
lint
vhvb1989 cad2bfe
do not exclude tests
vhvb1989 05d9fdb
Merge branch 'main' of github.com:Azure/azure-dev into zip-deploy-enh…
vhvb1989 b2a230a
rebase
vhvb1989 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -85,6 +85,7 @@ pflag | |
| preinit | ||
| pulumi | ||
| pyapp | ||
| pyvenv | ||
| restoreapp | ||
| retriable | ||
| rzip | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,70 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package project | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
|
|
||
| "github.com/azure/azure-dev/cli/azd/pkg/rzip" | ||
| "github.com/otiai10/copy" | ||
| ) | ||
|
|
||
| // CreateDeployableZip creates a zip file of a folder, recursively. | ||
| // Returns the path to the created zip file or an error if it fails. | ||
| func createDeployableZip(appName string, path string) (string, error) { | ||
vhvb1989 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // TODO: should probably avoid picking up files that weren't meant to be published (ie, local .env files, etc..) | ||
| zipFile, err := os.CreateTemp("", "azddeploy*.zip") | ||
| if err != nil { | ||
| return "", fmt.Errorf("failed when creating zip package to deploy %s: %w", appName, err) | ||
| } | ||
|
|
||
| if err := rzip.CreateFromDirectory(path, zipFile); err != nil { | ||
| // if we fail here just do our best to close things out and cleanup | ||
| zipFile.Close() | ||
| os.Remove(zipFile.Name()) | ||
| return "", err | ||
| } | ||
|
|
||
| if err := zipFile.Close(); err != nil { | ||
| // may fail but, again, we'll do our best to cleanup here. | ||
| os.Remove(zipFile.Name()) | ||
| return "", err | ||
| } | ||
|
|
||
| return zipFile.Name(), nil | ||
| } | ||
|
|
||
| // excludeDirEntryCondition resolves when a file or directory should be considered or not as part of build, when build is a | ||
| // copy-paste source strategy. Return true to exclude the directory entry. | ||
| type excludeDirEntryCondition func(path string, file os.FileInfo) bool | ||
|
|
||
| // buildForZipOptions provides a set of options for doing build for zip | ||
| type buildForZipOptions struct { | ||
| excludeConditions []excludeDirEntryCondition | ||
| } | ||
|
|
||
| // buildForZip is use by projects which build strategy is to only copy the source code into a folder which is later | ||
| // zipped for packaging. For example Python and Node framework languages. buildForZipOptions provides the specific | ||
| // details for each language which should not be ever copied. | ||
| func buildForZip(src, dst string, options buildForZipOptions) error { | ||
|
|
||
| // these exclude conditions applies to all projects | ||
| options.excludeConditions = append(options.excludeConditions, globalExcludeAzdFolder) | ||
|
|
||
| return copy.Copy(src, dst, copy.Options{ | ||
| Skip: func(srcInfo os.FileInfo, src, dest string) (bool, error) { | ||
| for _, checkExclude := range options.excludeConditions { | ||
| if checkExclude(src, srcInfo) { | ||
| return true, nil | ||
| } | ||
| } | ||
| return false, nil | ||
| }, | ||
| }) | ||
| } | ||
|
|
||
| func globalExcludeAzdFolder(path string, file os.FileInfo) bool { | ||
| return file.IsDir() && file.Name() == ".azure" | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.