~juju-qa/ubuntu/xenial/juju/2.0-rc2

« back to all changes in this revision

Viewing changes to src/github.com/juju/utils/os/os_linux.go

  • Committer: Nicholas Skaggs
  • Date: 2016-09-30 14:39:30 UTC
  • mfrom: (1.8.1)
  • Revision ID: nicholas.skaggs@canonical.com-20160930143930-vwwhrefh6ftckccy
import upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
        return os
30
30
}
31
31
 
32
 
var defaultVersionIDs = map[string]string{
33
 
        "arch": "rolling",
34
 
}
35
 
 
36
32
func updateOS(f string) (OSType, error) {
37
33
        values, err := ReadOSRelease(f)
38
34
        if err != nil {
41
37
        switch values["ID"] {
42
38
        case strings.ToLower(Ubuntu.String()):
43
39
                return Ubuntu, nil
44
 
        case strings.ToLower(Arch.String()):
45
 
                return Arch, nil
46
40
        case strings.ToLower(CentOS.String()):
47
41
                return CentOS, nil
48
42
        default:
49
 
                return Unknown, nil
 
43
                return GenericLinux, nil
50
44
        }
51
45
}
52
46
 
67
61
                }
68
62
                values[c[0]] = strings.Trim(c[1], "\t '\"")
69
63
        }
70
 
        id, ok := values["ID"]
71
 
        if !ok {
 
64
        if _, ok := values["ID"]; !ok {
72
65
                return nil, errors.New("OS release file is missing ID")
73
66
        }
74
 
        if _, ok := values["VERSION_ID"]; !ok {
75
 
                values["VERSION_ID"], ok = defaultVersionIDs[id]
76
 
                if !ok {
77
 
                        return nil, errors.New("OS release file is missing VERSION_ID")
78
 
                }
79
 
        }
80
67
        return values, nil
81
68
}