-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.go
36 lines (30 loc) · 811 Bytes
/
version.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
package streamer
import (
"errors"
"os"
"strings"
"github.com/rs/zerolog/log"
)
func (s *GitLabLogStreamer) updateCurrentGitlabVersion() error {
log.Debug().Msg("Updating current Gitlab version")
version, err := getCurrentGitlabVersion()
if err != nil {
return err
}
s.currentGitlabVersion = version
return nil
}
func getCurrentGitlabVersion() (string, error) {
log.Debug().Msg("Getting current Gitlab version")
content, err := os.ReadFile(GitlabVersionManifestPath)
if err != nil {
return "", err
}
lines := strings.Split(string(content), "\n")
if strings.HasPrefix(lines[0], "gitlab-ee") {
version := strings.Split(lines[0], " ")[1]
log.Debug().Msgf("Current Gitlab version: %s", version)
return version, nil
}
return "", errors.New("could not get current Gitlab version")
}