Example #1
0
    def _setup_app_config(self, **kwargs):
        self.app_name = kwargs.get('app')
        self.app_config = kwargs.get('app_config')

        from amplify.agent.common.util import configreader
        if self.app_config is None:
            self.app_config = configreader.read('app', config_file=kwargs.get('config_file'))
        else:
            configreader.CONFIG_CACHE['app'] = self.app_config

        # if the api_url was set in the config and isn't from our receiver's domain then never overwrite it
        api_url = self.app_config.get('cloud', {}).get('api_url', '') or ''
        from_us = api_url.startswith('https://receiver.amplify.nginx.com')
        self.freeze_api_url = bool(api_url) and not from_us

        if kwargs.get('pid_file'):  # If pid_file given in setup, then assume agent running in daemon mode.
            self.app_config['daemon']['pid'] = kwargs.get('pid_file')
            # This means 'daemon' in self.app_config.keys() is a reasonable test for detecting whether agent is running
            # as a daemon or in the foreground (or generically using self.app_config.get('daemon') which will return
            # None if running in foreground).

        # If an image name is not specified, but there is an AMPLIFY_IMAGENAME environment variable, set the config
        # value to the environment value.  This means that config file will always take precedence.  This also means
        # that the app_config is the source of truth for our program logic when trying to determine imagename/whether or
        # not in a container.
        if not self.app_config['credentials']['imagename'] and self.imagename:
            self.app_config['credentials']['imagename'] = self.imagename

        # if in a container, sets self.uuid to a... not... ultimately unique id that's based on the imagename
        if self.app_config['credentials']['imagename']:
            self.app_config['credentials']['uuid'] = 'container-%s' % self.app_config['credentials']['imagename']
Example #2
0
    def _setup_app_config(self, **kwargs):
        self.app_name = kwargs.get('app')
        self.app_config = kwargs.get('app_config')

        from amplify.agent.common.util import configreader
        if self.app_config is None:
            self.app_config = configreader.read('app', config_file=kwargs.get('config_file'))
        else:
            configreader.CONFIG_CACHE['app'] = self.app_config

        if kwargs.get('pid_file'):  # If pid_file given in setup, then assume agent running in daemon mode.
            self.app_config['daemon']['pid'] = kwargs.get('pid_file')
            # This means 'daemon' in self.app_config.keys() is a reasonable test for detecting whether agent is running
            # as a daemon or in the foreground (or generically using self.app_config.get('daemon') which will return
            # None if running in foreground).

        # If an image name is not specified, but there is an AMPLIFY_IMAGENAME environment variable, set the config
        # value to the environment value.  This means that config file will always take precedence.  This also means
        # that the app_config is the source of truth for our program logic when trying to determine imagename/whether or
        # not in a container.
        if not self.app_config['credentials']['imagename'] and self.imagename:
            self.app_config['credentials']['imagename'] = self.imagename

        # if in a container, sets self.uuid to a... not... ultimately unique id that's based on the imagename
        if self.app_config['credentials']['imagename']:
            self.app_config['credentials']['uuid'] = 'container-%s' % self.app_config['credentials']['imagename']
Example #3
0
    def _setup_app_config(self, **kwargs):
        self.app_name = kwargs.get('app')
        self.app_config = kwargs.get('app_config')

        from amplify.agent.common.util import configreader
        if self.app_config is None:
            self.app_config = configreader.read(
                'app', config_file=kwargs.get('config_file'))
        else:
            configreader.CONFIG_CACHE['app'] = self.app_config

        if kwargs.get(
                'pid_file'
        ):  # If pid_file given in setup, then assume agent running in daemon mode.
            self.app_config['daemon']['pid'] = kwargs.get('pid_file')
 def test_read_app_config(self):
     conf = configreader.read('app')
     assert_that(conf, instance_of(object))
     assert_that(conf.config, has_key('daemon'))
     assert_that(conf.config, has_key('credentials'))
Example #5
0
 def test_read_app_config(self):
     conf = configreader.read('app')
     assert_that(conf, instance_of(object))
     assert_that(conf.config, has_key('daemon'))
     assert_that(conf.config, has_key('credentials'))