From 6b8512de9ef49ee16a748a844bf2916f272754ef Mon Sep 17 00:00:00 2001 From: Harikrishnan Balagopal Date: Thu, 29 Sep 2022 14:08:21 +0530 Subject: [PATCH 1/2] chore: update the go.mod file to fix minor issues Signed-off-by: Harikrishnan Balagopal --- go.mod | 4 ++-- go.sum | 4 ---- transformer/transformer.go | 42 +++++++++++++++++++++----------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/go.mod b/go.mod index db736fa35..f6bff2be0 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,8 @@ require ( github.com/BurntSushi/toml v1.0.0 github.com/Masterminds/semver/v3 v3.1.1 github.com/Masterminds/sprig v2.22.0+incompatible + github.com/antchfx/xmlquery v1.3.12 + github.com/antchfx/xpath v1.2.1 github.com/argoproj/argo-cd/v2 v2.3.5 github.com/cloudfoundry-community/go-cfclient v0.0.0-20220509215243-5e4f7e9cf503 github.com/cloudfoundry/bosh-cli v6.4.1+incompatible @@ -69,8 +71,6 @@ require ( github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/acomagu/bufpipe v1.0.3 // indirect github.com/andybalholm/cascadia v1.3.1 // indirect - github.com/antchfx/xmlquery v1.3.12 // indirect - github.com/antchfx/xpath v1.2.1 // indirect github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20211106181442-e4c1a74c66bd // indirect github.com/argoproj/gitops-engine v0.6.2 // indirect github.com/argoproj/pkg v0.11.1-0.20211203175135-36c59d8fafe0 // indirect diff --git a/go.sum b/go.sum index bbbcd20ad..4fafb6835 100644 --- a/go.sum +++ b/go.sum @@ -636,8 +636,6 @@ github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TT github.com/docker/distribution v2.6.0-rc.1.0.20180327202408-83389a148052+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/distribution v2.8.0+incompatible h1:l9EaZDICImO1ngI+uTifW+ZYvvz7fKISBAKpg+MbWbY= -github.com/docker/distribution v2.8.0+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v0.0.0-20200511152416-a93e9eb0e95c/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= @@ -1596,8 +1594,6 @@ github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zM github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.2-0.20211117181255-693428a734f5/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.3-0.20211202222133-eacdcc10569b/go.mod h1:j4h1pJW6ZcJTgMZWP3+7RlG3zTaP02aDZ/Qw0sppK7Q= -github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198 h1:+czc/J8SlhPKLOtVLMQc+xDCFBT73ZStMsRhSsUhsSg= -github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198/go.mod h1:j4h1pJW6ZcJTgMZWP3+7RlG3zTaP02aDZ/Qw0sppK7Q= github.com/opencontainers/image-spec v1.0.3-0.20220825233605-bc9c4bd9b2a4 h1:7ACimcrIs4exQjkJI4epJCYdgd1WX8AB6UcAKkO4LK8= github.com/opencontainers/image-spec v1.0.3-0.20220825233605-bc9c4bd9b2a4/go.mod h1:K/JAU0m27RFhDRX4PcFdIKntROP6y5Ed6O91aZYDQfs= github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= diff --git a/transformer/transformer.go b/transformer/transformer.go index 017e4c087..928fe0f43 100644 --- a/transformer/transformer.go +++ b/transformer/transformer.go @@ -268,7 +268,7 @@ func GetInitializedTransformersF(filters labels.Selector) []Transformer { // GetServices returns the list of services detected in a directory func GetServices(prjName string, dir string) (map[string][]plantypes.PlanArtifact, error) { - services := map[string][]plantypes.PlanArtifact{} + planServices := map[string][]plantypes.PlanArtifact{} logrus.Infoln("Planning started on the base directory") logrus.Debugf("Transformers: %+v", transformers) for _, transformer := range transformers { @@ -284,30 +284,30 @@ func GetServices(prjName string, dir string) (map[string][]plantypes.PlanArtifac newServices, err := transformer.DirectoryDetect(env.Encode(dir).(string)) if err != nil { logrus.Errorf("[%s] Failed . Error: %q", config.Name, err) - } else { - newServices := getPlanArtifactsFromArtifacts(*env.Decode(&newServices).(*map[string][]transformertypes.Artifact), config) - services = plantypes.MergeServices(services, newServices) - if len(newServices) > 0 { - logrus.Infof(getNamedAndUnNamedServicesLogMessage(newServices)) - } - common.PlanProgressNumBaseDetectTransformers++ - logrus.Infof("[%s] Done", config.Name) + continue } + newPlanServices := getPlanArtifactsFromArtifacts(*env.Decode(&newServices).(*map[string][]transformertypes.Artifact), config) + planServices = plantypes.MergeServices(planServices, newPlanServices) + if len(newPlanServices) > 0 { + logrus.Infof(getNamedAndUnNamedServicesLogMessage(newPlanServices)) + } + common.PlanProgressNumBaseDetectTransformers++ + logrus.Infof("[%s] Done", config.Name) } - logrus.Infof("[Base Directory] %s", getNamedAndUnNamedServicesLogMessage(services)) + logrus.Infof("[Base Directory] %s", getNamedAndUnNamedServicesLogMessage(planServices)) logrus.Infoln("Planning finished on the base directory") logrus.Infoln("Planning started on its sub directories") - nservices, err := walkForServices(dir, services) + nservices, err := walkForServices(dir, planServices) if err != nil { logrus.Errorf("Transformation planning - Directory Walk failed : %s", err) } else { - services = nservices + planServices = nservices logrus.Infoln("Planning finished on its sub directories") } - logrus.Infof("[Directory Walk] %s", getNamedAndUnNamedServicesLogMessage(services)) - services = nameServices(prjName, services) - logrus.Infof("[Named Services] Identified %d named services", len(services)) - return services, nil + logrus.Infof("[Directory Walk] %s", getNamedAndUnNamedServicesLogMessage(planServices)) + planServices = nameServices(prjName, planServices) + logrus.Infof("[Named Services] Identified %d named services", len(planServices)) + return planServices, nil } func walkForServices(inputPath string, bservices map[string][]plantypes.PlanArtifact) (map[string][]plantypes.PlanArtifact, error) { @@ -370,9 +370,13 @@ func walkForServices(inputPath string, bservices map[string][]plantypes.PlanArti newPlanServices := getPlanArtifactsFromArtifacts(*env.Decode(&newServicesToArtifacts).(*map[string][]transformertypes.Artifact), config) services = plantypes.MergeServices(services, newPlanServices) logrus.Debugf("[%s] Done", config.Name) - numfound += len(newServicesToArtifacts) - if len(newServicesToArtifacts) > 0 { - relpath, _ := filepath.Rel(inputPath, path) + numfound += len(newPlanServices) + if len(newPlanServices) > 0 { + relpath, err := filepath.Rel(inputPath, path) + if err != nil { + logrus.Errorf("failed to make the directory %s relative to the input directory %s . Error: %q", path, inputPath, err) + continue + } logrus.Infof("%s in %s", getNamedAndUnNamedServicesLogMessage(newPlanServices), relpath) } } From 074cd1c63a13552a88087481eb36109294b85ec6 Mon Sep 17 00:00:00 2001 From: Harikrishnan Balagopal Date: Sun, 2 Oct 2022 16:30:45 +0530 Subject: [PATCH 2/2] fixup! chore: update the go.mod file to fix minor issues Signed-off-by: Harikrishnan Balagopal --- transformer/transformer.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/transformer/transformer.go b/transformer/transformer.go index 928fe0f43..b71c5e28f 100644 --- a/transformer/transformer.go +++ b/transformer/transformer.go @@ -372,12 +372,14 @@ func walkForServices(inputPath string, bservices map[string][]plantypes.PlanArti logrus.Debugf("[%s] Done", config.Name) numfound += len(newPlanServices) if len(newPlanServices) > 0 { + msg := getNamedAndUnNamedServicesLogMessage(newPlanServices) relpath, err := filepath.Rel(inputPath, path) if err != nil { logrus.Errorf("failed to make the directory %s relative to the input directory %s . Error: %q", path, inputPath, err) + logrus.Infof("%s in %s", msg, path) continue } - logrus.Infof("%s in %s", getNamedAndUnNamedServicesLogMessage(newPlanServices), relpath) + logrus.Infof("%s in %s", msg, relpath) } } logrus.Debugf("planning finished for the directory %s and %d services were detected", path, numfound)