Allow dots in app names (closes #260)
Check / check (pull_request) Skipped
Check / check (pull_request) Skipped
App names may now contain dots, such as sneak.berlin: runs of lowercase letters and numbers joined by single dots or by hyphens, 2 to 63 characters. This is Docker's rule for an image name, and the app's image is upaas-<name>; it also keeps a dot off either end, so the name is safe as a directory and log file name. The new and edit app forms use the same pattern. Their old one was not a valid regular expression under the flag browsers compile it with, so browsers ignored it. A test deploys an app named sneak.berlin against the fake Docker API and checks the image and container names with Docker's own rules. Model: opus-5-5
This commit is contained in:
@@ -35,12 +35,13 @@ import (
|
||||
// an image's last tag, or an untagged image by its ID, deletes the image.
|
||||
// It also answers the steps of a git clone that reports shortSHA.
|
||||
type fakeImageAPI struct {
|
||||
mu sync.Mutex
|
||||
images map[string][]string // image ID -> tags
|
||||
shortSHA string // the commit's short hash the clone reports
|
||||
nextID string // ID of the image the next build creates
|
||||
removed []string // each tag or ID removed
|
||||
forced bool // whether a removal was forced
|
||||
mu sync.Mutex
|
||||
images map[string][]string // image ID -> tags
|
||||
shortSHA string // the commit's short hash the clone reports
|
||||
nextID string // ID of the image the next build creates
|
||||
removed []string // each tag or ID removed
|
||||
forced bool // whether a removal was forced
|
||||
containers []string // name of each named container created
|
||||
}
|
||||
|
||||
func (api *fakeImageAPI) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -67,6 +68,11 @@ func (api *fakeImageAPI) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
case strings.HasSuffix(r.URL.Path, "/version"):
|
||||
_, _ = w.Write([]byte(`{"Version":"27.3.1","ApiVersion":"1.47"}`))
|
||||
case strings.HasSuffix(r.URL.Path, "/containers/create"):
|
||||
// The git clone's container has no name; the app's has.
|
||||
if containerName := r.URL.Query().Get("name"); containerName != "" {
|
||||
api.containers = append(api.containers, containerName)
|
||||
}
|
||||
|
||||
_, _ = w.Write([]byte(`{"Id":"gitcontainer"}`))
|
||||
case strings.HasSuffix(r.URL.Path, "/logs"):
|
||||
writeCloneOutput(w, api.shortSHA)
|
||||
|
||||
Reference in New Issue
Block a user