本文整理匯總了Golang中github.com/docker/swarm/cluster.ContainerConfig.Labels方法的典型用法代碼示例。如果您正苦於以下問題:Golang ContainerConfig.Labels方法的具體用法?Golang ContainerConfig.Labels怎麽用?Golang ContainerConfig.Labels使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/docker/swarm/cluster.ContainerConfig
的用法示例。
在下文中一共展示了ContainerConfig.Labels方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestCreateContainer
func TestCreateContainer(t *testing.T) {
// create mock client
config := new(cluster.ContainerConfig)
config.Labels = make(map[string]string)
config.Labels["upm.ip"] = "192.168.11.124/24:enp0s25"
dockinfo := new(dockerclient.ContainerInfo)
dockinfo.Id = "123456789"
dockinfo.Config = &dockerclient.ContainerConfig{
Labels: map[string]string{
"upm.ip": "192.168.11.124/24:enp0s25",
},
}
client := mockclient.NewMockClient()
client.On("Info").Return(mockInfo, nil)
client.On("Version").Return(mockVersion, nil)
client.On("StartMonitorEvents", mock.Anything, mock.Anything, mock.Anything).Return()
client.On("ListContainers", true, false, "").Return([]dockerclient.Container{}, nil).Once()
client.On("ListImages", mock.Anything).Return([]*dockerclient.Image{}, nil)
client.On("ListVolumes", mock.Anything).Return([]*dockerclient.Volume{}, nil)
client.On("ListNetworks", mock.Anything).Return([]*dockerclient.NetworkResource{}, nil)
client.On("ListVolumes", mock.Anything).Return([]*dockerclient.Volume{}, nil)
client.On("CreateContainer", mock.Anything, mock.Anything).Return("123456789", nil)
client.On("RemoveContainer", mock.AnythingOfType("string"), true, true).Return(nil)
client.On("InspectContainer", "123456789").Return(dockinfo, nil)
// create a cluster from mock client
c := simpleCluster(client)
ca, err := c.CreateContainer(config, "lee.test")
assert.Nil(t, err)
if err != nil {
return
}
assert.Equal(t, ca.Id, "123456789")
err = c.RemoveContainer(ca, true, true)
assert.Nil(t, err)
}