Provide a {@link PgConnectOptions} configured with environment variables, if the environment variable
is not set, then a default value will take precedence over this.
514087
public static PgConnectOptions fromEnv() {
    PgConnectOptions pgConnectOptions = new PgConnectOptions();

    if (getenv("PGHOSTADDR") == null) {
      if (getenv("PGHOST") != null) {
        pgConnectOptions.setHost(getenv("PGHOST"));
      }
    } else {
      pgConnectOptions.setHost(getenv("PGHOSTADDR"));
    }

    if (getenv("PGPORT") != null) {
      try {
        pgConnectOptions.setPort(parseInt(getenv("PGPORT")));
      } catch (NumberFormatException e) {
        // port will be set to default
      }
    }

    if (getenv("PGDATABASE") != null) {
      pgConnectOptions.setDatabase(getenv("PGDATABASE"));
    }
    if (getenv("PGUSER") != null) {
      pgConnectOptions.setUser(getenv("PGUSER"));
    }
    if (getenv("PGPASSWORD") != null) {
      pgConnectOptions.setPassword(getenv("PGPASSWORD"));
    }
    if (getenv("PGSSLMODE") != null) {
      pgConnectOptions.setSslMode(SslMode.of(getenv("PGSSLMODE")));
    }
    return pgConnectOptions;
  }
1075185
def SetEnvironmentVariable(self, name, value):
    
    if isinstance(value, py2to3.STRING_TYPES):
      value = self._PathStripPrefix(value)

    if value is not None:
      self._environment_variables[name.upper()] = value
1161249
def set_env_or_defaults(self):
        
        option = namedtuple('Option', ['section', 'name', 'env_var',
                                       'default_value'])

        options = [option('auth', 'user', 'NAPPS_USER', None),
                   option('auth', 'token', 'NAPPS_TOKEN', None),
                   option('napps', 'api', 'NAPPS_API_URI',
                          'https://napps.kytos.io/api/'),
                   option('napps', 'repo', 'NAPPS_REPO_URI',
                          'https://napps.kytos.io/repo'),
                   option('kytos', 'api', 'KYTOS_API',
                          'http://localhost:8181/')]

        for option in options:
            if not self.config.has_option(option.section, option.name):
                env_value = os.environ.get(option.env_var,
                                           option.default_value)
                if env_value:
                    self.config.set(option.section, option.name, env_value)

        self.config.set('global', 'debug', str(self.debug))
419156
function defaultOptions(options) {
    const optionsDefault = {
        validateBeforeSave: true,
        explicitOnly: true,
        queries: {
            readAll: false,
            format: queries.formats.JSON,
        },
    };
    options = extend(true, {}, optionsDefault, options);
    if (options.joi) {
        const joiOptionsDefault = {
            options: {
                allowUnknown: options.explicitOnly !== true,
            },
        };
        if (is.object(options.joi)) {
            options.joi = extend(true, {}, joiOptionsDefault, options.joi);
        } else {
            options.joi = Object.assign({}, joiOptionsDefault);
        }
        if (!Object.prototype.hasOwnProperty.call(options.joi.options, 'stripUnknown')) {
            options.joi.options.stripUnknown = options.joi.options.allowUnknown !== true;
        }
    }
    return options;
}
547833
protected void configurePropertySources(ConfigurableEnvironment environment,
			String[] args) {
		MutablePropertySources sources = environment.getPropertySources();
		if (this.defaultProperties != null && !this.defaultProperties.isEmpty()) {
			sources.addLast(
					new MapPropertySource("defaultProperties", this.defaultProperties));
		}
		if (this.addCommandLineProperties && args.length > 0) {
			String name = CommandLinePropertySource.COMMAND_LINE_PROPERTY_SOURCE_NAME;
			if (sources.contains(name)) {
				PropertySource<?> source = sources.get(name);
				CompositePropertySource composite = new CompositePropertySource(name);
				composite.addPropertySource(new SimpleCommandLinePropertySource(
						"springApplicationCommandLineArgs", args));
				composite.addPropertySource(source);
				sources.replace(name, composite);
			}
			else {
				sources.addFirst(new SimpleCommandLinePropertySource(args));
			}
		}
	}
