Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
krnowak committed Jun 13, 2024
1 parent e0cfb59 commit 673620d
Show file tree
Hide file tree
Showing 1,246 changed files with 279,500 additions and 222,730 deletions.
3 changes: 0 additions & 3 deletions cmd/ore/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// The package github.com/Azure/azure-sdk-for-go needs go 1.7 for TLS
// renegotiation, so only link in the ore subcommands if we build with go 1.7.

package main

import (
Expand Down
74 changes: 0 additions & 74 deletions cmd/ore/azure/create-image-arm.go

This file was deleted.

75 changes: 44 additions & 31 deletions cmd/ore/azure/create-image.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2016 CoreOS, Inc.
// Copyright 2018 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,47 +15,60 @@
package azure

import (
"time"
"encoding/json"
"fmt"
"os"

"github.com/spf13/cobra"

"github.com/flatcar/mantle/platform/api/azure"
)

var (
cmdCreateImage = &cobra.Command{
Use: "create-image",
cmdCreateImageARM = &cobra.Command{
Use: "create-image-arm",
Short: "Create Azure image",
Long: "Create Azure image from a local VHD file",
RunE: runCreateImage,
Long: "Create Azure image from a blob url",
RunE: runCreateImageARM,
}

// create image options
md azure.OSImage
imageName string
blobUrl string
resourceGroup string
)

func today() string {
return time.Now().Format("2006-01-02")
}

func init() {
sv := cmdCreateImage.Flags().StringVar

sv(&md.Name, "name", "", "image name")
sv(&md.Label, "label", "", "image label")
sv(&md.Description, "description", "", "image description")
sv(&md.MediaLink, "blob", "", "source blob url")
sv(&md.ImageFamily, "family", "", "image family")
sv(&md.PublishedDate, "published-date", today(), "image published date, parsed as RFC3339")
sv(&md.RecommendedVMSize, "recommended-vm-size", "Medium", "recommended VM size")
sv(&md.IconURI, "icon-uri", "coreos-globe-color-lg-100px.png", "icon URI")
sv(&md.SmallIconURI, "small-icon-uri", "coreos-globe-color-lg-45px.png", "small icon URI")

Azure.AddCommand(cmdCreateImage)
sv := cmdCreateImageARM.Flags().StringVar

sv(&imageName, "image-name", "", "image name")
sv(&blobUrl, "image-blob", "", "source blob url")
sv(&resourceGroup, "resource-group", "kola", "resource group name")

Azure.AddCommand(cmdCreateImageARM)
}

func runCreateImage(cmd *cobra.Command, args []string) error {
md.Category = "Public"
md.OS = "Linux"
return api.AddOSImage(&md)
func runCreateImageARM(cmd *cobra.Command, args []string) error {
if err := api.SetupClients(); err != nil {
fmt.Fprintf(os.Stderr, "setting up clients: %v\n", err)
os.Exit(1)
}
img, err := api.CreateImage(imageName, resourceGroup, blobUrl)
if err != nil {
fmt.Fprintf(os.Stderr, "Couldn't create image: %v\n", err)
os.Exit(1)
}
if img.ID == nil {
fmt.Fprintf(os.Stderr, "received nil image\n")
os.Exit(1)
}
err = json.NewEncoder(os.Stdout).Encode(&struct {
ID *string
Location *string
}{
ID: img.ID,
Location: img.Location,
})
if err != nil {
fmt.Fprintf(os.Stderr, "Couldn't encode result: %v\n", err)
os.Exit(1)
}
return nil
}
107 changes: 0 additions & 107 deletions cmd/ore/azure/replicate-image.go

This file was deleted.

51 changes: 0 additions & 51 deletions cmd/ore/azure/share-image.go

This file was deleted.

41 changes: 0 additions & 41 deletions cmd/ore/azure/unreplicate-image.go

This file was deleted.

Loading

0 comments on commit 673620d

Please sign in to comment.