Exemplo n.º 1
0
Arquivo: publish.go Projeto: shtlee/qa
func (p *Pub) Init(conf, env, path string) (err error) {

	if err = config.LoadEx(p, conf); err != nil {
		return
	}
	if err = config.LoadEx(&p.Env, env); err != nil {
		return
	}
	dt := da.NewTransport(p.Env.AccessKey, p.Env.SecretKey, nil)
	p.rsCli, err = rs.New(p.Env.Hosts, p.Env.Ips, dt)
	if err != nil {
		err = errors.Info(err, "Pub init failed")
		return
	}
	p.pubCli, err = pub.New(p.Env.Hosts["pu"], p.Env.Ips["pu"], dt)
	if err != nil {
		err = errors.Info(err, "Pub init failed")
		return
	}
	p.DataFile = filepath.Join(path, p.DataFile)
	domainRegexp, err := regexp.Compile(p.NormalDomainRegexp)
	if err != nil {
		err = errors.Info(err, "Pub init failed")
		return
	}
	p.isNormalDomain = domainRegexp.Match([]byte(p.Domain))

	return
}
Exemplo n.º 2
0
func (p *PubImage) Init(conf, env, path string) (err error) {

	if err = config.LoadEx(p, conf); err != nil {
		err = errors.Info(err, "pub_image load conf failed", conf)
		return
	}
	if err = config.LoadEx(&p.Env, env); err != nil {
		err = errors.Info(err, "pub_image load env failed", env)
		return
	}
	dt := da.NewTransport(p.Env.AccessKey, p.Env.SecretKey, nil)
	p.Pubcli, err = pub.New(p.Env.Hosts["pu"], p.Env.Ips["pu"], dt)
	if err != nil {
		err = errors.Info(err, "pub_image init failed")
		return
	}
	return
}
Exemplo n.º 3
0
func doTestInit(t *testing.T) {
	var (
		c Config
	)

	// load config
	b, err := ioutil.ReadFile("qbox.conf")
	if err != nil {
		t.Fatal(err)
	}
	if err = json.Unmarshal(b, &c); err != nil {
		t.Fatal(err)
	}

	// create auth transport layer, uptoken and digest
	auth := &uptoken.AuthPolicy{}
	token := uptoken.MakeAuthTokenString(c.AccessKey, c.SecretKey, auth)
	// uptoken transport
	ut := uptoken.NewTransport(token, nil)

	// digest transport
	dt := digest.NewTransport(c.AccessKey, c.SecretKey, nil)

	if eus, err = eu.New(&c, dt); err != nil {
		t.Fatal(err)
	}
	if pubs, err = pub.New(&c, dt); err != nil {
		t.Fatal(err)
	}
	if rss, err = rs.New(&c, dt); err != nil {
		t.Fatal(err)
	}
	if ucs, err = uc.New(&c, dt); err != nil {
		t.Fatal(err)
	}
	if ups, err = up.New(&c, ut); err != nil {
		t.Fatal(err)
	}
	if ims, err = image.New(&c, dt); err != nil {
		t.Fatal(err)
	}
}