get.porter.sh/porter@v1.3.0/pkg/cnab/config-adapter/helpers.go (about)

     1  package configadapter
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/stretchr/testify/require"
     8  
     9  	"get.porter.sh/porter/pkg/cnab"
    10  	"get.porter.sh/porter/pkg/config"
    11  	"get.porter.sh/porter/pkg/manifest"
    12  )
    13  
    14  func LoadTestBundle(t *testing.T, config *config.Config, path string) cnab.ExtendedBundle {
    15  	ctx := context.Background()
    16  	m, err := manifest.ReadManifest(config.Context, path, config)
    17  	require.NoError(t, err)
    18  	b, err := ConvertToTestBundle(ctx, config, m)
    19  	require.NoError(t, err)
    20  	return b
    21  }
    22  
    23  // ConvertToTestBundle is suitable for taking a test manifest (porter.yaml)
    24  // and making a bundle.json for it. Does not make an accurate representation
    25  // of the bundle, but is suitable for testing.
    26  func ConvertToTestBundle(ctx context.Context, cfg *config.Config, manifest *manifest.Manifest) (cnab.ExtendedBundle, error) {
    27  	converter := NewManifestConverter(cfg, manifest, nil, nil, false)
    28  	return converter.ToBundle(ctx)
    29  }