func (i InstantiateCCUIObject) generateInstantiateCCObjects(ccObject inputStructs.InstantiateCC, organizations []inputStructs.Organization, tls, action string) ([]InstantiateCCUIObject, error) {
	var instantiateCCObjects []InstantiateCCUIObject
	var err error
	if ccObject.ChannelPrefix != "" && ccObject.NumChannels > 0 {
		instantiateCCObjects, err = i.createInstantiateCCObjectIfChanPrefix(ccObject, organizations, tls, action)
		if err != nil {
			return instantiateCCObjects, err
		}
		return instantiateCCObjects, nil
	}
	orgNames := strings.Split(ccObject.Organizations, ",")
	instantiateCCObjects, err = i.createInstantiateCCObjects(orgNames, ccObject.ChannelName, tls, action, organizations, ccObject)
	if err != nil {
		return instantiateCCObjects, err
	}
	return instantiateCCObjects, nil
}
generateInstantiateCCObjects -- To generate chaincode objects for instantiation/upgrade
package operations
import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/url"
	"strconv"
	"strings"
	"time"
	"github.com/davecgh/go-spew/spew"
	"github.com/hyperledger/fabric-test/tools/operator/connectionprofile"
	"github.com/hyperledger/fabric-test/tools/operator/logger"
	"github.com/hyperledger/fabric-test/tools/operator/networkclient"
	"github.com/hyperledger/fabric-test/tools/operator/paths"
	"github.com/hyperledger/fabric-test/tools/operator/testclient/inputStructs"
	yaml "gopkg.in/yaml.v2"
)
type InstantiateCCUIObject struct {
	SDK             string                   `json:"sdk,omitempty"`
	TransType       string                   `json:"transType,omitempty"`
	TLS             string                   `json:"TLS,omitempty"`
	ChainCodeID     string                   `json:"chaincodeID,omitempty"`
	ChainCodeVer    string                   `json:"chaincodeVer,omitempty"`
	ConnProfilePath string                   `json:"ConnProfilePath,omitempty"`
	ChannelOpt      ChannelOptions           `json:"channelOpt,omitempty"`
	DeployOpt       InstantiateDeployOptions `json:"deploy,omitempty"`
	TimeOutOpt      TimeOutOptions           `json:"timeoutOpt,omitempty"`
	Sequence        string                   `json:"sequence,omitempty"`
	TargetPeers     []string                 `json:"targetPeers,omitempty"`
}
type InstantiateDeployOptions struct {
	Function              string             `json:"fcn,omitempty"`
	Arguments             []string           `json:"args,omitempty"`
	Endorsement           *EndorsementPolicy `json:"endorsement,omitempty"`
	CollectionsConfigPath string             `json:"collectionsConfigPath,omitempty"`
}
type TimeOutOptions struct {
	PreConfig string `json:"preConfig,omitempty"`
	Request   string `json:"request,omitempty"`
}
type EndorsementPolicy struct {
	Identities      []Identity          `json:"identities,omitempty"`
	Policy          map[string][]Policy `json:"policy,omitempty"`
	SignaturePolicy string              `json:"signaturePolicy,omitempty"`
}
type Policy struct {
	SignedBy int `json:"signed-by"`
}
type Identity struct {
	Role struct {
		Name  string `json:"name,omitempty"`
		MSPID string `json:"mspId,omitempty"`
	} `json:"role,omitempty"`
}
type ConnProfileOptions struct {
	Organizations map[string]struct {
		MSPID string   `yaml:"mspid,omitempty"`
		Peers []string `yaml:"peers,omitempty"`
	} `yaml:"organizations,omitempty"`
	Peers map[string]struct {
		URL        string `yaml:"url,omitempty"`
		MetricsURL string `yaml:"metricsURL,omitempty"`
	} `yaml:"peers,omitempty"`
	Orderers map[string]struct {
		URL        string `yaml:"url,omitempty"`
		MetricsURL string `yaml:"metricsURL,omitempty"`
	}
	Channels map[string]struct {
		Orderers []string `yaml:"orderers,omitempty"`
		Peers    []string `yaml:"peers,omitempty"`
	}
}
type InstalledCC struct {
	CC []struct {
		PackageID string `json:"package_id,omitempty"`
		Label     string `json:"label,omitempty"`
	} `json:"installed_chaincodes,omitempty"`
}
func (i InstantiateCCUIObject) InstantiateCC(config inputStructs.Config, tls, action string) error {
	var instantiateCCObjects []InstantiateCCUIObject
	configObjects := config.InstantiateCC
	var ccConfigObjects []interface{}
	if action == "upgrade" {
		configObjects = config.UpgradeCC
	}
	fmt.Printf("\033[1m\nAction:%s\nInput:\033[0m\n%s\n", action, spew.Sdump(configObjects))
	for index := 0; index < len(configObjects); index++ {
		ccObjects, err := i.generateInstantiateCCObjects(configObjects[index], config.Organizations, tls, action)
		if err != nil {
			return err
		}
		ccConfigObjects = append(ccConfigObjects, &configObjects[index])
		instantiateCCObjects = append(instantiateCCObjects, ccObjects...)
	}
	err := i.instantiateCC(instantiateCCObjects)
	if err != nil {
		return err
	}
	var connProfileObject connectionprofile.ConnProfile
	err = connProfileObject.UpdateConnectionProfiles(ccConfigObjects, config.Organizations, action)
	if err != nil {
		return err
	}
	return nil
}