MCPcopy Index your code
hub / github.com/linuxkit/linuxkit / CreateImage

Method CreateImage

src/cmd/linuxkit/gcp.go:134–173  ·  view source on GitHub ↗

CreateImage creates a GCP image using the source from Google Storage

(name, storageURL, family string, nested, uefi, replace bool)

Source from the content-addressed store, hash-verified

132
133// CreateImage creates a GCP image using the source from Google Storage
134func (g GCPClient) CreateImage(name, storageURL, family string, nested, uefi, replace bool) error {
135 if replace {
136 if err := g.DeleteImage(name); err != nil {
137 return err
138 }
139 }
140
141 log.Infof("Creating image: %s", name)
142 imgObj := &compute.Image{
143 RawDisk: &compute.ImageRawDisk{
144 Source: storageURL,
145 },
146 Name: name,
147 }
148
149 if family != "" {
150 imgObj.Family = family
151 }
152
153 if nested {
154 imgObj.Licenses = []string{vmxImageLicence}
155 }
156
157 if uefi {
158 imgObj.GuestOsFeatures = []*compute.GuestOsFeature{
159 {Type: uefiCompatibleFeature},
160 }
161 }
162
163 op, err := g.compute.Images.Insert(g.projectName, imgObj).Do()
164 if err != nil {
165 return err
166 }
167
168 if err := g.pollOperationStatus(op.Name); err != nil {
169 return err
170 }
171 log.Infof("Image %s created", name)
172 return nil
173}
174
175// DeleteImage deletes and image
176func (g GCPClient) DeleteImage(name string) error {

Callers 2

pushGCPCmdFunction · 0.95
CreateScalewayImageMethod · 0.80

Calls 3

DeleteImageMethod · 0.95
pollOperationStatusMethod · 0.95
DoMethod · 0.80

Tested by

no test coverage detected