mirror of
https://github.com/hashicorp/packer.git
synced 2026-09-24 00:41:41 -04:00
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.
34 lines
862 B
Go
34 lines
862 B
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 "fmt"
|
|
|
|
// APIError encapsulates an error returned from the API
|
|
type APIError struct {
|
|
Code string `json:"code"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
func (e APIError) Error() string {
|
|
return fmt.Sprintf("BMCS: [%s] '%s'", e.Code, e.Message)
|
|
}
|
|
|
|
// firstError is a helper function to work out which error to return from calls
|
|
// to the API.
|
|
func firstError(err error, apiError *APIError) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if apiError != nil && len(apiError.Code) > 0 {
|
|
return apiError
|
|
}
|
|
|
|
return nil
|
|
}
|