Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

key.go 846B

1234567891011121314151617181920212223242526272829
  1. // Copyright 2018 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package private
  5. import (
  6. "fmt"
  7. "code.gitea.io/gitea/modules/setting"
  8. )
  9. // UpdatePublicKeyInRepo update public key and if necessary deploy key updates
  10. func UpdatePublicKeyInRepo(keyID, repoID int64) error {
  11. // Ask for running deliver hook and test pull request tasks.
  12. reqURL := setting.LocalURL + fmt.Sprintf("api/internal/ssh/%d/update/%d", keyID, repoID)
  13. resp, err := newInternalRequest(reqURL, "POST").Response()
  14. if err != nil {
  15. return err
  16. }
  17. defer resp.Body.Close()
  18. // All 2XX status codes are accepted and others will return an error
  19. if resp.StatusCode/100 != 2 {
  20. return fmt.Errorf("Failed to update public key: %s", decodeJSONError(resp).Err)
  21. }
  22. return nil
  23. }