本文整理匯總了Golang中github.com/flynn/flynn/test/cluster.Cluster類的典型用法代碼示例。如果您正苦於以下問題:Golang Cluster類的具體用法?Golang Cluster怎麽用?Golang Cluster使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Cluster類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: removeHost
func (r *Runner) removeHost(c *cluster.Cluster, w http.ResponseWriter, q url.Values, ps httprouter.Params) error {
hostID := ps.ByName("host")
if err := c.RemoveHost(hostID); err != nil {
return err
}
w.WriteHeader(200)
return nil
}
示例2: addReleaseHosts
func (r *Runner) addReleaseHosts(c *cluster.Cluster, w http.ResponseWriter, q url.Values, ps httprouter.Params) error {
res, err := c.Boot(cluster.ClusterTypeRelease, 3, nil, false)
if err != nil {
return err
}
instance, err := c.AddVanillaHost(args.RootFS)
if err != nil {
return err
}
res.Instances = append(res.Instances, instance)
return json.NewEncoder(w).Encode(res)
}
示例3: addHost
func (r *Runner) addHost(c *cluster.Cluster, w http.ResponseWriter, q url.Values, ps httprouter.Params) (err error) {
var instance *cluster.Instance
if q.Get("vanilla") == "" {
instance, err = c.AddHost()
} else {
instance, err = c.AddVanillaHost(args.RootFS)
}
if err != nil {
return err
}
return json.NewEncoder(w).Encode(instance)
}
示例4: createFlynnrc
func createFlynnrc(c *cluster.Cluster) error {
tmpfile, err := ioutil.TempFile("", "flynnrc-")
if err != nil {
return err
}
path := tmpfile.Name()
config, err := c.CLIConfig()
if err != nil {
os.RemoveAll(path)
return err
}
if err := config.SaveTo(path); err != nil {
os.RemoveAll(path)
return err
}
flynnrc = path
return nil
}
示例5: NewClient
func NewClient(endpoint string) (*Client, error) {
authKey := os.Getenv("TEST_RUNNER_AUTH_KEY")
if authKey == "" {
return nil, errors.New("missing TEST_RUNNER_AUTH_KEY environment variable")
}
httpClient := &http.Client{Transport: &http.Transport{TLSClientConfig: &tls.Config{ServerName: "ci.flynn.io"}}}
client := &Client{
Client: &httpclient.Client{
ErrNotFound: ErrNotFound,
URL: endpoint,
Key: authKey,
HTTP: httpClient,
},
}
var cluster tc.Cluster
if err := client.Get("", &cluster); err != nil {
return nil, err
}
client.cluster = &cluster
client.size = cluster.Size()
return client, nil
}
示例6: build
func (r *Runner) build(b *Build) (err error) {
logFile, err := ioutil.TempFile("", "build-log")
if err != nil {
return err
}
b.LogFile = logFile.Name()
buildLog := buildlog.NewLog(logFile)
mainLog, err := buildLog.NewFile("build.log")
if err != nil {
return err
}
r.updateStatus(b, "pending")
<-r.buildCh
defer func() {
r.buildCh <- struct{}{}
}()
start := time.Now()
fmt.Fprintf(mainLog, "Starting build of %s at %s\n", b.Commit, start.Format(time.RFC822))
var c *cluster.Cluster
defer func() {
b.Duration = time.Since(start)
b.DurationFormatted = formatDuration(b.Duration)
fmt.Fprintf(mainLog, "build finished in %s\n", b.DurationFormatted)
if err != nil {
fmt.Fprintf(mainLog, "build error: %s\n", err)
fmt.Fprintln(mainLog, "DUMPING LOGS")
c.DumpLogs(buildLog)
}
c.Shutdown()
buildLog.Close()
b.LogURL = r.uploadToS3(logFile, b, buildLog.Boundary())
logFile.Close()
os.RemoveAll(b.LogFile)
b.LogFile = ""
if err == nil {
log.Printf("build %s passed!\n", b.ID)
r.updateStatus(b, "success")
r.ircMsgs <- fmt.Sprintf("PASS: %s %s", b.Description, b.URL())
} else {
log.Printf("build %s failed: %s\n", b.ID, err)
r.updateStatus(b, "failure")
r.ircMsgs <- fmt.Sprintf("FAIL: %s %s", b.Description, b.URL())
}
}()
log.Printf("building %s\n", b.Commit)
out := &iotool.SafeWriter{W: io.MultiWriter(os.Stdout, mainLog)}
bc := r.bc
bc.Network = r.allocateNet()
defer r.releaseNet(bc.Network)
c = cluster.New(bc, out)
log.Println("created cluster with ID", c.ID)
r.clusters[c.ID] = c
defer func() {
delete(r.clusters, c.ID)
}()
rootFS, err := c.BuildFlynn(r.rootFS, b.Commit, b.Merge, true)
defer removeRootFS(rootFS)
if err != nil {
return fmt.Errorf("could not build flynn: %s", err)
}
if _, err := c.Boot(cluster.ClusterTypeDefault, 3, buildLog, false); err != nil {
return fmt.Errorf("could not boot cluster: %s", err)
}
config, err := c.CLIConfig()
if err != nil {
return fmt.Errorf("could not generate flynnrc: %s", err)
}
var script bytes.Buffer
testRunScript.Execute(&script, map[string]interface{}{"Cluster": c, "Config": config.Clusters[0], "ListenPort": listenPort})
return c.RunWithEnv(script.String(), &cluster.Streams{
Stdout: out,
Stderr: out,
}, map[string]string{"TEST_RUNNER_AUTH_KEY": r.authKey})
}
示例7: dumpLogs
func (r *Runner) dumpLogs(c *cluster.Cluster, w http.ResponseWriter, q url.Values, ps httprouter.Params) error {
c.DumpLogs(w)
return nil
}