func generateAdlsGenOneJson()

in cmd/mountgen1.go [152:227]


func generateAdlsGenOneJson() error {
	rustFuseMap := make(map[string]interface{})
	if strings.ToLower(azStorageOpt.AuthMode) == "spn" {
		// adlsgen1fuse will be reading secret from env variable (ADL_CLIENT_SECRET) hence no reason to include this.
		// rustFuseMap["clientsecret"] = azStorageOpt.ClientSecret

		rustFuseMap["clientid"] = azStorageOpt.ClientID
		rustFuseMap["tenantid"] = azStorageOpt.TenantID
		if azStorageOpt.ActiveDirectoryEndpoint != "" {
			rustFuseMap["authorityurl"] = azStorageOpt.ActiveDirectoryEndpoint
		} else {
			rustFuseMap["authorityurl"] = "https://login.microsoftonline.com"
		}

		rustFuseMap["credentialtype"] = "servicePrincipal"
	} else {
		return fmt.Errorf("for Gen1 account only SPN auth is supported")
	}

	rustFuseMap["resourceurl"] = "https://datalake.azure.net/"

	if libFuseOpt.AttributeExpiration != 0 {
		rustFuseMap["fuseattrtimeout"] = libFuseOpt.AttributeExpiration
	}

	if libFuseOpt.EntryExpiration != 0 {
		rustFuseMap["fuseentrytimeout"] = libFuseOpt.EntryExpiration
	}

	var allowOther bool
	err := config.UnmarshalKey("allow-other", &allowOther)
	if err != nil {
		log.Err("mountgen1 : generateAdlsGenOneJson:allow-other config error (invalid config attributes) [%s]", err.Error())
		return fmt.Errorf("unable to parse allow-other config [%s]", err.Error())
	}

	rustFuseMap["fuseallowother"] = allowOther

	if options.Logging.LogLevel != "" {
		rustFuseMap["loglevel"] = strings.ToUpper(options.Logging.LogLevel)
	}

	if azStorageOpt.MaxRetries != 0 {
		rustFuseMap["retrycount"] = azStorageOpt.MaxRetries
	}

	if fileCacheOpt.MaxSizeMB != 1000 {
		rustFuseMap["maxcachesizeinmb"] = fileCacheOpt.MaxSizeMB
	}

	if requiredFreeSpace != 0 {
		rustFuseMap["requiredfreespaceinmb"] = requiredFreeSpace
	}

	if fileCacheOpt.TmpPath != "" {
		rustFuseMap["cachedir"] = common.ExpandPath(fileCacheOpt.TmpPath)
	}

	if azStorageOpt.Container != "" {
		rustFuseMap["resourceid"] = "adl://" + azStorageOpt.AccountName + ".azuredatalakestore.net/" + azStorageOpt.Container + "/"
	} else {
		rustFuseMap["resourceid"] = "adl://" + azStorageOpt.AccountName + ".azuredatalakestore.net/"
	}

	rustFuseMap["mountdir"] = options.MountPath

	jsonData, _ := json.MarshalIndent(rustFuseMap, "", "\t")

	err = os.WriteFile(gen1ConfigFilePath, jsonData, 0777)
	if err != nil {
		log.Err("mountgen1 : generateAdlsGenOneJson:failed to write adlsgen1fuse.json [%s]", err.Error())
		return fmt.Errorf("failed to write adlsgen1fuse.json [%s]", err.Error())
	}

	return nil
}