Skip to content
Snippets Groups Projects
Commit 1761f8f5 authored by Michał Bień's avatar Michał Bień
Browse files

Fixed bug when storing empty configmap

parent 98f59004
No related branches found
No related tags found
No related merge requests found
GOOS=linux GOARCH=amd64 go build
...@@ -78,7 +78,7 @@ func (s *configServiceServer) FindGitlabProjectId(api *gitlab.Client, uid string ...@@ -78,7 +78,7 @@ func (s *configServiceServer) FindGitlabProjectId(api *gitlab.Client, uid string
func (s *configServiceServer) PrepareDataJsonFromRepository(api *gitlab.Client, repoId int) ([]byte, error) { func (s *configServiceServer) PrepareDataJsonFromRepository(api *gitlab.Client, repoId int) ([]byte, error) {
//List files //List files
tree, _, err := s.gitAPI.Repositories.ListTree(repoId, nil) tree, _, err := s.gitAPI.Repositories.ListTree(repoId, nil)
if err != nil || len(tree) == 0 { if err != nil {
log.Print(err) log.Print(err)
return nil, status.Errorf(codes.NotFound, "Cannot find any config files") return nil, status.Errorf(codes.NotFound, "Cannot find any config files")
} }
...@@ -108,12 +108,11 @@ func (s *configServiceServer) PrepareDataJsonFromRepository(api *gitlab.Client, ...@@ -108,12 +108,11 @@ func (s *configServiceServer) PrepareDataJsonFromRepository(api *gitlab.Client,
compiledMap = append(compiledMap, mapAfterName...) compiledMap = append(compiledMap, mapAfterName...)
compiledMap = append(compiledMap, base64.StdEncoding.EncodeToString(data)...) compiledMap = append(compiledMap, base64.StdEncoding.EncodeToString(data)...)
if numFiles-1 == i { //it's last element if numFiles-1 != i { //it's not last element
compiledMap = append(compiledMap, mapAfterLast...)
} else {
compiledMap = append(compiledMap, mapNextData...) compiledMap = append(compiledMap, mapNextData...)
} }
} }
compiledMap = append(compiledMap, mapAfterLast...)
return compiledMap, nil return compiledMap, nil
} }
...@@ -129,10 +128,10 @@ func (s *configServiceServer) PrepareDataMapFromRepository(api *gitlab.Client, r ...@@ -129,10 +128,10 @@ func (s *configServiceServer) PrepareDataMapFromRepository(api *gitlab.Client, r
log.Print(err) log.Print(err)
return nil, status.Errorf(codes.NotFound, "Cannot find any config files") return nil, status.Errorf(codes.NotFound, "Cannot find any config files")
} }
if len(tree) == 0 { //if len(tree) == 0 {
log.Printf("There are no files to config in repo %d", repoId) // log.Printf("There are no files to config in repo %d", repoId)
return compiledMap, nil // return compiledMap, nil
} //}
//Start parsing //Start parsing
for _, file := range tree { for _, file := range tree {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment