示例#1
0
文件: secret.go 项目: johan--/flynn
func (s *VirSecret) GetUsageType() (int, error) {
	result := int(C.virSecretGetUsageType(s.ptr))
	if result == -1 {
		return 0, errors.New(GetLastError())
	}
	return result, nil
}
示例#2
0
// UsageType gets the type of object which uses this secret. The returned value
// is one of the constants defined in the SecretUsageType enumeration. More
// values may be added to this enumeration in the future, so callers should
// expect to see usage types they do not explicitly know about.
func (sec Secret) UsageType() (SecretUsageType, error) {
	sec.log.Println("reading secret usage type...")
	cUsageType := C.virSecretGetUsageType(sec.virSecret)

	if cUsageType == -1 {
		err := LastError()
		sec.log.Printf("an error occurred: %v\n", err)
		return 0, err
	}

	usageType := SecretUsageType(cUsageType)

	sec.log.Printf("usage type: %v\n", usageType)

	return usageType, nil
}