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