您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

gpg_key_import.go 1.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2021 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package asymkey
  4. import "code.gitea.io/gitea/models/db"
  5. // __________________ ________ ____ __.
  6. // / _____/\______ \/ _____/ | |/ _|____ ___.__.
  7. // / \ ___ | ___/ \ ___ | <_/ __ < | |
  8. // \ \_\ \| | \ \_\ \ | | \ ___/\___ |
  9. // \______ /|____| \______ / |____|__ \___ > ____|
  10. // \/ \/ \/ \/\/
  11. // .___ __
  12. // | | _____ ______ ____________/ |_
  13. // | |/ \\____ \ / _ \_ __ \ __\
  14. // | | Y Y \ |_> > <_> ) | \/| |
  15. // |___|__|_| / __/ \____/|__| |__|
  16. // \/|__|
  17. // This file contains functions related to the original import of a key
  18. // GPGKeyImport the original import of key
  19. type GPGKeyImport struct {
  20. KeyID string `xorm:"pk CHAR(16) NOT NULL"`
  21. Content string `xorm:"MEDIUMTEXT NOT NULL"`
  22. }
  23. func init() {
  24. db.RegisterModel(new(GPGKeyImport))
  25. }
  26. // GetGPGImportByKeyID returns the import public armored key by given KeyID.
  27. func GetGPGImportByKeyID(keyID string) (*GPGKeyImport, error) {
  28. key := new(GPGKeyImport)
  29. has, err := db.GetEngine(db.DefaultContext).ID(keyID).Get(key)
  30. if err != nil {
  31. return nil, err
  32. } else if !has {
  33. return nil, ErrGPGKeyImportNotExist{keyID}
  34. }
  35. return key, nil
  36. }