10 examples of 'golang image' in Go

Every line of 'golang image' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
126func GetOtherImage() {
127 if env := os.Getenv("POUCH_HELLOWORLD_REPO"); len(env) != 0 {
128 HelloworldRepo = env
129 }
130 if env := os.Getenv("POUCH_HELLOWORLD_TAG"); len(env) != 0 {
131 HelloworldTag = env
132 }
133 if env := os.Getenv("POUCH_HTTPD_REPO"); len(env) != 0 {
134 HttpdRepo = env
135 }
136 if env := os.Getenv("POUCH_HTTPD_TAG"); len(env) != 0 {
137 HttpdTag = env
138 }
139 if env := os.Getenv("POUCH_CNI_REPO"); len(env) != 0 {
140 CniRepo = env
141 }
142 if env := os.Getenv("POUCH_CNI_TAG"); len(env) != 0 {
143 CniTag = env
144 }
145}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

14func (cli *Client) ImageCreate(ctx context.Context, options types.ImageCreateOptions) (io.ReadCloser, error) {
15 query := url.Values{}
16 query.Set("fromImage", options.Parent)
17 query.Set("tag", options.Tag)
18 resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth)
19 if err != nil {
20 return nil, err
21 }
22 return resp.body, nil
23}
63func (rit *registryImageTransformer) ImageForEnvVar(env *corev1.EnvVar, parentName string) (string, bool) {
64 return rit.handleImage(env.Name, "", false)
65}
65func createImage(out, errOut io.Writer, cmd *cobra.Command, args []string, c client.ImagesClient) error {
66 imageModel := &v1.Image{
67 Meta: v1.Meta{
68 Name: args[0],
69 },
70 BaseImage: &args[1],
71 }
72
73 var systemDependencies v1.SystemDependencies
74 if systemDependenciesFile != "" {
75 fullPath := path.Join(workDir, systemDependenciesFile)
76 b, err := ioutil.ReadFile(fullPath)
77 if err != nil {
78 return fmt.Errorf("failed to read system dependencies file: %s", err)
79 }
80 err = json.Unmarshal(b, &systemDependencies)
81 if err != nil {
82 return fmt.Errorf("failed to unmarshal system dependencies file: %s", err)
83 }
84 }
85 var runtimeDependencies v1.RuntimeDependencies
86 if runtimeDependenciesFile != "" {
87 fullPath := path.Join(workDir, runtimeDependenciesFile)
88 b, err := ioutil.ReadFile(fullPath)
89 if err != nil {
90 return fmt.Errorf("failed to read runtime dependencies file: %s", err)
91 }
92 runtimeDependencies.Manifest = string(b)
93 }
94
95 imageModel.SystemDependencies = &systemDependencies
96 imageModel.RuntimeDependencies = &runtimeDependencies
97
98 err := CallCreateImage(c)(imageModel)
99 if err != nil {
100 return err
101 }
102 if w, err := formatOutput(out, false, imageModel); w {
103 return err
104 }
105 fmt.Fprintf(out, "Created image: %s\n", imageModel.Name)
106 return nil
107}
538func (c *client) CreateImage(project string, i *compute.Image) error {
539 op, err := c.Retry(c.raw.Images.Insert(project, i).Do)
540 if err != nil {
541 return err
542 }
543
544 if err := c.i.globalOperationsWait(project, op.Name); err != nil {
545 return err
546 }
547
548 var createdImage *compute.Image
549 if createdImage, err = c.i.GetImage(project, i.Name); err != nil {
550 return err
551 }
552 *i = *createdImage
553 return nil
554}
62func PushImage(clientGlance *gophercloud.ServiceClient, imageName string, imageFilepath string, flavor *flavors.Flavor, verbose bool) {
63 // Create metadata (on OpenStack).
64 imgId, _ := createImage(clientGlance, imageName, flavor, verbose)
65 // Send the image binary data to OpenStack
66 uploadImage(clientGlance, imgId, imageFilepath, verbose)
67}
27func Images(io *ImagesOptions) error {
28 o := util.NewOutput()
29 defer o.Flush()
30
31 o.Write("IMAGE ID", "NAME", "CREATED", "SIZE")
32 for _, image := range io.allImages {
33 o.Write(image.GetUID(), image.GetName(), image.GetCreated(), image.Status.OCISource.Size.String())
34 }
35
36 return nil
37}
43func GetImageURL() string {
44 return getDomain(registry.DomainPrefixImage)
45}
26func getImage() string {
27 image := IMAGE
28 if i := os.Getenv("WERF_STAPEL_IMAGE_NAME"); i != "" {
29 image = i
30 }
31 return image
32}
239func (a *API) CreateCustomImage(ctx context.Context, name string, url string) (*godo.Image, error) {
240 var image *godo.Image
241 var err error
242 image, _, err = a.c.Images.Create(ctx, &godo.CustomImageCreateRequest{
243 Name: name,
244 Url: url,
245 Region: a.opts.Region,
246 Distribution: "Fedora",
247 Tags: []string{"mantle"},
248 })
249 if err != nil {
250 return nil, fmt.Errorf("couldn't create image: %v", err)
251 }
252 imageID := image.ID
253
254 err = util.WaitUntilReady(10*time.Minute, 10*time.Second, func() (bool, error) {
255 var err error
256 // update image in closure
257 image, _, err = a.c.Images.GetByID(ctx, imageID)
258 if err != nil {
259 return false, err
260 }
261 return image.Status == "available", nil
262 })
263 if err != nil {
264 a.DeleteImage(ctx, imageID)
265 return nil, fmt.Errorf("waiting for image creation: %v", err)
266 }
267
268 return image, nil
269}

Related snippets