fixed queries and added change permissions
This commit is contained in:
@@ -21,11 +21,14 @@ type ImageData struct {
|
||||
DisplayName string
|
||||
}
|
||||
|
||||
func convertImageToImageData(imageSummary image.Summary) ImageData {
|
||||
func convertImageToImageData(imageSummary image.Summary) *ImageData {
|
||||
if len(imageSummary.RepoTags) == 0 {
|
||||
return nil
|
||||
}
|
||||
imageId := imageSummary.RepoTags[0]
|
||||
splitImageId := strings.Split(imageId, ":")
|
||||
imageName, imageVersion := splitImageId[0], splitImageId[1]
|
||||
return ImageData{
|
||||
return &ImageData{
|
||||
Id: imageId,
|
||||
Name: imageName,
|
||||
Version: imageVersion,
|
||||
@@ -38,9 +41,15 @@ func (con Connection) GetImages(c *gin.Context) {
|
||||
c.AbortWithError(500, err)
|
||||
return
|
||||
}
|
||||
imagesData := make([]ImageData, len(images))
|
||||
for index, imageSummary := range images {
|
||||
imagesData[index] = convertImageToImageData(imageSummary)
|
||||
imagesData := make([]ImageData, 0, len(images))
|
||||
|
||||
for _, imageSummary := range images {
|
||||
imageData := convertImageToImageData(imageSummary)
|
||||
if imageData == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
imagesData = append(imagesData, *imageData)
|
||||
}
|
||||
|
||||
c.JSON(200, imagesData)
|
||||
|
||||
Reference in New Issue
Block a user