From 808dc13cbb19f5c68c416f381e9e86eef20fcfd3 Mon Sep 17 00:00:00 2001 From: hori-ryota Date: Sun, 28 Jan 2018 17:24:46 +0900 Subject: [PATCH] Add fetchcmd for instance type --- cmd/metadata/init.go | 1 + cmd/metadata/instance_type.go | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 cmd/metadata/instance_type.go diff --git a/cmd/metadata/init.go b/cmd/metadata/init.go index b6cac9d..2824cf2 100644 --- a/cmd/metadata/init.go +++ b/cmd/metadata/init.go @@ -22,4 +22,5 @@ var ( func init() { MetadataCmd.AddCommand(regionCmd) MetadataCmd.AddCommand(instanceIdCmd) + MetadataCmd.AddCommand(instanceTypeCmd) } diff --git a/cmd/metadata/instance_type.go b/cmd/metadata/instance_type.go new file mode 100644 index 0000000..0d6f2d3 --- /dev/null +++ b/cmd/metadata/instance_type.go @@ -0,0 +1,24 @@ +package metadata + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +var ( + instanceTypeCmd = &cobra.Command{ + Use: "instance-type", + Short: "get own EC2 instance type", + RunE: func(cmd *cobra.Command, args []string) error { + + instanceType, err := client.GetMetadata("instance-type") + if err != nil { + return err + } + + fmt.Println(instanceType) + return nil + }, + } +)