Exemple #1
0
//Undeploy the kubernetes provider and reset replication controllers
func (p *Kubernetes) Undeploy() error {
	for _, artifact := range p.Artifacts() {
		base := filepath.Base(artifact)
		fullPath := filepath.Join(p.WorkDirectory(), base)

		markupParser := parser.NewParser(fullPath)
		result := &kubeConfig{}
		markupParser.Unmarshal(result)
		name := result.Metadata.Name
		kind := result.Kind

		if isReplicationController(kind) {
			p.resetReplica(name)
		}
		p.deletePod(fullPath)
	}
	return nil
}
Exemple #2
0
//LoadAnswers Unmarshals the answers from the answers.conf file into the base AnswersData
func (b *Base) LoadAnswers() error {
	//if a directory was provided...
	fp := b.AnswersDir()
	if utils.PathIsDirectory(fp) {
		//Construct the full path by combining with the ANSWERS_FILE constant
		fp = filepath.Join(fp, constants.ANSWERS_FILE)
		if !utils.PathExists(fp) {
			return errors.New("Failed to read answers from path")
		}
	}
	//..try to parse the file
	if !utils.PathExists(fp) {
		return errors.New("Bad answers filepath")
	}
	p := parser.NewParser(fp)
	err := p.Unmarshal(&b.AnswersData)
	if err != nil {
		return errors.New("Failed to parse file")
	}
	return nil
}