~timo-jyrinki/ubuntu-sdk-tools/test_automerge

« back to all changes in this revision

Viewing changes to usdk-target/images.go

  • Committer: Benjamin Zeller
  • Date: 2016-07-06 09:06:40 UTC
  • mfrom: (18.1.12 ubuntu-sdk-tools)
  • Revision ID: benjamin.zeller@canonical.com-20160706090640-6nwco3u5b27hfki9
- Deprecate -a and -f switches when creating containers, we can get the information from the image
- Automatically fix broken devices in containers
- Automatically add DRI devices if they are not in the containers
- Automatically fix NVidia driver issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
func (c *imagesCmd) flags() {
50
50
}
51
51
 
52
 
func (c *imagesCmd) run(args []string) error {
53
 
 
54
 
        config := ubuntu_sdk_tools.GetConfigOrDie()
55
 
        d, err := lxd.NewClient(config, "ubuntu-sdk-images")
56
 
        if err != nil {
57
 
                return err
58
 
        }
59
 
 
60
 
        images, err := d.ListImages()
61
 
        if err != nil {
62
 
                return err
 
52
func findRelevantImages(client *lxd.Client) ([]imageDesc, error) {
 
53
        images, err := client.ListImages()
 
54
        if err != nil {
 
55
                return nil, err
63
56
        }
64
57
 
65
58
        imageDescs := make([]imageDesc, len(images))
70
63
 
71
64
                alias := ""
72
65
                for _, tAl := range image.Aliases {
73
 
 
74
66
                        if !strings.HasPrefix(tAl.Name, "ubuntu-sdk") {
75
67
                                continue
76
68
                        }
95
87
                imageDescs[idx].UploadDate = image.UploadDate
96
88
        }
97
89
 
 
90
        return imageDescs, nil
 
91
}
 
92
 
 
93
func (c *imagesCmd) run(args []string) error {
 
94
 
 
95
        config := ubuntu_sdk_tools.GetConfigOrDie()
 
96
        d, err := lxd.NewClient(config, "ubuntu-sdk-images")
 
97
        if err != nil {
 
98
                return err
 
99
        }
 
100
 
 
101
        imageDescs, err := findRelevantImages(d)
 
102
        if err != nil {
 
103
                return err
 
104
        }
 
105
 
98
106
        js, err := json.Marshal(imageDescs)
99
107
        if err != nil {
100
108
                return fmt.Errorf("Error while formatting data from the server. error: %v,\n", err)