本文整理汇总了Golang中github.com/coreos/fleet/client.API类的典型用法代码示例。如果您正苦于以下问题:Golang API类的具体用法?Golang API怎么用?Golang API使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了API类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getUnitStatePage
func getUnitStatePage(cAPI client.API, machineID, unitName string, tok PageToken) (*schema.UnitStatePage, error) {
states, err := cAPI.UnitStates()
if err != nil {
return nil, err
}
var filtered []*schema.UnitState
for _, us := range states {
if machineID != "" && machineID != us.MachineID {
continue
}
if unitName != "" && unitName != us.Name {
continue
}
filtered = append(filtered, us)
}
items, next := extractUnitStatePageData(filtered, tok)
page := schema.UnitStatePage{
States: items,
}
if next != nil {
page.NextPageToken = next.Encode()
}
return &page, nil
}
开发者ID:jonboulle,项目名称:fleet,代码行数:27,代码来源:state.go
示例2: getMachinePage
func getMachinePage(cAPI client.API, tok PageToken) (*schema.MachinePage, error) {
all, err := cAPI.Machines()
if err != nil {
return nil, err
}
page := extractMachinePage(all, tok)
return page, nil
}
开发者ID:hugoduncan,项目名称:fleet,代码行数:9,代码来源:machines.go
示例3: getMachines
func getMachines(client fleetClient.API, outMachines map[string]string) error {
machines, err := client.Machines()
if err != nil {
return err
}
for _, machine := range machines {
outMachines[machine.ID] = machine.PublicIP
}
return nil
}
开发者ID:mikedanese,项目名称:heapster,代码行数:10,代码来源:buddy.go
示例4: fleetUnitHealthHandler
func fleetUnitHealthHandler(fleetAPIClient client.API, checker fleetUnitHealthChecker) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
checks := []fthealth.Check{}
unitStates, err := fleetAPIClient.UnitStates()
if err != nil {
panic(err)
}
for _, unitState := range unitStates {
checks = append(checks, newFleetUnitHealthCheck(*unitState, checker))
}
fthealth.HandlerParallel("Coco Fleet Unit Healthcheck", "Checks the health of all fleet units", checks...)(w, r)
}
}
开发者ID:Financial-Times,项目名称:coco-fleet-unit-healthcheck,代码行数:13,代码来源:fleet-unit-healthcheck.go
示例5: waitForSystemdState
func waitForSystemdState(client client.API, unit string, allowedStates []string) error {
seenDesiredState := 0
for {
states, err := client.UnitStates()
if err != nil {
return maskAny(err)
}
found := false
seenDesired := false
for _, state := range states {
if state.Name == unit {
found = true
for _, allowedState := range allowedStates {
if allowedState == state.SystemdActiveState {
seenDesired = true
}
}
}
}
if found && !seenDesired {
seenDesiredState = 0
} else {
seenDesiredState++
}
if seenDesiredState > 5 {
return nil
}
time.Sleep(500 * time.Millisecond)
}
return nil
}
开发者ID:giantswarm,项目名称:fleet-unit-replicator,代码行数:35,代码来源:fleet.go
示例6: getUnitPage
func getUnitPage(cAPI client.API, tok PageToken) (*schema.UnitPage, error) {
units, err := cAPI.Units()
if err != nil {
return nil, err
}
items, next := extractUnitPageData(units, tok)
page := schema.UnitPage{
Units: items,
}
if next != nil {
page.NextPageToken = next.Encode()
}
return &page, nil
}
开发者ID:ericcapricorn,项目名称:fleet,代码行数:17,代码来源:units.go
示例7: TestNullAPI
func TestNullAPI(test *testing.T) {
var api client.API = new(nullAPI)
// all the methods return errors, all the time.
if _, err := api.Machines(); err == nil {
test.Error("Machines() did not return an error")
}
if _, err := api.Unit("foo"); err == nil {
test.Error("Unit() did not return an error")
}
if _, err := api.Units(); err == nil {
test.Error("Units() did not return an error")
}
if _, err := api.UnitStates(); err == nil {
test.Error("UnitStates() did not return an error")
}
if err := api.SetUnitTargetState("foo", "bar"); err == nil {
test.Error("SetUnitTargetState() did not return an error")
}
if err := api.CreateUnit(nil); err == nil {
test.Error("CreateUnit() did not return an error")
}
if err := api.DestroyUnit("foo"); err == nil {
test.Error("DestroyUnit() did not return an error")
}
}
开发者ID:brendangibat,项目名称:terraform-provider-fleet,代码行数:33,代码来源:nullapi_test.go
注:本文中的github.com/coreos/fleet/client.API类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论