github.com/sealerio/sealer@v0.11.1-0.20240507115618-f4f89c5853ae/build/layerutils/manifests/manifests.go (about) 1 // Copyright © 2021 Alibaba Group Holding Ltd. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package manifest 16 17 import ( 18 "fmt" 19 "os" 20 "path/filepath" 21 22 "github.com/sealerio/sealer/build/layerutils" 23 ) 24 25 type Manifests struct{} 26 27 // ListImages List all the containers images in manifest files 28 func (manifests *Manifests) ListImages(yamlFile string) ([]string, error) { 29 var list []string 30 31 yamlBytes, err := os.ReadFile(filepath.Clean(yamlFile)) 32 if err != nil { 33 return nil, fmt.Errorf("failed to read file: %s", err) 34 } 35 36 images := layerutils.DecodeImages(string(yamlBytes)) 37 if len(images) != 0 { 38 list = append(list, images...) 39 } 40 return list, nil 41 } 42 43 func NewManifests() (layerutils.Interface, error) { 44 return &Manifests{}, nil 45 }