Пример #1
0
Файл: list.go Проект: flazz/rack
func (command *commandList) Execute(resource *handler.Resource) {
	err := keypairs.List(command.Ctx.ServiceClient).EachPage(func(page pagination.Page) (bool, error) {
		info, err := osKeypairs.ExtractKeyPairs(page)
		if err != nil {
			return false, err
		}
		result := make([]map[string]interface{}, len(info))
		for j, key := range info {
			result[j] = structs.Map(key)
		}
		resource.Result = result
		return false, nil
	})
	if err != nil {
		resource.Err = err
		return
	}
}
Пример #2
0
func TestListKeyPairs(t *testing.T) {
	client, err := newClient()
	th.AssertNoErr(t, err)

	count := 0
	err = keypairs.List(client).EachPage(func(page pagination.Page) (bool, error) {
		count++
		t.Logf("--- %02d ---", count)

		ks, err := keypairs.ExtractKeyPairs(page)
		th.AssertNoErr(t, err)

		for i, keypair := range ks {
			t.Logf("[%02d]    name=[%s]", i, keypair.Name)
			t.Logf(" fingerprint=[%s]", keypair.Fingerprint)
			t.Logf("   publickey=[%s]", tools.Elide(keypair.PublicKey))
			t.Logf("  privatekey=[%s]", tools.Elide(keypair.PrivateKey))
			t.Logf("      userid=[%s]", keypair.UserID)
		}

		return true, nil
	})
	th.AssertNoErr(t, err)
}