func()

in pkg/sidecar_mounter/sidecar_mounter_config.go [155:248]


func (mc *MountConfig) prepareMountArgs() {
	flagMap := map[string]string{
		"app-name":    GCSFuseAppName,
		"temp-dir":    mc.BufferDir + TempDir,
		"config-file": mc.ConfigFile,
		"foreground":  "",
		"uid":         "0",
		"gid":         "0",
	}

	configFileFlagMap := map[string]string{
		"logging:file-path": "/dev/fd/1", // redirect the output to cmd stdout
		"logging:format":    "json",
		"cache-dir":         "", // by default the gcsfuse file cache is disabled on GKE
	}

	invalidArgs := []string{}

	for _, arg := range mc.Options {
		if strings.Contains(arg, ":") && !strings.Contains(arg, "https") {
			i := strings.LastIndex(arg, ":")
			f, v := arg[:i], arg[i+1:]

			if f == util.DisableMetricsForGKE {
				if v == util.FalseStr {
					flagMap["prometheus-port"] = strconv.Itoa(prometheusPort)
					// Use a new port each gcsfuse instance that we start.
					prometheusPort++
				}

				continue
			}

			if disallowedFlags[f] {
				invalidArgs = append(invalidArgs, arg)
			} else {
				configFileFlagMap[f] = v
			}

			// if the value of flag file-cache:max-size-mb is not 0,
			// enable the file cache feature by passing the cache directory.
			if f == "file-cache:max-size-mb" && v != "0" {
				configFileFlagMap["cache-dir"] = mc.CacheDir
			}

			continue
		}

		argPair := strings.SplitN(arg, "=", 2)
		if len(argPair) == 0 {
			continue
		}

		flag := argPair[0]
		if disallowedFlags[flag] {
			invalidArgs = append(invalidArgs, arg)

			continue
		}

		value := ""
		if len(argPair) > 1 {
			value = argPair[1]
		}

		if flag == identityProviderFlag {
			mc.TokenServerIdentityProvider = value

			continue
		}

		switch {
		case boolFlags[flag] && value != "":
			flag = flag + "=" + value
			if value == util.TrueStr || value == util.FalseStr {
				value = ""
			} else {
				invalidArgs = append(invalidArgs, flag)

				continue
			}
		case flag == "app-name":
			value = GCSFuseAppName + "-" + value
		}

		flagMap[flag] = value
	}

	if len(invalidArgs) > 0 {
		klog.Warningf("got invalid arguments for volume %q: %v. Will discard invalid args and continue to mount.",
			invalidArgs, mc.VolumeName)
	}
	mc.FlagMap, mc.ConfigFileFlagMap = flagMap, configFileFlagMap
}