-
Notifications
You must be signed in to change notification settings - Fork 64
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
Create a download-starter-project
endpoint in the registry
.
#720
Comments
This new feature introduces a new endpoint |
Part of the Implementation 1func fetchDevfile(devfileName string) ([]byte, error) {
...
} This implementation does not take the func serveDevfileStarterProject(c *gin.Context) {
...
devfileBytes, err := fetchDevfile(devfileName)
if err != nil {
log.Print(err.Error())
c.JSON(http.StatusInternalServerError, gin.H{
"error": err.Error(),
"status": fmt.Sprintf("failed to pull the devfile of %s", devfileName),
})
return
} else if len(devfileBytes) == 0 {
c.JSON(http.StatusNotFound, gin.H{
"status": fmt.Sprintf("the devfile of %s didn't exist", devfileName),
})
return
}
...
} This implementation makes the process simple but limits the status outcomes to as they are currently. If this poses a problem to future changes I have purposed Implementation 2 as an alternative. The devfile Implementation 2func fetchDevfile(c *gin.Context, devfileName string) []byte {
...
} This implementation consists most of the source from |
Implementation 2 for func fetchDevfile(c *gin.Context, devfileName string) ([]byte, indexSchema.Schema) {
...
} |
Closed issue #750 provides the following for getting the selected starterproject download location from the devfile contents: filterOptions := common.DevfileOptions{
FilterByName: starterProjectName,
}
...
starterProjects, err = content.Data.GetStarterProjects(filterOptions) |
@michael-valdron I want to raise up your attention that for the filter, if no such object fulfills all the filter conditions, it will just return an empty list, without any errors. The same behavior applies to name filter as well. |
@yangcao77 Perfect, thanks letting know. I will use this as one of the conditions which produces the Not Found response for the endpoint: if len(starterProjects) == 0 {
c.JSON(http.StatusNotFound, gin.H{
"status": fmt.Sprintf("the starter project named %s does not exist in the devfile of %s", starterProjectName, devfileName),
})
} |
Since the index generated is with the new format, the starterProject endpoints need to look for a version, (version string or |
commit 40b70ab Merge: 655c290 018c568 Author: Michael Valdron <[email protected]> Date: Tue Mar 1 15:31:08 2022 -0500 fixed merge conflicts commit 655c290 Merge: 3f4fb80 7a90a42 Author: Michael Valdron <[email protected]> Date: Thu Feb 24 21:24:37 2022 -0500 Merge branch 'main' into addDownloadStarterProject commit 3f4fb80 Author: Michael Valdron <[email protected]> Date: Thu Feb 17 18:13:18 2022 -0500 starter project download git source changed to use index/generator functions. commit 7170750 Author: Michael Valdron <[email protected]> Date: Thu Feb 17 18:12:14 2022 -0500 dependency updates. commit 9f72032 Author: Stephanie <[email protected]> Date: Tue Feb 15 16:21:24 2022 -0500 add util.go for download from git Signed-off-by: Stephanie <[email protected]> commit a86df62 Author: Michael Valdron <[email protected]> Date: Fri Feb 11 16:52:06 2022 -0500 remove https from git url. commit 40cde78 Author: Michael Valdron <[email protected]> Date: Fri Feb 11 15:01:28 2022 -0500 Read archive bytes for zip urls fixed. Fixed ContentType set in response. commit ce2090e Author: Michael Valdron <[email protected]> Date: Fri Feb 11 14:01:31 2022 -0500 golang image tag updated from alpine3.11 to alpine3.15 commit 1ce4615 Author: Michael Valdron <[email protected]> Date: Thu Feb 10 16:51:52 2022 -0500 Removed commented out source of fetchDevfile impl 1 (unused). commit 4edf10a Author: Michael Valdron <[email protected]> Date: Thu Feb 10 16:50:37 2022 -0500 source added for downloading starter project from zip url and git repository (root, remote -> origin) commit ef946e8 Author: Michael Valdron <[email protected]> Date: Thu Feb 10 16:48:05 2022 -0500 Dependency go-getter added for downloading starter projects using git as a source and with subDir set. commit 8ca0364 Author: Michael Valdron <[email protected]> Date: Wed Feb 9 11:29:57 2022 -0500 added missing return statements to error condition blocks. commit 95c39f7 Merge: e8852e3 723fa9c Author: Michael Valdron <[email protected]> Date: Wed Feb 9 11:20:49 2022 -0500 Merge branch 'main' into addDownloadStarterProject commit e8852e3 Author: Michael Valdron <[email protected]> Date: Tue Feb 8 19:50:42 2022 -0500 param key change in index.go applied to serveStarterProjects endpoint. Control logic for starter project download methods added. commit 768f0cb Author: Michael Valdron <[email protected]> Date: Tue Feb 8 19:43:50 2022 -0500 serveStarterProjects endpoint key :devfileName changed to :name to match serveDevfile endpoint pattern. commit ff614c5 Author: Michael Valdron <[email protected]> Date: Mon Feb 7 18:03:34 2022 -0500 dependency updates: go v1.14->v1.17, gin v1.6.3->v1.7.7, github.com/deislabs/oras v0.8.1->oras.land/oras-go v0.4.0 commit 9a5b40f Merge: 0d01cd3 6566c05 Author: Michael Valdron <[email protected]> Date: Mon Feb 7 14:13:55 2022 -0500 Merge branch 'addDownloadStarterProject' of github:michael-valdron/registry-support into addDownloadStarterProject commit 0d01cd3 Author: Michael Valdron <[email protected]> Date: Fri Jan 28 17:29:35 2022 -0500 fetchDevfile now returns the devfile's index schema for telemetry data. commit 40db91a Author: Michael Valdron <[email protected]> Date: Fri Jan 28 16:44:44 2022 -0500 Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at: devfile/api#720 commit 336153a Author: Michael Valdron <[email protected]> Date: Tue Feb 1 16:52:43 2022 -0500 filtering added using temp iteration and control logic, filter options commented out until new release of library. commit f25e6b8 Author: Michael Valdron <[email protected]> Date: Tue Feb 1 11:25:03 2022 -0500 library dependency added. commit de05073 Author: Michael Valdron <[email protected]> Date: Mon Jan 31 20:58:45 2022 -0500 get starter project entity source added. commit c0a0f6e Author: Michael Valdron <[email protected]> Date: Fri Jan 28 17:29:35 2022 -0500 fetchDevfile now returns the devfile's index schema for telemetry data. commit ac4f605 Author: Michael Valdron <[email protected]> Date: Fri Jan 28 16:44:44 2022 -0500 Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at: devfile/api#720 commit 8dd8c1c Author: Michael Valdron <[email protected]> Date: Thu Jan 27 17:34:18 2022 -0500 fixed up some return statements and flow control for fetching a devfile. commit d5aba7a Author: Michael Valdron <[email protected]> Date: Thu Jan 20 16:54:50 2022 -0500 serveDevfileStarterProject endpoint definitions added. commit 7b8e5ac Author: Michael Valdron <[email protected]> Date: Wed Jan 26 19:21:38 2022 -0500 draft proposal function source added. commit 6b44b81 Author: Michael Valdron <[email protected]> Date: Wed Jan 26 19:20:21 2022 -0500 endpoint URL format changes. commit 0de93f6 Author: Michael Valdron <[email protected]> Date: Thu Jan 20 16:54:50 2022 -0500 serveDevfileStarterProject endpoint definitions added. commit 2dd0890 Author: Michael Valdron <[email protected]> Date: Thu Jan 20 16:46:08 2022 -0500 reorganized util package import in index.go commit 6566c05 Merge: 65dcb66 f96264a Author: Michael Valdron <[email protected]> Date: Mon Feb 7 13:58:12 2022 -0500 Merge branch 'addDownloadStarterProject' of github:michael-valdron/registry-support into addDownloadStarterProject commit 65dcb66 Author: Michael Valdron <[email protected]> Date: Fri Jan 28 17:29:35 2022 -0500 fetchDevfile now returns the devfile's index schema for telemetry data. commit 9c10f03 Author: Michael Valdron <[email protected]> Date: Fri Jan 28 16:44:44 2022 -0500 Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at: devfile/api#720 commit f96264a Merge: 3d7a869 e0351de Author: Michael Valdron <[email protected]> Date: Mon Feb 7 13:51:24 2022 -0500 Merge branch 'addDownloadStarterProject' of github:michael-valdron/registry-support into addDownloadStarterProject commit 3d7a869 Author: Michael Valdron <[email protected]> Date: Tue Feb 1 16:52:43 2022 -0500 filtering added using temp iteration and control logic, filter options commented out until new release of library. commit 8cdd723 Author: Michael Valdron <[email protected]> Date: Tue Feb 1 11:25:03 2022 -0500 library dependency added. commit 476e7c6 Author: Michael Valdron <[email protected]> Date: Mon Jan 31 20:58:45 2022 -0500 get starter project entity source added. commit 9843452 Author: Michael Valdron <[email protected]> Date: Fri Jan 28 17:29:35 2022 -0500 fetchDevfile now returns the devfile's index schema for telemetry data. commit b6658b8 Author: Michael Valdron <[email protected]> Date: Fri Jan 28 16:44:44 2022 -0500 Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at: devfile/api#720 commit c0a9685 Author: Michael Valdron <[email protected]> Date: Thu Jan 27 17:34:18 2022 -0500 fixed up some return statements and flow control for fetching a devfile. commit 5da0574 Author: Michael Valdron <[email protected]> Date: Thu Jan 20 16:54:50 2022 -0500 serveDevfileStarterProject endpoint definitions added. commit e0351de Author: Michael Valdron <[email protected]> Date: Tue Feb 1 16:52:43 2022 -0500 filtering added using temp iteration and control logic, filter options commented out until new release of library. commit 94e64ea Author: Michael Valdron <[email protected]> Date: Tue Feb 1 11:25:03 2022 -0500 library dependency added. commit 99cbed9 Author: Michael Valdron <[email protected]> Date: Mon Jan 31 20:58:45 2022 -0500 get starter project entity source added. commit 2ca9308 Author: Michael Valdron <[email protected]> Date: Fri Jan 28 17:29:35 2022 -0500 fetchDevfile now returns the devfile's index schema for telemetry data. commit 2bb8eb9 Author: Michael Valdron <[email protected]> Date: Fri Jan 28 16:44:44 2022 -0500 Implementation 2 for fetchDevfile chosen and added. See Issue #720 discussion at: devfile/api#720 commit 6ee2896 Author: Michael Valdron <[email protected]> Date: Thu Jan 27 17:34:18 2022 -0500 fixed up some return statements and flow control for fetching a devfile. commit b768325 Merge: 6bd6809 4e3a233 Author: Michael Valdron <[email protected]> Date: Wed Jan 26 19:23:38 2022 -0500 fixed merge conflicts. commit 6bd6809 Author: Michael Valdron <[email protected]> Date: Wed Jan 26 19:21:38 2022 -0500 draft proposal function source added. commit 0ed5d25 Author: Michael Valdron <[email protected]> Date: Wed Jan 26 19:20:21 2022 -0500 endpoint URL format changes. commit b119a18 Author: Michael Valdron <[email protected]> Date: Thu Jan 20 16:54:50 2022 -0500 serveDevfileStarterProject endpoint definitions added. commit 1bac181 Author: Michael Valdron <[email protected]> Date: Thu Jan 20 16:46:08 2022 -0500 reorganized util package import in index.go commit 4e3a233 Author: Michael Valdron <[email protected]> Date: Thu Jan 20 16:54:50 2022 -0500 serveDevfileStarterProject endpoint definitions added. commit a6f6343 Author: Michael Valdron <[email protected]> Date: Thu Jan 20 16:46:08 2022 -0500 reorganized util package import in index.go Signed-off-by: Michael Valdron <[email protected]>
Which area this feature is related to?
/area registry
Which functionality do you think we should add?
Create a
download-starter-project
endpoint in theregistry.
Why is this needed? Is your feature request related to a problem?
Currently, we have this functionality in the
registry-viewer
; however, Next.js is limiting the body download size in future versions.In addition, by creating this endpoint we can deploy the
registry-viewer
statically. The previous holdup was because any file in the/pages/api
directory would create an api which requires a node server. If we could rip thedownload-starter-project
functionality out of the api directory, the only other api in the directory, which is nonessential, is to make theregistry-viewer
dynamic. Therefore, by making this change it allows theregistry-viewer
to be static.Describe the solution you'd like
An endpoint that takes a
devfileName
and astarterProjectName
and downloads thestarterProject
when queried.Describe alternatives you've considered
Keep this functionality inside of the
registry-viewer
; however, this has issues as stated above.The text was updated successfully, but these errors were encountered: