This repository has been archived by the owner on Jun 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 190
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 #190 from joshwget/split-project-package
Split project package into project, config, and yaml packages
- Loading branch information
Showing
28 changed files
with
329 additions
and
326 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package project | ||
package config | ||
|
||
import ( | ||
"bytes" | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package project | ||
package config | ||
|
||
import ( | ||
"fmt" | ||
|
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,88 @@ | ||
package config | ||
|
||
import ( | ||
"testing" | ||
|
||
yaml "github.com/cloudfoundry-incubator/candiedyaml" | ||
yamlTypes "github.com/docker/libcompose/yaml" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
type TestConfig struct { | ||
SystemContainers map[string]*ServiceConfig | ||
} | ||
|
||
func newTestConfig() TestConfig { | ||
return TestConfig{ | ||
SystemContainers: map[string]*ServiceConfig{ | ||
"udev": { | ||
Image: "udev", | ||
Restart: "always", | ||
Net: "host", | ||
Privileged: true, | ||
DNS: yamlTypes.NewStringorslice("8.8.8.8", "8.8.4.4"), | ||
Environment: yamlTypes.NewMaporEqualSlice([]string{ | ||
"DAEMON=true", | ||
}), | ||
Labels: yamlTypes.NewSliceorMap(map[string]string{ | ||
"io.rancher.os.detach": "true", | ||
"io.rancher.os.scope": "system", | ||
}), | ||
VolumesFrom: []string{ | ||
"system-volumes", | ||
}, | ||
Ulimits: yamlTypes.Ulimits{ | ||
Elements: []yamlTypes.Ulimit{ | ||
yamlTypes.NewUlimit("nproc", 65557, 65557), | ||
}, | ||
}, | ||
}, | ||
"system-volumes": { | ||
Image: "state", | ||
Net: "none", | ||
ReadOnly: true, | ||
Privileged: true, | ||
Labels: yamlTypes.NewSliceorMap(map[string]string{ | ||
"io.rancher.os.createonly": "true", | ||
"io.rancher.os.scope": "system", | ||
}), | ||
Volumes: []string{ | ||
"/dev:/host/dev", | ||
"/var/lib/rancher/conf:/var/lib/rancher/conf", | ||
"/etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt.rancher", | ||
"/lib/modules:/lib/modules", | ||
"/lib/firmware:/lib/firmware", | ||
"/var/run:/var/run", | ||
"/var/log:/var/log", | ||
}, | ||
LogDriver: "json-file", | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func TestMarshalConfig(t *testing.T) { | ||
config := newTestConfig() | ||
bytes, err := yaml.Marshal(config) | ||
assert.Nil(t, err) | ||
|
||
config2 := TestConfig{} | ||
|
||
err = yaml.Unmarshal(bytes, &config2) | ||
assert.Nil(t, err) | ||
|
||
assert.Equal(t, config, config2) | ||
} | ||
|
||
func TestMarshalServiceConfig(t *testing.T) { | ||
configPtr := newTestConfig().SystemContainers["udev"] | ||
bytes, err := yaml.Marshal(configPtr) | ||
assert.Nil(t, err) | ||
|
||
configPtr2 := &ServiceConfig{} | ||
|
||
err = yaml.Unmarshal(bytes, configPtr2) | ||
assert.Nil(t, err) | ||
|
||
assert.Equal(t, configPtr, configPtr2) | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package project | ||
package config | ||
|
||
var schemaString = `{ | ||
"$schema": "http://json-schema.org/draft-04/schema#", | ||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package project | ||
package config | ||
|
||
import ( | ||
"encoding/json" | ||
|
Oops, something went wrong.