コード例 #1
0
ファイル: docker.go プロジェクト: allenbhuiyan/distributive
func (chk DockerImageRegexp) Status() (int, string, error) {
	images, err := dockerstatus.DockerImageRepositories()
	if err != nil {
		return 1, "", err
	}
	if tabular.ReIn(chk.re, images) {
		return errutil.Success()
	}
	msg := "Docker image was not found."
	return errutil.GenericError(msg, chk.re.String(), images)
}
コード例 #2
0
ファイル: docker.go プロジェクト: allenbhuiyan/distributive
func (chk DockerRunningRegexp) Status() (int, string, error) {
	running, err := dockerstatus.RunningContainers()
	if err != nil {
		return 1, "", err
	}
	if tabular.ReIn(chk.re, running) {
		return errutil.Success()
	}
	msg := "Docker container not runnning"
	return errutil.GenericError(msg, chk.re.String(), running)
}
コード例 #3
0
ファイル: packages.go プロジェクト: TanyaCouture/distributive
// existsRepoWithProperty is an abstraction of YumRepoExists and YumRepoURL.
// It takes a struct field name to check, and an expected value. If the expected
// value is found in the field of a repo, it returns 0, "" else an error message.
// Valid choices for prop: "URL" | "Name" | "Name"
func existsRepoWithProperty(prop string, val *regexp.Regexp, manager string) (int, string, error) {
	var properties []string
	for _, repo := range getRepos(manager) {
		switch prop {
		case "URL":
			properties = append(properties, repo.URL)
		case "Name":
			properties = append(properties, repo.Name)
		case "Status":
			properties = append(properties, repo.Status)
		case "ID":
			properties = append(properties, repo.ID)
		default:
			log.Fatal("Repos don't have the requested property: " + prop)
		}
	}
	if tabular.ReIn(val, properties) {
		return errutil.Success()
	}
	msg := "Repo with given " + prop + " not found"
	return errutil.GenericError(msg, val.String(), properties)
}