本文整理汇总了Golang中github.com/coreos/fleet/unit.UnitState.MachineID方法的典型用法代码示例。如果您正苦于以下问题:Golang UnitState.MachineID方法的具体用法?Golang UnitState.MachineID怎么用?Golang UnitState.MachineID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/coreos/fleet/unit.UnitState
的用法示例。
在下文中一共展示了UnitState.MachineID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: newFakeRegistryForCommands
func newFakeRegistryForCommands(unitPrefix string, unitCount int, template bool) client.API {
// clear machineStates for every invocation
machineStates = nil
machines := []machine.MachineState{
newMachineState("c31e44e1-f858-436e-933e-59c642517860", "1.2.3.4", map[string]string{"ping": "pong"}),
newMachineState("595989bb-cbb7-49ce-8726-722d6e157b4e", "5.6.7.8", map[string]string{"foo": "bar"}),
}
jobs := make([]job.Job, 0)
appendJobsForTests(&jobs, machines[0], unitPrefix, unitCount, template)
appendJobsForTests(&jobs, machines[1], unitPrefix, unitCount, template)
states := make([]unit.UnitState, 0)
if template {
state := unit.UnitState{
UnitName: fmt.Sprintf("%[email protected]", unitPrefix),
LoadState: "loaded",
ActiveState: "inactive",
SubState: "dead",
MachineID: machines[0].ID,
}
states = append(states, state)
state.MachineID = machines[1].ID
states = append(states, state)
} else {
for i := 1; i <= unitCount; i++ {
state := unit.UnitState{
UnitName: fmt.Sprintf("%s%d.service", unitPrefix, i),
LoadState: "loaded",
ActiveState: "active",
SubState: "listening",
MachineID: machines[0].ID,
}
states = append(states, state)
}
for i := 1; i <= unitCount; i++ {
state := unit.UnitState{
UnitName: fmt.Sprintf("%s%d.service", unitPrefix, i),
LoadState: "loaded",
ActiveState: "inactive",
SubState: "dead",
MachineID: machines[1].ID,
}
states = append(states, state)
}
}
reg := registry.NewFakeRegistry()
reg.SetMachines(machines)
reg.SetUnitStates(states)
reg.SetJobs(jobs)
return &client.RegistryClient{Registry: reg}
}
示例2: modelToUnitState
func modelToUnitState(usm *unitStateModel) *unit.UnitState {
if usm == nil {
return nil
}
us := unit.UnitState{
LoadState: usm.LoadState,
ActiveState: usm.ActiveState,
SubState: usm.SubState,
UnitHash: usm.UnitHash,
}
if usm.MachineState != nil {
us.MachineID = usm.MachineState.ID
}
return &us
}