-
Notifications
You must be signed in to change notification settings - Fork 114
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
CDS download #3976
CDS download #3976
Conversation
Signed-off-by: Lance Finfrock <[email protected]>
api/external/cds/response/root.proto
Outdated
@@ -20,3 +20,7 @@ message ContentItem { | |||
message InstallContentItem { | |||
|
|||
} | |||
|
|||
message DownloadContentItem { |
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.
Delete this. It is not needed.
Signed-off-by: Lance Finfrock <[email protected]>
Signed-off-by: Lance Finfrock <[email protected]>
Signed-off-by: Lance Finfrock <[email protected]>
Signed-off-by: Lance Finfrock <[email protected]>
@@ -15,6 +15,7 @@ message ContentItem { | |||
string version = 5; | |||
repeated string platforms = 6; | |||
bool can_be_installed = 7; | |||
string filename = 8; |
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.
For a content item, added a filename field so when it is downloaded it can have the correct name.
) | ||
|
||
// Chosen somewhat arbitrarily to be a "good enough" value. | ||
// See: https://github.com/chef/automate/pull/1143#discussion_r170428374 | ||
const streamBufferSize = 262144 |
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.
Copied from
const streamBufferSize = 262144 |
log.Infof("DownloadContentItem: Downloading content item with ID %s ...", request.Id) | ||
|
||
// Get the data | ||
resp, err := http.Get("https://github.com/dev-sec/apache-baseline/archive/master.tar.gz") |
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.
This will later be updated to pull from the SaaS CDS with the token.
|
||
reader := bufio.NewReaderSize(resp.Body, streamBufferSize) | ||
|
||
_, err = reader.WriteTo(writer) |
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.
This streams down and streams up the data. To test this change the streamBufferSize
to 100.
} | ||
w.Write(data.GetContent()) // nolint: errcheck | ||
} | ||
} |
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.
Streaming from automate-cds -> automate-gateway -> client.
@@ -9,7 +9,10 @@ export enum CdsActionTypes { | |||
GET_CONTENT_ITEMS_FAILURE = 'CDS::GET::CONTENT_ITEMS::FAILURE', | |||
INSTALL_CONTENT_ITEM = 'CDS::INSTALL::CONTENT_ITEM', | |||
INSTALL_CONTENT_ITEM_SUCCESS = 'CDS::INSTALL::CONTENT_ITEM::SUCCESS', | |||
INSTALL_CONTENT_ITEM_FAILURE = 'CDS::INSTALL::CONTENT_ITEM::FAILURE' | |||
INSTALL_CONTENT_ITEM_FAILURE = 'CDS::INSTALL::CONTENT_ITEM::FAILURE', |
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.
For all the UI code below. The file is downloaded in the effects file. For an error or success, a message is shown in the banner.
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.
🎉
🔩 Description: What code changed, and why?
When the "download" button is clicked on a content item that item will be downloaded to the browser. This is streaming the file from a third-party source and streaming it to the user's browser.
⛓️ Related Resources
#3899
👟 How to Build and Test the Change
build components/automate-gateway && build components/automate-cds && build components/automate-ui-devproxy && start_all_services && start_automate_ui_background && ui_logs
✅ Checklist