Example #1
0
func (c *VirConnection) LookupSecretByUsage(usageType int, usageID string) (VirSecret, error) {
	cUsageID := C.CString(usageID)
	defer C.free(unsafe.Pointer(cUsageID))
	ptr := C.virSecretLookupByUsage(c.ptr, C.int(usageType), cUsageID)
	if ptr == nil {
		return VirSecret{}, GetLastError()
	}
	return VirSecret{ptr: ptr}, nil
}
Example #2
0
// LookupSecretByUsage tries to lookup a secret on the given hypervisor based on
// its usage. The usageID is unique within the set of secrets sharing the same
// usageType value.
// "Free" should be used to free the resources after the secret object is no
// longer needed.
func (conn Connection) LookupSecretByUsage(usageType SecretUsageType, usageID string) (Secret, error) {
	cUsageType := C.int(usageType)
	cUsageID := C.CString(usageID)
	defer C.free(unsafe.Pointer(cUsageID))

	cSecret := C.virSecretLookupByUsage(conn.virConnect, cUsageType, cUsageID)

	if cSecret == nil {
		err := LastError()
		return Secret{}, err
	}

	secret := Secret{
		log:       conn.log,
		virSecret: cSecret,
	}

	return secret, nil
}