Shorten container creation URL, update logs, and clean up code
- commit
- 232c2f9bdc345d368346b44f7bd3d80f27278a54
- author
- bamen · · 2024-09-19 05:31 UTC
- parent
- 5a8f38b
- signature
- unsigned
3 files · +3 -5
M internal/cli/cmd/push.go +1 -1
| @@ -88,7 +88,7 @@ func pushImage(a *cli.App, imageName string) error { | |||
| 88 | 88 | log.Info("Image pushed successfully", "image", imageName) | |
| 89 | 89 | ||
| 90 | 90 | if pushResponse.CreateContainerURL != "" { | |
| 91 | - | log.Info("Create a container for this image at:", "url", pushResponse.CreateContainerURL) | |
| 91 | + | log.Info("Container creation URL:", "url", pushResponse.CreateContainerURL) | |
| 92 | 92 | } | |
| 93 | 93 | ||
| 94 | 94 | return nil | |
| @@ -88,7 +88,7 @@ func pushImage(a *cli.App, imageName string) error { | |||||
| 88 | log.Info("Image pushed successfully", "image", imageName) | 88 | log.Info("Image pushed successfully", "image", imageName) | ||
| 89 | 89 | ||||
| 90 | if pushResponse.CreateContainerURL != "" { | 90 | if pushResponse.CreateContainerURL != "" { | ||
| 91 | - | log.Info("Create a container for this image at:", "url", pushResponse.CreateContainerURL) | 91 | + | log.Info("Container creation URL:", "url", pushResponse.CreateContainerURL) |
| 92 | } | 92 | } | ||
| 93 | 93 | ||||
| 94 | return nil | 94 | return nil | ||
M internal/httpserve/handler/cli-endpoints.go +1 -3
| @@ -4,7 +4,6 @@ import ( | |||
| 4 | 4 | "encoding/json" | |
| 5 | 5 | "errors" | |
| 6 | 6 | "fmt" | |
| 7 | - | "log" | |
| 8 | 7 | "net/http" | |
| 9 | 8 | "regexp" | |
| 10 | 9 | ||
| @@ -153,13 +152,12 @@ func generateShortID(imageID string) string { | |||
| 153 | 152 | ||
| 154 | 153 | // storeIDMapping saves the mapping between short ID and full ID | |
| 155 | 154 | func storeIDMapping(shortID, fullID string) { | |
| 156 | - | log.Printf("Storing mapping: %s -> %s", shortID, fullID) | |
| 157 | 155 | safelyInteractWithIDMap(Update, shortID, fullID) | |
| 158 | 156 | } | |
| 159 | 157 | ||
| 160 | 158 | // generateCreateContainerURL creates the URL for the container creation page | |
| 161 | 159 | func generateCreateContainerURL(a *server.App, shortID string) string { | |
| 162 | - | return fmt.Sprintf("%s://%s%s/create-container/%s", | |
| 160 | + | return fmt.Sprintf("%s://%s%s/cc/%s", | |
| 163 | 161 | a.Config.Http.Protocol(), | |
| 164 | 162 | a.Config.Http.FullDomain(), | |
| 165 | 163 | a.Config.Admin.Path, | |
| @@ -4,7 +4,6 @@ import ( | |||||
| 4 | "encoding/json" | 4 | "encoding/json" | ||
| 5 | "errors" | 5 | "errors" | ||
| 6 | "fmt" | 6 | "fmt" | ||
| 7 | - | "log" | |||
| 8 | "net/http" | 7 | "net/http" | ||
| 9 | "regexp" | 8 | "regexp" | ||
| 10 | 9 | ||||
| @@ -153,13 +152,12 @@ func generateShortID(imageID string) string { | |||||
| 153 | 152 | ||||
| 154 | // storeIDMapping saves the mapping between short ID and full ID | 153 | // storeIDMapping saves the mapping between short ID and full ID | ||
| 155 | func storeIDMapping(shortID, fullID string) { | 154 | func storeIDMapping(shortID, fullID string) { | ||
| 156 | - | log.Printf("Storing mapping: %s -> %s", shortID, fullID) | |||
| 157 | safelyInteractWithIDMap(Update, shortID, fullID) | 155 | safelyInteractWithIDMap(Update, shortID, fullID) | ||
| 158 | } | 156 | } | ||
| 159 | 157 | ||||
| 160 | // generateCreateContainerURL creates the URL for the container creation page | 158 | // generateCreateContainerURL creates the URL for the container creation page | ||
| 161 | func generateCreateContainerURL(a *server.App, shortID string) string { | 159 | func generateCreateContainerURL(a *server.App, shortID string) string { | ||
| 162 | - | return fmt.Sprintf("%s://%s%s/create-container/%s", | 160 | + | return fmt.Sprintf("%s://%s%s/cc/%s", |
| 163 | a.Config.Http.Protocol(), | 161 | a.Config.Http.Protocol(), | ||
| 164 | a.Config.Http.FullDomain(), | 162 | a.Config.Http.FullDomain(), | ||
| 165 | a.Config.Admin.Path, | 163 | a.Config.Admin.Path, | ||
M internal/httpserve/router.go +1 -1
| @@ -106,7 +106,7 @@ func bindAdminRoute(e *echo.Echo, a *server.App, adminPath string) { | |||
| 106 | 106 | adminGroup.GET("/manager", func(c echo.Context) error { | |
| 107 | 107 | return handler.AdminManagerRoute(c, a) | |
| 108 | 108 | }, middleware.RequireLogin(a)) | |
| 109 | - | adminGroup.GET("/create-container/:ID", func(c echo.Context) error { | |
| 109 | + | adminGroup.GET("/cc/:ID", func(c echo.Context) error { | |
| 110 | 110 | return handler.CreateContainerFullGET(c, a) | |
| 111 | 111 | }, middleware.RequireLogin(a)) | |
| 112 | 112 | } | |
| @@ -106,7 +106,7 @@ func bindAdminRoute(e *echo.Echo, a *server.App, adminPath string) { | |||||
| 106 | adminGroup.GET("/manager", func(c echo.Context) error { | 106 | adminGroup.GET("/manager", func(c echo.Context) error { | ||
| 107 | return handler.AdminManagerRoute(c, a) | 107 | return handler.AdminManagerRoute(c, a) | ||
| 108 | }, middleware.RequireLogin(a)) | 108 | }, middleware.RequireLogin(a)) | ||
| 109 | - | adminGroup.GET("/create-container/:ID", func(c echo.Context) error { | 109 | + | adminGroup.GET("/cc/:ID", func(c echo.Context) error { |
| 110 | return handler.CreateContainerFullGET(c, a) | 110 | return handler.CreateContainerFullGET(c, a) | ||
| 111 | }, middleware.RequireLogin(a)) | 111 | }, middleware.RequireLogin(a)) | ||
| 112 | } | 112 | } | ||