Exemplo n.º 1
0
// rcFromManifest reads a .json/yaml file and returns the rc in it.
func rcFromManifest(fileName string) *v1.ReplicationController {
	var controller v1.ReplicationController
	framework.Logf("Parsing rc from %v", fileName)
	data := generated.ReadOrDie(fileName)

	json, err := utilyaml.ToJSON(data)
	Expect(err).NotTo(HaveOccurred())

	Expect(runtime.DecodeInto(api.Codecs.UniversalDecoder(), json, &controller)).NotTo(HaveOccurred())
	return &controller
}
Exemplo n.º 2
0
// svcFromManifest reads a .json/yaml file and returns the rc in it.
func svcFromManifest(fileName string) *v1.Service {
	var svc v1.Service
	framework.Logf("Parsing service from %v", fileName)
	data := generated.ReadOrDie(fileName)

	json, err := utilyaml.ToJSON(data)
	Expect(err).NotTo(HaveOccurred())

	Expect(runtime.DecodeInto(api.Codecs.UniversalDecoder(), json, &svc)).NotTo(HaveOccurred())
	return &svc
}
Exemplo n.º 3
0
func podFromManifest(filename string) (*v1.Pod, error) {
	var pod v1.Pod
	framework.Logf("Parsing pod from %v", filename)
	data := generated.ReadOrDie(filename)
	json, err := utilyaml.ToJSON(data)
	if err != nil {
		return nil, err
	}
	if err := runtime.DecodeInto(api.Codecs.UniversalDecoder(), json, &pod); err != nil {
		return nil, err
	}
	return &pod, nil
}
Exemplo n.º 4
0
func createFileForGoBinData(gobindataPath, outputFilename string) error {
	data := generated.ReadOrDie(gobindataPath)
	if len(data) == 0 {
		return fmt.Errorf("Failed to read gobindata from %v", gobindataPath)
	}
	fullPath := filepath.Join(framework.TestContext.OutputDir, outputFilename)
	err := os.MkdirAll(filepath.Dir(fullPath), 0777)
	if err != nil {
		return fmt.Errorf("Error while creating directory %v: %v", filepath.Dir(fullPath), err)
	}
	err = ioutil.WriteFile(fullPath, data, 0644)
	if err != nil {
		return fmt.Errorf("Error while trying to write to file %v: %v", fullPath, err)
	}
	return nil
}