cloud-native-toolkit / iascable

IasCable is a node/typescript library to build installable component infrastructure components from a catalog of available modules
MIT License
13 stars 8 forks source link

when using local module, it is not included in module dependency resolution #240

Open binnes opened 2 years ago

binnes commented 2 years ago

When building a BOM using the -c command line option to include an additional module or catalog, the additional module/catalog is not being used to resolve module dependencies in a BOM

binnes commented 2 years ago

This is still an issue.

To reproduce: clone repo : https://github.com/binnes/terraform-cluster-login

generate local metadata : iascable metadata -moduleUrl file:/automation/terraform-ocp-login

then using BOM:

apiVersion: cloudnativetoolkit.dev/v1alpha1
kind: BillOfMaterial
metadata:
  name: minikube-test
spec:
  modules:
    - name: cluster-login
    - name: olm

run build : iascable build -i testBOM.yaml -c file:/automation/terraform-cluster-login/output/cluster-login/index.yaml

which generates error:

build: Error building config {
  err: MultipleMatchingModules [Error]: More than one module resolves dependency for module: module=olm, dependency=cluster, refs=[{"source":"github.com/cloud-native-toolkit/terraform-ibm-container-platform","version":">= 1.7.0"},{"source":"github.com/cloud-native-toolkit/terraform-ibm-ocp-vpc","version":">= 1.0.0"},{"source":"github.com/cloud-native-toolkit/terraform-ibm-iks-vpc","version":">= 1.0.0"},{"source":"github.com/cloud-native-toolkit/terraform-k8s-ocp-cluster","version":">= 2.0.0"},{"source":"github.com/cloud-native-toolkit/terraform-ocp-login","version":">= 1.0.0"}], matchingModules=cluster,cluster,cluster
      at SelectedModuleResolverImpl.findDependencyInCatalog (/snapshot/iascable/dist/lib/services/module-selector/selected-modules.resolver.js:135:19)
      at /snapshot/iascable/dist/lib/services/module-selector/selected-modules.resolver.js:72:40
      at Array.reduce (<anonymous>)
      at ArrayUtil.reduce (/snapshot/iascable/dist/lib/util/array-util/array-util.js:45:27)
      at SelectedModuleResolverImpl.resolveModuleDependencies (/snapshot/iascable/dist/lib/services/module-selector/selected-modules.resolver.js:55:14)
      at /snapshot/iascable/dist/lib/services/module-selector/selected-modules.resolver.js:37:25
      at Array.reduce (<anonymous>)
      at SelectedModuleResolverImpl.resolveDependencies (/snapshot/iascable/dist/lib/services/module-selector/selected-modules.resolver.js:36:24)
      at SelectedModuleResolverImpl.resolve (/snapshot/iascable/dist/lib/services/module-selector/selected-modules.resolver.js:27:50)
      at Object.resolveSelectedModules (/snapshot/iascable/dist/lib/services/module-selector/selected-modules.resolver.js:15:56) {
    module: {
      cloudProvider: '',
      softwareProvider: '',
      type: 'terraform',
      id: 'github.com/cloud-native-toolkit/terraform-k8s-olm',
      name: 'olm',
      description: 'Installs Operator Lifecycle Manager in the cluster',
      platforms: [Array],
      tags: [Array],
      versions: [Array],
      group: '',
      displayName: 'Operator Lifecycle Manager',
      category: 'infrastructure',
      originalAlias: undefined,
      alias: 'olm',
      bomModule: [Object]
    },
    dep: { id: 'cluster', refs: [Array] },
    matchingModules: [ [Object], [Object], [Object] ]
  }
}

Debug output attached : out.txt