From 351c51b79804d75a53d6b8e3e61cca142a70237a Mon Sep 17 00:00:00 2001 From: Mateusz Kuziemko Date: Thu, 13 Jan 2022 14:58:18 +0100 Subject: [PATCH] small refactoring --- cmd/populator/cmd/register/ocf_manifests.go | 25 ++++++++----------- .../docs/populator_register-ocf-manifests.md | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/cmd/populator/cmd/register/ocf_manifests.go b/cmd/populator/cmd/register/ocf_manifests.go index cfa9317a5..0c91eafb5 100644 --- a/cmd/populator/cmd/register/ocf_manifests.go +++ b/cmd/populator/cmd/register/ocf_manifests.go @@ -185,23 +185,20 @@ func getSourcesInfo(ctx context.Context, cfg dbpopulator.Config, log *zap.Logger return nil, fmt.Errorf("empty list of files for source %s", source) } - if !cfg.UpdateOnGitCommit { - sourcesInfo = append(sourcesInfo, dbpopulator.SourceInfo{ - Files: files, - RootDir: rootDir, - }) - continue + newSourceInfo := dbpopulator.SourceInfo{ + Files: files, + RootDir: rootDir, } - gitHash, err := getGitHash(rootDir) - if err != nil { - return nil, errors.Wrap(err, "while getting `git rev-parse HEAD`") + if cfg.UpdateOnGitCommit { + gitHash, err := getGitHash(rootDir) + if err != nil { + return nil, errors.Wrap(err, "while getting `git rev-parse HEAD`") + } + newSourceInfo.GitHash = gitHash } - sourcesInfo = append(sourcesInfo, dbpopulator.SourceInfo{ - Files: files, - GitHash: gitHash, - RootDir: rootDir, - }) + + sourcesInfo = append(sourcesInfo, newSourceInfo) } return sourcesInfo, nil } diff --git a/cmd/populator/docs/populator_register-ocf-manifests.md b/cmd/populator/docs/populator_register-ocf-manifests.md index 9723d28e4..512220ba0 100644 --- a/cmd/populator/docs/populator_register-ocf-manifests.md +++ b/cmd/populator/docs/populator_register-ocf-manifests.md @@ -22,7 +22,7 @@ It creates a binary for your platform in the `bin` directory. For example, for L > **CAUTION:** In order to run DB populator manually, make sure the populator inside development cluster is disabled. > To disable it, run `ENABLE_POPULATOR=false make dev-cluster-update` -It requires one argument, which is a path to directory with Hub manifests. Internally it uses [go-getter](https://github.com/hashicorp/go-getter) so it can download manifests from different locations and in different formats. +It requires one argument, which is a path to directory with Hub manifests. Internally it uses [go-getter](https://github.com/hashicorp/go-getter) so it can download manifests from different locations and in different formats. Supported protocols in DB populator are Git and local files. To be able to use it locally when Capact is running in a Kubernetes cluster, two ports need to be forwarded: