func ProcessAkSkConfig(appInsId, appName string, req *models.InstantiateRequest, clientIp string,
	tenantId string) (error, config.AppConfigAdapter) {
	var applicationConfig config.ApplicationConfig
	appAuthConfig := config.NewAppAuthCfg(appInsId)
	if req.Parameters["ak"] == "" || req.Parameters["sk"] == "" {
		err := appAuthConfig.GenerateAkSK()
		if err != nil {
			return err, config.AppConfigAdapter{}
		}
		req.Parameters["ak"] = appAuthConfig.Ak
		req.Parameters["sk"] = appAuthConfig.Sk
		req.AkSkLcmGen = true
	} else {
		appAuthConfig.Ak = req.Parameters["ak"]
		appAuthConfig.Sk = req.Parameters["sk"]
		req.AkSkLcmGen = false
	}
	appConfigFile, err := getApplicationConfigFile(tenantId, req.PackageId)
	if err != nil {
		log.Error("failed to get application configuration file")
		return err, config.AppConfigAdapter{}
	}
	configYaml, err := os.Open(PackageFolderPath + tenantId + "/" + req.PackageId + "/APPD/" + appConfigFile)
	if err != nil {
		log.Error("failed to read app config file")
		return err, config.AppConfigAdapter{}
	}
	defer configYaml.Close()
	mfFileBytes, _ := ioutil.ReadAll(configYaml)
	data, err := yaml.YAMLToJSON(mfFileBytes)
	if err != nil {
		log.Error(util.FailedToCovertYamlToJson)
		return err, config.AppConfigAdapter{}
	}
	err = json.Unmarshal(data, &applicationConfig)
	if err != nil {
		log.Error(util.UnMarshalError)
		return err, config.AppConfigAdapter{}
	}
	acm := config.NewAppConfigMgr(appInsId, appName, appAuthConfig, applicationConfig)
	err = acm.PostAppAuthConfig(clientIp)
	if err != nil {
		return err, config.AppConfigAdapter{}
	}
	return nil, acm
}
Process Ak Sk configuration
package controllers
import (
	"archive/zip"
	"encoding/json"
	"errors"
	"io"
	"io/ioutil"
	"lcmcontroller/config"
	"lcmcontroller/models"
	"path"
	"path/filepath"
	"strings"
	"unsafe"
	"github.com/ghodss/yaml"
	"lcmcontroller/util"
	"os"
	log "github.com/sirupsen/logrus"
)
var (
	PackageFolderPath   = "/usr/app/packages/"
)
type LcmController struct {
	BaseController
}
func extractCsarPackage(packagePath string) (string, error) {
	zipReader, _ := zip.OpenReader(packagePath)
	if len(zipReader.File) > util.TooManyFile {
		return "", errors.New("Too many files contains in zip file")
	}
	defer zipReader.Close()
	var totalWrote int64
	packageDir := path.Dir(packagePath)
	err := os.MkdirAll(packageDir, 0750)
	if err != nil {
		log.Error(util.FailedToMakeDir)
		return "" ,errors.New(util.FailedToMakeDir)
	}
	for _, file := range zipReader.Reader.File {
		zippedFile, err := file.Open()
		if err != nil || zippedFile == nil {
			log.Error("Failed to open zip file")
			continue
		}
		if file.UncompressedSize64 > util.SingleFileTooBig || totalWrote > util.TooBig {
			log.Error("File size limit is exceeded")
		}
		defer zippedFile.Close()
		isContinue, wrote := extractFiles(file, zippedFile, totalWrote, packageDir)
		if isContinue {
			continue
		}
		totalWrote = wrote
	}
	return packageDir, nil
}
func extractFiles(file *zip.File, zippedFile io.ReadCloser, totalWrote int64, dirName string) (bool, int64) {
	targetDir := dirName
	extractedFilePath := filepath.Join(
		targetDir,
		file.Name,
	)
	if file.FileInfo().IsDir() {
		err := os.MkdirAll(extractedFilePath, 0750)
		if err != nil {
			log.Error("Failed to create directory")
		}
	} else {
		outputFile, err := os.OpenFile(
			extractedFilePath,
			os.O_WRONLY|os.O_CREATE|os.O_TRUNC,
			0750,
		)
		if err != nil || outputFile == nil {
			log.Error("The output file is nil")
			return true, totalWrote
		}
		defer outputFile.Close()
		wt, err := io.Copy(outputFile, zippedFile)
		if err != nil {
			log.Error("Failed to copy zipped file")
		}
		totalWrote += wt
	}
	return false, totalWrote
}