Exemplo n.º 1
0
func (r *EtcdRegistry) Set(build schema.Build, opts schema.BuildUpdateOpts) error {
	build = schema.UpdateBuild(build, &opts)
	j, err := marshal(build)
	if err != nil {
		return err
	}

	key := path.Join(r.keyPrefix, build.ID.String())
	_, err = r.etcd.Set(key, string(j), DefaultExpireSeconds)
	if err != nil {
		return err
	}

	return nil
}
Exemplo n.º 2
0
// Set stores the build data to a json file. file name is "/tmp/risu/<UUID>.json".
func (r *LocalFsRegistry) Set(build schema.Build, opts schema.BuildUpdateOpts) error {
	build = schema.UpdateBuild(build, &opts)
	b, err := json.Marshal(build)
	if err != nil {
		return err
	}

	file, err := os.Create(r.dir + build.ID.String() + ".json")
	if err != nil {
		return err
	}

	defer file.Close()

	buildData := []byte(string(b))

	_, err = file.Write(buildData)
	if err != nil {
		return err
	}
	return nil
}