Пример #1
0
            request.get(url, (err, response, body) => {
                if (err) {
                    log.error(
                        {
                            url,
                            error: err.message,
                            stack: err.stack,
                        },
                        'Failed to access Rancher metadata service, are you running in Rancher?'
                    );
                } else if (response.statusCode >= 400) {
                    log.error(
                        {
                            url,
                        },
                        `Rancher metadata service returned ${response.statusCode}. ` +
                        'Are you running in Rancher?'
                    );
                } else if (body) {
                    log.info(`Rancher environment ${body}`);
                    this.data[prop] = body;
                }

                currentProp += 1;
                if (currentProp === numberOfProps) {
                    // Don't allow this object to be edited, just to make sure
                    this.data = deepFreeze(this.data);
                }
            });
Пример #2
0
        request.get(envUrl, (err, response, body) => {
            if (err) {
                log.error(
                    {
                        url: envUrl,
                        error: err.message,
                        stack: err.stack,
                    },
                    'Failed to access Rancher metadata service, are you running in Rancher?'
                );
            } else if (response.statusCode >= 400) {
                log.error(
                    {
                        url: envUrl,
                    },
                    `Rancher metadata service returned ${response.statusCode}. ` +
                    'Are you running in Rancher?'
                );
            } else if (body) {
                log.info(`Rancher environment ${body}`);
                this.data.environment = body.toString('utf8').toLowerCase();
            }

            currentProp += 1;
            if (currentProp === numberOfProps) {
                this.data = deepFreeze(this.data);
            }
        });