Exemple #1
0
func main() {
	identifier, labels, _ := strategies.GetIdentifierLabelsAndConf()

	for {
		metadata, err := getMetadata(identifier, labels)
		if err == errGoUp {
			newidentifier, _ := path.Split(identifier)
			if newidentifier == identifier {
				break
			}
			identifier = newidentifier
			continue
		}
		if err != nil {
			fmt.Println(strategies.MarshalError(err.Error()))
			os.Exit(strategies.DefaultErrorExitCode)
		}

		out, err := json.Marshal(metadata)
		if err != nil {
			fmt.Println(strategies.MarshalError(err.Error()))
			os.Exit(strategies.DefaultErrorExitCode)
		}
		fmt.Println(string(out))
		os.Exit(0)
	}
	fmt.Print(strategies.MarshalError("couldn't find artifact"))
	os.Exit(strategies.DefaultErrorExitCode)
}
Exemple #2
0
func main() {
	identifier, labels, confBlob := strategies.GetIdentifierLabelsAndConf()

	conf := &StrategyTemplateConfig{}
	err := json.Unmarshal(confBlob, conf)
	if err != nil {
		fmt.Println(strategies.MarshalError(err.Error()))
		os.Exit(strategies.DefaultErrorExitCode)
	}

	mirrors := make([]schema.ABDMirror, len(conf.Template))
	for i, m := range conf.Template {
		mirrors[i].Artifact = doTemplateSubstitution(m.Artifact, identifier, labels)
		mirrors[i].Signature = doTemplateSubstitution(m.Signature, identifier, labels)
	}

	metadata := &schema.ABDMetadata{
		Identifier: identifier,
		Labels:     labels,
		Mirrors:    mirrors,
	}

	metaBlob, err := json.Marshal(metadata)
	if err != nil {
		fmt.Println(strategies.MarshalError(err.Error()))
		os.Exit(strategies.DefaultErrorExitCode)
	}

	fmt.Print(string(metaBlob))
	os.Exit(0)
}
Exemple #3
0
func main() {
	identifier, _, _ := strategies.GetIdentifierLabelsAndConf()
	fmt.Println(strategies.MarshalError(fmt.Sprintf("refusing to discover %q, configured to be a noop", identifier)))
	os.Exit(strategies.DefaultErrorExitCode)
}