-
Notifications
You must be signed in to change notification settings - Fork 92
feat: notation plugin install command #827
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
Merged
Changes from all commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
fb763d9
added zip suport
dd75b5d
Merge branch 'notaryproject:main' into plugin-1.1.0
c326db2
added tar.gz support
d19ec82
updated
bf3d6e9
added uninstall
a6379c1
added install from URL
4b5989c
updated
1550236
fix
ea75514
updated
ce9439f
Merge branch 'notaryproject:main' into plugin-1.1.0
236a8aa
notation plugin install
4ae38c8
Merge branch 'notaryproject:main' into plugin-install
3c6ca5f
update
121b783
updated
0743cb0
updated unit tests
932e89a
updated based on spec changes
981cef3
fixed unit tests
e641eb5
e2e tests
7983bd9
fixing e2e tests
56612a6
fixing e2e tests
1c070ee
fixing e2e tests
5d2d27c
fixing e2e tests
26366bc
fixing e2e tests
0e5a109
fixing e2e tests
73d1aeb
fixing e2e tests
4f21480
clean up
e275eab
fix CI
fccef51
added license headers
31a7dc1
updates
5f893dc
fix: fix the license check (#826)
d5a68ee
updates
ff41ceb
fixed tests
320b2e3
updates
f8747a4
updates
c400f10
updates
327172e
updates
ba587a3
updates
93da0fc
updates e2e
5dcb505
updates
3618d4b
fixed bug
1375a85
fix e2e
0145452
updated based on spec
c8d9c51
fixed e2e
364d680
updated based on spec
c045bd5
updated based on spec
129daa0
bump: bump up to go version 1.21 (#833)
84e60aa
updated per code review
125b169
updated per code review
dfbbba4
updated per code review
8cef5eb
doc: update plugin spec (#809)
FeynmanZhou 583ff98
build(deps): Bump github.com/spf13/cobra from 1.7.0 to 1.8.0 (#823)
dependabot[bot] 2624fe7
update
a272fdf
updated per code review
d3ff85a
updated per code review
dbf5adb
fixing unit tests
5031090
fixing e2e tests
b2b66c4
refactored the code
029317b
build(deps): Bump github/codeql-action from 2.22.5 to 2.22.7 (#835)
dependabot[bot] ed93044
Correct broken link to quick start guide (#831)
rcrozean 0d7170a
updated err msg
303dac5
updated dependency
d27414b
chore: update tag to digest (#837)
yizha1 3e07ac8
updated comments
bcb2f5f
resolved conflicts
80f18a7
chore: update references with the tag version (#836)
yizha1 a5e4398
resolved conflicts
30651d5
build(deps): Bump actions/setup-go from 4.1.0 to 5.0.0 (#845)
dependabot[bot] a5fa33f
build(deps): Bump github/codeql-action from 2.22.7 to 2.22.9 (#846)
dependabot[bot] 7550dad
added install from executable file directly
4adfb46
fixing e2e tests
9fdc455
fixing e2e tests
f70f736
fixing e2e tests
9ac03bf
resolved conflicts
4257e06
updated per code review
1357ed3
updated dependency
34be1e1
updated per code review
69b33e0
updated error message
3266871
updated notation-go dependency
9a6bc30
updated func doc
489136a
updated per code review
534199f
updated per code review
0d510bc
updated per code review
0e8b51a
resolved conflicts
a68d098
update
49a3bcb
added printouts to show dowloading plugin from URL
af4b648
fix E2E test
57c6b35
fix E2E test
45788ae
update
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 |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| // Copyright The Notary Project Authors. | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package plugin | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "io" | ||
| "net/http" | ||
| "time" | ||
|
|
||
| "github.com/notaryproject/notation/internal/httputil" | ||
| ) | ||
|
|
||
| // MaxPluginSourceBytes specifies the limit on how many bytes are allowed in the | ||
| // server's response to the download from URL request. | ||
| // | ||
| // The plugin source size must be strictly less than this value. | ||
| var MaxPluginSourceBytes int64 = 256 * 1024 * 1024 // 256 MiB | ||
|
|
||
| // PluginSourceType is an enum for plugin source | ||
| type PluginSourceType int | ||
|
|
||
| const ( | ||
| // PluginSourceTypeFile means plugin source is file | ||
| PluginSourceTypeFile PluginSourceType = 1 + iota | ||
|
|
||
| // PluginSourceTypeURL means plugin source is URL | ||
| PluginSourceTypeURL | ||
| ) | ||
|
|
||
| const ( | ||
| // MediaTypeZip means plugin file is zip | ||
| MediaTypeZip = "application/zip" | ||
|
|
||
| // MediaTypeGzip means plugin file is gzip | ||
| MediaTypeGzip = "application/x-gzip" | ||
| ) | ||
|
|
||
| // DownloadPluginFromURLTimeout is the timeout when downloading plugin from a | ||
| // URL | ||
| const DownloadPluginFromURLTimeout = 10 * time.Minute | ||
|
|
||
| // DownloadPluginFromURL downloads plugin file from url to a tmp directory | ||
| func DownloadPluginFromURL(ctx context.Context, pluginURL string, tmpFile io.Writer) error { | ||
| // Get the data | ||
| client := httputil.NewAuthClient(ctx, &http.Client{Timeout: DownloadPluginFromURLTimeout}) | ||
| req, err := http.NewRequest(http.MethodGet, pluginURL, nil) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| resp, err := client.Do(req) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| defer resp.Body.Close() | ||
| // Check server response | ||
| if resp.StatusCode != http.StatusOK { | ||
| return fmt.Errorf("%s %q: https response bad status: %s", resp.Request.Method, resp.Request.URL, resp.Status) | ||
| } | ||
| // Write the body to file | ||
| lr := &io.LimitedReader{ | ||
| R: resp.Body, | ||
| N: MaxPluginSourceBytes, | ||
| } | ||
| _, err = io.Copy(tmpFile, lr) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if lr.N == 0 { | ||
| return fmt.Errorf("%s %q: https response reaches the %d MiB size limit", resp.Request.Method, resp.Request.URL, MaxPluginSourceBytes) | ||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| return nil | ||
| } | ||
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
Oops, something went wrong.
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.