283524
private void overrideFromSystemProperties() {
        String  url = System.getProperty("activejdbc.url");
        String  user = System.getProperty("activejdbc.user");
        String  password = System.getProperty("activejdbc.password");
        String  driver = System.getProperty("activejdbc.driver");
        if(!blank(url) && !blank(user) && !blank(driver)){
            connectionSpecMap.put(getEnvironment(), new ConnectionJdbcSpec(driver, url, user, password));
        }

        String  jndi = System.getProperty("activejdbc.jndi");
        if(!blank(jndi)){
            connectionSpecMap.put(getEnvironment(), new ConnectionJndiSpec(jndi));
        }
    }
76204
public ConnectionInput withConnectionProperties(java.util.Map<String, String> connectionProperties) {
        setConnectionProperties(connectionProperties);
        return this;
    }
1245780
public static void setDefaultEnvironment(String environment) {
    System.setProperty("pelzer.environment", environment);
    Logging.getLogger(EnvironmentManager.class);
    PropertyManager.setDefaultEnvironment(environment);
  }
975551
public LaunchConfig withEnvironmentVariables(java.util.Map<String, String> environmentVariables) {
        setEnvironmentVariables(environmentVariables);
        return this;
    }
1010115
private function setEnvironmentOption()
    {
        if (!array_key_exists('env', $this->options)) {
            $this->options = array_merge(
                $this->options,
                ['env' => App::environment()]
            );
        }
    }
1053942
static <T> boolean setOption(Channel jdkChannel, NioChannelOption<T> option, T value) {
        java.nio.channels.NetworkChannel channel = (java.nio.channels.NetworkChannel) jdkChannel;
        if (!channel.supportedOptions().contains(option.option)) {
            return false;
        }
        if (channel instanceof ServerSocketChannel && option.option == java.net.StandardSocketOptions.IP_TOS) {
            // Skip IP_TOS as a workaround for a JDK bug:
            // See http://mail.openjdk.java.net/pipermail/nio-dev/2018-August/005365.html
            return false;
        }
        try {
            channel.setOption(option.option, value);
            return true;
        } catch (IOException e) {
            throw new ChannelException(e);
        }
    }
334628
public ConnectionOptions withClientProperties(Map<String, Object> clientProperties) {
    factory.setClientProperties(Assert.notNull(clientProperties, "clientProperties"));
    return this;
  }
787600
public static Connector createDefault(Map<String, String> properties) {
        Connector.Builder builder = Connector.Builder.create()
                .rawProperties(properties)
                .secureEnabled(Boolean.parseBoolean(properties.get("ssl.enabled")))
                .sslProtocol(properties.get("ssl.protocol"))
                .sslClientMode(Boolean.parseBoolean(properties.get("ssl.clientMode")))
                .sslNeedClientAuth(Boolean.parseBoolean(properties.get("ssl.needClientAuth")))
                .sslWantClientAuth(Boolean.parseBoolean(properties.get("ssl.wantClientAuth")))
                .sslKeyManagerFactoryAlgorithm(properties.get("ssl.key.manager.factory.algorithm"))
                .sslKeyPassword(properties.get("ssl.key.password"))
                .sslKeyStoreProvider(properties.get("ssl.key.store.provider"))
                .sslKeyStoreType(properties.get("ssl.key.store.type"))
                .sslKeyStorePassword(properties.get("ssl.key.store.password"))
                .sslTrustManagerFactoryAlgorithm(properties.get("ssl.trust.manager.factory.algorithm"))
                .sslTrustPassword(properties.get("ssl.trust.password"))
                .sslTrustStoreProvider(properties.get("ssl.trust.store.provider"))
                .sslTrustStoreType(properties.get("ssl.trust.store.type"))
                .sslTrustStorePassword(properties.get("ssl.trust.store.password"))
                .ajpEnabled(Boolean.parseBoolean(properties.get("ajp.enabled")))
                .host(StringUtils.defaultIfBlank(properties.get("host"), "0.0.0.0"))
                .port(Integer.valueOf(StringUtils.defaultIfBlank(properties.get("port"), "80")))
                .name(properties.get("name"));

        String keyStoreFile = properties.get("ssl.key.store.file");
        if (StringUtils.isNotBlank(keyStoreFile))
            try {
                builder.sslKeyStoreFile(readByteArrayFromResource(keyStoreFile));
            } catch (IOException e) {
                logger.error("读取sslKeyStoreFile出错", e);
            }

        String trustStoreFile = properties.get("ssl.trust.store.file");
        if (StringUtils.isNotBlank(trustStoreFile))
            try {
                builder.sslTrustStoreFile(readByteArrayFromResource(trustStoreFile));
            } catch (IOException e) {
                logger.error("读取sslTrustStoreFile出错", e);
            }

        return builder.build();
    }
