Implements a new Packer builder (oracle-bmcs) which adds support for building custom images for Oracle Bare Metal Cloud Services (BMCS) https://cloud.oracle.com/en_US/bare-metal. Additionally includes documentation for the oracle-bmcs builder.
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
// Copyright (c) 2017 Oracle America, Inc.
|
|
// The contents of this file are subject to the Mozilla Public License Version
|
|
// 2.0 (the "License"); you may not use this file except in compliance with the
|
|
// License. If a copy of the MPL was not distributed with this file, You can
|
|
// obtain one at http://mozilla.org/MPL/2.0/
|
|
|
|
package bmcs
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"net/url"
|
|
"os"
|
|
|
|
"github.com/go-ini/ini"
|
|
)
|
|
|
|
var (
|
|
mux *http.ServeMux
|
|
client *Client
|
|
server *httptest.Server
|
|
keyFile *os.File
|
|
)
|
|
|
|
// setup sets up a test HTTP server along with a bmcs.Client that is
|
|
// configured to talk to that test server. Tests should register handlers on
|
|
// mux which provide mock responses for the API method being tested.
|
|
func setup() {
|
|
mux = http.NewServeMux()
|
|
server = httptest.NewServer(mux)
|
|
parsedURL, _ := url.Parse(server.URL)
|
|
|
|
config := &Config{}
|
|
config.baseURL = parsedURL.String()
|
|
|
|
var cfg *ini.File
|
|
var err error
|
|
cfg, keyFile, err = BaseTestConfig()
|
|
|
|
config, err = loadConfigSection(cfg, "DEFAULT", config)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
client, err = NewClient(config)
|
|
if err != nil {
|
|
panic("Failed to instantiate test client")
|
|
}
|
|
}
|
|
|
|
// teardown closes the test HTTP server
|
|
func teardown() {
|
|
server.Close()
|
|
os.Remove(keyFile.Name())
|
|
}
|