GitOps for k8s
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

errors.go 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. package git
  2. import (
  3. "errors"
  4. "strings"
  5. fluxerr "github.com/weaveworks/flux/errors"
  6. )
  7. var NoRepoError = &fluxerr.Error{
  8. Type: fluxerr.User,
  9. Err: errors.New("no repo in user config"),
  10. Help: `No Git repository URL in your config
  11. We need to clone a git repo to proceed, and you haven't supplied
  12. one. Please upload a config file, including a git repository URL, as
  13. described in
  14. https://docs.fluxcd.io/en/latest/references/fluxctl.html
  15. `,
  16. }
  17. func CloningError(url string, actual error) error {
  18. return &fluxerr.Error{
  19. Type: fluxerr.User,
  20. Err: actual,
  21. Help: `Could not clone the upstream git repository
  22. There was a problem cloning your git repository,
  23. ` + url + `
  24. This may be because you have not supplied a valid deploy key, or
  25. because the repository has been moved, deleted, or never existed.
  26. Please check that there is a repository at the address above, and that
  27. there is a deploy key with write permissions to the repository. In
  28. GitHub, you can do this via the settings for the repository, and
  29. cross-check with the fingerprint given by
  30. fluxctl identity
  31. `,
  32. }
  33. }
  34. func ErrUpstreamNotWritable(url string, actual error) error {
  35. help := `Could not write to upstream repository
  36. To keep track of synchronisation, the Flux daemon must be able to
  37. write to the upstream git repository.
  38. `
  39. if strings.HasPrefix(url, "http://") ||
  40. strings.HasPrefix(url, "https://") {
  41. help = help + `
  42. Usually, git URLs starting with "http://" or "https://" will not work
  43. well with flux, because they require the user to supply credentials
  44. interactively. If possible, use an SSH URL (starting with "ssh://", or
  45. of the form "user@host:path/to/repo").
  46. `
  47. } else {
  48. help = help + `
  49. This failure may be due to the SSH (deploy) key used by the daemon not
  50. having write permission. You can see the key used, with
  51. fluxctl identity
  52. In GitHub, please check via the repository settings that the deploy
  53. key is "Read/write". You can cross-check the fingerprint with that
  54. given by
  55. fluxctl identity --fingerprint
  56. If the key is present but read-only, you will need to delete it and
  57. create a new deploy key. To create a new one, use
  58. fluxctl identity --regenerate
  59. `
  60. }
  61. return &fluxerr.Error{
  62. Type: fluxerr.User,
  63. Err: actual,
  64. Help: help,
  65. }
  66. }
  67. func PushError(url string, actual error) error {
  68. return &fluxerr.Error{
  69. Type: fluxerr.User,
  70. Err: actual,
  71. Help: `Problem committing and pushing to git repository.
  72. There was a problem with committing changes and pushing to the git
  73. repository.
  74. If this has worked before, it most likely means a fast-forward push
  75. was not possible. It is safe to try again.
  76. If it has not worked before, this probably means that the repository
  77. exists but the SSH (deploy) key provided doesn't have write
  78. permission.
  79. In GitHub, please check via the repository settings that the deploy
  80. key is "Read/write". You can cross-check the fingerprint with that
  81. given by
  82. fluxctl identity
  83. If the key is present but read-only, you will need to delete it and
  84. create a new deploy key. To create a new one, use
  85. fluxctl identity --regenerate
  86. The public key this outputs can then be given to GitHub; make sure you
  87. check the box to allow write access unless you're using the
  88. --git-readonly=true option.
  89. `,
  90. }
  91. }