func (c *VirConnection) LookupSecretByUUIDString(uuid string) (VirSecret, error) { cUuid := C.CString(uuid) defer C.free(unsafe.Pointer(cUuid)) ptr := C.virSecretLookupByUUIDString(c.ptr, cUuid) if ptr == nil { return VirSecret{}, GetLastError() } return VirSecret{ptr: ptr}, nil }
// LookupSecretByUUID tries to lookup a secret on the given hypervisor based on // its UUID. Uses the printable string value to describe the UUID. // "Free" should be used to free the resources after the secret object is no // longer needed. func (conn Connection) LookupSecretByUUID(uuid string) (Secret, error) { cUUID := C.CString(uuid) defer C.free(unsafe.Pointer(cUUID)) cSecret := C.virSecretLookupByUUIDString(conn.virConnect, cUUID) if cSecret == nil { err := LastError() return Secret{}, err } secret := Secret{ log: conn.log, virSecret: cSecret, } return secret, nil }
func (c *VirConnection) SecretSetValue(uuid, value string) error { cUuid := C.CString(uuid) defer C.free(unsafe.Pointer(cUuid)) ptr := C.virSecretLookupByUUIDString(c.ptr, cUuid) if ptr == nil { return GetLastError() } secret, err := base64.StdEncoding.DecodeString(value) if err != nil { return err } cSecret := C.CString(string(secret)) defer C.free(unsafe.Pointer(cSecret)) res := C.virSecretSetValue(ptr, (*C.uchar)(unsafe.Pointer(cSecret)), C.size_t(len(secret)), 0) if res != 0 { return GetLastError() } return nil }