1267828
private void processOptions(OptionSet options) {
    Pseudorandom.get().setSeed(options.valueOf(randomSeed));

    if (opts.contains(CommonOptions.MAP_REDUCE)) {
      MapReduceConfiguration.setMapReduceExecutor(new LocalMapReduceExecutor(
          options.valueOf(mrMaxThreads), options.valueOf(mrMaxBatchesPerThread)));
    }

    if (opts.contains(CommonOptions.STOCHASTIC_GRADIENT) || opts.contains(CommonOptions.LBFGS)) {
      LogFunction log = null;
      if (parsedOptions.has(logBrief)) {
        log = new NullLogFunction();
      } else {
         log = new DefaultLogFunction(parsedOptions.valueOf(logInterval), false,
             options.valueOf(logParametersInterval), options.valueOf(logParametersDir));
      }
      LogFunctions.setLogFunction(log);
    }
  }
710569
private void processGeneralOptions(Configuration conf,
      CommandLine line) {
    if (line.hasOption("fs")) {
      FileSystem.setDefaultUri(conf, line.getOptionValue("fs"));
    }

    if (line.hasOption("jt")) {
      conf.set("mapred.job.tracker", line.getOptionValue("jt"));
    }
    if (line.hasOption("conf")) {
      String[] values = line.getOptionValues("conf");
      for(String value : values) {
        conf.addResource(new Path(value));
      }
    }
    try {
      if (line.hasOption("libjars")) {
        conf.set("tmpjars", 
                 validateFiles(line.getOptionValue("libjars"), conf));
        //setting libjars in client classpath
        URL[] libjars = getLibJars(conf);
        if(libjars!=null && libjars.length>0) {
          conf.setClassLoader(new URLClassLoader(libjars, conf.getClassLoader()));
          Thread.currentThread().setContextClassLoader(
              new URLClassLoader(libjars, 
                  Thread.currentThread().getContextClassLoader()));
        }
      }
      if (line.hasOption("files")) {
        conf.set("tmpfiles", 
                 validateFiles(line.getOptionValue("files"), conf));
      }
      if (line.hasOption("archives")) {
        conf.set("tmparchives", 
                  validateFiles(line.getOptionValue("archives"), conf));
      }
    } catch (IOException ioe) {
      System.err.println(StringUtils.stringifyException(ioe));
    }
    if (line.hasOption('D')) {
      String[] property = line.getOptionValues('D');
      for(String prop : property) {
        String[] keyval = prop.split("=", 2);
        if (keyval.length == 2) {
          conf.set(keyval[0], keyval[1]);
        }
      }
    }
    conf.setBoolean("mapred.used.genericoptionsparser", true);
  }
1094198
public synchronized void setOption(String key, String value)
	{
		if (key == null || value == null) {
			return;
		}
		config.put(key, value);
	}
178052
private GlobalOptions createGlobalOptions(CommandLine parsedOpts) {
    String host = parsedOpts.hasOption(HOST_OPT) ?
            parsedOpts.getOptionValue(HOST_OPT) : DEFAULT_REST_SERVER_HOST;
    int port = DEFAULT_REST_SERVER_PORT;
    try {
      if (parsedOpts.hasOption(PORT_OPT)) {
        port = Integer.parseInt(parsedOpts.getOptionValue(PORT_OPT));
      }
    } catch (NumberFormatException e) {
      printHelpAndExit("The port must be a valid integer.");
    }

    return new GlobalOptions(host, port);
  }