コード例 #1
0
ファイル: settings.go プロジェクト: boldfield/goxc
func (s *Settings) GetTaskSettingStringSlice(taskName, settingName string) []string {
	retUntyped := s.GetTaskSetting(taskName, settingName)
	if retUntyped == nil {
		return []string{}
	}
	strSlice, err := typeutils.ToStringSlice(retUntyped, taskName+"."+settingName)
	if err != nil {
		//already logged
	}
	return strSlice
}
コード例 #2
0
ファイル: bintray.go プロジェクト: boldfield/goxc
func getVersions(apihost, apikey, subject, repository, pkg string, isVerbose bool) ([]string, error) {
	client := &http.Client{}
	url := apihost + "/packages/" + subject + "/" + repository + "/" + pkg
	req, err := http.NewRequest("GET", url, nil)
	if err != nil {
		return nil, err
	}
	req.SetBasicAuth(subject, apikey)
	resp, err := client.Do(req)
	if err != nil {
		log.Printf("Error calling %s - %v", url, err)
		return nil, err
	}
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		log.Printf("Error reading response body - %v", err)
		return nil, err
	}
	resp.Body.Close()
	var b map[string]interface{}
	err = json.Unmarshal(body, &b)
	if err != nil {
		log.Printf("Error parsing json body - %v", err)
		log.Printf("Body: %s", body)
		return nil, err
	}
	if isVerbose {
		log.Printf("Body: %s", body)
	}
	if versions, keyExists := b["versions"]; keyExists {
		versionsSlice, err := typeutils.ToStringSlice(versions, "versions")

		return versionsSlice, err
	}
	return nil, errors.New("Versions not listed!")
}
コード例 #3
0
ファイル: buildsettings.go プロジェクト: boldfield/goxc
func buildSettingsFromMap(m map[string]interface{}) (*BuildSettings, error) {
	var err error
	bs := BuildSettings{}
	FillBuildSettingsDefaults(&bs)
	for k, v := range m {
		switch k {
		//case "GoRoot":
		//	bs.GoRoot, err = typeutils.ToString(v, k)
		case "Processors":
			var fp float64
			fp, err = typeutils.ToFloat64(v, k)
			if err == nil {
				processors := int(fp)
				bs.Processors = &processors
			}
		case "Race":
			var race bool
			race, err = typeutils.ToBool(v, k)
			if err == nil {
				bs.Race = &race
			}
		case "Verbose":
			var verbose bool
			verbose, err = typeutils.ToBool(v, k)
			if err == nil {
				bs.Verbose = &verbose
			}
		case "PrintCommands":
			var printCommands bool
			printCommands, err = typeutils.ToBool(v, k)
			if err == nil {
				bs.PrintCommands = &printCommands
			}
		case "CcFlags":
			var ccFlags string
			ccFlags, err = typeutils.ToString(v, k)
			if err == nil {
				bs.CcFlags = &ccFlags
			}
		case "Compiler":
			var s string
			s, err = typeutils.ToString(v, k)
			if err == nil {
				bs.Compiler = &s
			}
		case "GccGoFlags":
			var s string
			s, err = typeutils.ToString(v, k)
			if err == nil {
				bs.GccGoFlags = &s
			}
		case "GcFlags":
			var s string
			s, err = typeutils.ToString(v, k)
			if err == nil {
				bs.GcFlags = &s
			}
		case "InstallSuffix":
			var s string
			s, err = typeutils.ToString(v, k)
			if err == nil {
				bs.InstallSuffix = &s
			}
		case "LdFlags":
			var s string
			s, err = typeutils.ToString(v, k)
			if err == nil {
				bs.LdFlags = &s
			}
		case "Tags":
			var s string
			s, err = typeutils.ToString(v, k)
			if err == nil {
				bs.Tags = &s
			}
		case "LdFlagsXVars":
			var xVars map[string]interface{}
			xVars, err = typeutils.ToMap(v, k)
			if err == nil {
				bs.LdFlagsXVars = &xVars
			}
		case "ExtraArgs":
			bs.ExtraArgs, err = typeutils.ToStringSlice(v, k)
		default:
			log.Printf("Warning!! Unrecognised Setting '%s' (value %v)", k, v)
		}
		if err != nil {
			return &bs, err
		}

	}
	return &bs, err
}
コード例 #4
0
ファイル: json.go プロジェクト: boldfield/goxc
func loadSettingsSection(settingsSection map[string]interface{}) (settings Settings, err error) {
	settings = Settings{}
	for k, v := range settingsSection {
		//try to match key
		switch k {
		case "Tasks":
			settings.Tasks, err = typeutils.ToStringSlice(v, k)
		case "TasksExclude":
			settings.TasksExclude, err = typeutils.ToStringSlice(v, k)
		case "TasksAppend":
			settings.TasksAppend, err = typeutils.ToStringSlice(v, k)
		case "TasksPrepend":
			settings.TasksPrepend, err = typeutils.ToStringSlice(v, k)
		case "AppName":
			settings.AppName, err = typeutils.ToString(v, k)
		case "ArtifactsDest":
			settings.ArtifactsDest, err = typeutils.ToString(v, k)
		case "OutPath":
			settings.OutPath, err = typeutils.ToString(v, k)
		case "Arch":
			settings.Arch, err = typeutils.ToString(v, k)
		case "Os":
			settings.Os, err = typeutils.ToString(v, k)
		case "BuildConstraints":
			settings.BuildConstraints, err = typeutils.ToString(v, k)
		case "ResourcesInclude":
			settings.ResourcesInclude, err = typeutils.ToString(v, k)
		case "ResourcesExclude":
			settings.ResourcesExclude, err = typeutils.ToString(v, k)
		case "MainDirsExclude":
			settings.MainDirsExclude, err = typeutils.ToString(v, k)
		//deprecated
		case "Resources":
			for k2, v2 := range v.(map[string]interface{}) {
				switch k2 {
				case "Include":
					settings.ResourcesInclude, err = typeutils.ToString(v2, k+":"+k2)
				case "Exclude":
					settings.ResourcesExclude, err = typeutils.ToString(v2, k+":"+k2)
				}
			}
		case "PackageVersion":
			settings.PackageVersion, err = typeutils.ToString(v, k)
		case "BranchName":
			settings.BranchName, err = typeutils.ToString(v, k)
		case "PrereleaseInfo":
			settings.PrereleaseInfo, err = typeutils.ToString(v, k)
		case "BuildName":
			settings.BuildName, err = typeutils.ToString(v, k)
		case "Verbosity":
			settings.Verbosity, err = typeutils.ToString(v, k)
		case "TaskSettings":
			settings.TaskSettings, err = typeutils.ToMapStringMapStringInterface(v, k)
		case "FormatVersion":
			settings.GoxcConfigVersion, err = typeutils.ToString(v, k)
		case "ConfigVersion":
			settings.GoxcConfigVersion, err = typeutils.ToString(v, k)
		case "BuildSettings":
			var m map[string]interface{}
			m, err = typeutils.ToMap(v, k)
			if err == nil {
				settings.BuildSettings, err = buildSettingsFromMap(m)
				if err == nil {
					//log.Printf("Parsed build settings OK (%+v)", settings.BuildSettings)
				}
			}
		case "Env":
			settings.Env, err = typeutils.ToStringSlice(v, k)
		default:
			log.Printf("Warning!! Unrecognised Setting '%s' (value %v)", k, v)
		}
		if err != nil {
			return settings, err
		}
	}
	return settings, err
}