Browse code

allow docker run <name>:<id>

Victor Vieux authored on 2013/06/04 05:00:15
Showing 1 changed files
... ...
@@ -151,14 +151,20 @@ func (store *TagStore) Get(repoName string) (Repository, error) {
151 151
 	return nil, nil
152 152
 }
153 153
 
154
-func (store *TagStore) GetImage(repoName, tag string) (*Image, error) {
154
+func (store *TagStore) GetImage(repoName, tagOrId string) (*Image, error) {
155 155
 	repo, err := store.Get(repoName)
156 156
 	if err != nil {
157 157
 		return nil, err
158 158
 	} else if repo == nil {
159 159
 		return nil, nil
160 160
 	}
161
-	if revision, exists := repo[tag]; exists {
161
+	//go through all the tags, to see if tag is in fact an ID
162
+	for _, revision := range repo {
163
+		if utils.TruncateId(revision) == tagOrId {
164
+			return store.graph.Get(revision)
165
+		}
166
+	}
167
+	if revision, exists := repo[tagOrId]; exists {
162 168
 		return store.graph.Get(revision)
163 169
 	}
164 170
 	return nil, nil