grim/convey

Handle loader options for code build, actually use the image option. Refs #160
// Convey
// Copyright 2016-2018 Gary Kramlich <grim@reaperworld.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package codebuild
import (
"github.com/aphistic/sweet"
"github.com/go-yaml/yaml"
. "github.com/onsi/gomega"
)
func (c *codebuildSuite) TestUnmarshalSimple(t sweet.T) {
yamlData := `version: 0.2
env:
variables:
JAVA_HOME: "/usr/lib/jvm/java-8-openjdk-amd64"
parameter-store:
LOGIN_PASSWORD: "dockerLoginPassword"
phases:
install:
commands:
- apt-get update -y
- apt-get install -y maven
pre_build:
commands:
- echo Nothing to do in the pre_build phase...
build:
commands:
- echo Build started on $(date)
- mvn install
post_build:
commands:
- echo Build completed on $(date)
artifacts:
files:
- target/messageUtil-1.0.jar
discard-paths: yes`
var actual CodeBuild
err := yaml.Unmarshal([]byte(yamlData), &actual)
Expect(err).To(BeNil())
expected := CodeBuild{
Version: "0.2",
Environment: environment{
Variables: map[string]string{
"JAVA_HOME": "/usr/lib/jvm/java-8-openjdk-amd64",
},
ParameterStore: map[string]string{
"LOGIN_PASSWORD": "dockerLoginPassword",
},
},
Phases: map[string]phase{
"install": {
Commands: []string{
"apt-get update -y",
"apt-get install -y maven",
},
},
"pre_build": {
Commands: []string{
"echo Nothing to do in the pre_build phase...",
},
},
"build": {
Commands: []string{
"echo Build started on $(date)",
"mvn install",
},
},
"post_build": {
Commands: []string{
"echo Build completed on $(date)",
},
},
},
Artifacts: artifacts{
Files: []string{
"target/messageUtil-1.0.jar",
},
DiscardPaths: "yes",
},
}
Expect(actual).To(Equal(expected))
}