This repository has been archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #771 from arithx/kola-azure
platform/azure: add kola/ore commands for Azure
- Loading branch information
Showing
441 changed files
with
73,897 additions
and
9,545 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
// 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. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package azure | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
cmdCreateImageARM = &cobra.Command{ | ||
Use: "create-image-arm", | ||
Short: "Create Azure image", | ||
Long: "Create Azure image from a blob url", | ||
RunE: runCreateImageARM, | ||
} | ||
|
||
imageName string | ||
blobUrl string | ||
resourceGroup string | ||
) | ||
|
||
func init() { | ||
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 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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// 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. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package azure | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"time" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var ( | ||
cmdGC = &cobra.Command{ | ||
Use: "gc", | ||
Short: "GC resources in Azure", | ||
Long: `Delete instances created over the given duration ago`, | ||
RunE: runGC, | ||
} | ||
|
||
gcDuration time.Duration | ||
) | ||
|
||
func init() { | ||
Azure.AddCommand(cmdGC) | ||
cmdGC.Flags().DurationVar(&gcDuration, "duration", 5*time.Hour, "how old resources must be before they're considered garbage") | ||
} | ||
|
||
func runGC(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) | ||
} | ||
err := api.GC(gcDuration) | ||
if err != nil { | ||
fmt.Fprintf(os.Stderr, "Couldn't gc: %v\n", err) | ||
os.Exit(1) | ||
} | ||
return nil | ||
} |
Oops, something went wrong.