All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.amazonaws.athena.connector.integ.providers.ConnectorEnvironmentVarsProvider Maven / Gradle / Ivy

There is a newer version: 2024.46.1
Show newest version
/*-
 * #%L
 * Amazon Athena Query Federation Integ Test
 * %%
 * Copyright (C) 2019 - 2021 Amazon Web Services
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package com.amazonaws.athena.connector.integ.providers;

import com.amazonaws.athena.connector.integ.data.TestConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Map;

/**
 * Responsible for providing the Connector's Environment vars added to the Connector's stack attributes and used
 * in the creation of the Lambda.
 */
public class ConnectorEnvironmentVarsProvider
{
    private static final Logger logger = LoggerFactory.getLogger(ConnectorEnvironmentVarsProvider.class);

    private static final String TEST_CONFIG_ENVIRONMENT_VARS = "environment_vars";

    private ConnectorEnvironmentVarsProvider() {}

    /**
     * Gets the environment variables used for configuring the Lambda function (e.g. spill_bucket, etc...)
     * @param testConfig A Map containing the test configuration attributes extracted from a config file.
     * @return Map containing the Lambda's environment variables and their associated values if the vars
     * are included in test-config.json.
     */
    public static Map getVars(TestConfig testConfig)
    {
        // Get environment vars.
        Map environmentVars = testConfig.getStringMap(TEST_CONFIG_ENVIRONMENT_VARS).orElseThrow(() ->
                new RuntimeException(TEST_CONFIG_ENVIRONMENT_VARS + " must be specified in test-config.json"));

        logger.info("Environment vars: {}", environmentVars);

        return environmentVars;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy