github.com/coreos/mantle@v0.13.0/cmd/ore/azure/create-image.go (about)

     1  // Copyright 2016 CoreOS, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package azure
    16  
    17  import (
    18  	"time"
    19  
    20  	"github.com/spf13/cobra"
    21  
    22  	"github.com/coreos/mantle/platform/api/azure"
    23  )
    24  
    25  var (
    26  	cmdCreateImage = &cobra.Command{
    27  		Use:   "create-image",
    28  		Short: "Create Azure image",
    29  		Long:  "Create Azure image from a local VHD file",
    30  		RunE:  runCreateImage,
    31  	}
    32  
    33  	// create image options
    34  	md azure.OSImage
    35  )
    36  
    37  func today() string {
    38  	return time.Now().Format("2006-01-02")
    39  }
    40  
    41  func init() {
    42  	sv := cmdCreateImage.Flags().StringVar
    43  
    44  	sv(&md.Name, "name", "", "image name")
    45  	sv(&md.Label, "label", "", "image label")
    46  	sv(&md.Description, "description", "", "image description")
    47  	sv(&md.MediaLink, "blob", "", "source blob url")
    48  	sv(&md.ImageFamily, "family", "", "image family")
    49  	sv(&md.PublishedDate, "published-date", today(), "image published date, parsed as RFC3339")
    50  	sv(&md.RecommendedVMSize, "recommended-vm-size", "Medium", "recommended VM size")
    51  	sv(&md.IconURI, "icon-uri", "coreos-globe-color-lg-100px.png", "icon URI")
    52  	sv(&md.SmallIconURI, "small-icon-uri", "coreos-globe-color-lg-45px.png", "small icon URI")
    53  
    54  	Azure.AddCommand(cmdCreateImage)
    55  }
    56  
    57  func runCreateImage(cmd *cobra.Command, args []string) error {
    58  	md.Category = "Public"
    59  	md.OS = "Linux"
    60  	return api.AddOSImage(&md)
    61  }