text:
![Version: 1.10.4](https://img.shields.io/badge/Version-1.10.4-informational?style=flat-square) ![AppVersion: 1.10.3](https://img.shields.io/badge/AppVersion-1.10.3-informational?style=flat-square)

Helm chart for net-exporter.

**Homepage:** <https://github.com/giantswarm/net-exporter>

## How to install this chart

Add Delivery Hero public chart repo:

```console
helm repo add deliveryhero https://charts.deliveryhero.io/
```

A simple install with default values:

```console
helm install deliveryhero/net-exporter
```

To install the chart with the release name `my-release`:

```console
helm install my-release deliveryhero/net-exporter
```

To install with some set values:

```console
helm install my-release deliveryhero/net-exporter --set values_key1=value1 --set values_key2=value2
```

To install with custom values file:

```console
helm install my-release deliveryhero/net-exporter -f values.yaml
```

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| NetExporter.DNSCheck.TCP.Disabled | bool | `false` |  |
| NetExporter.Hosts | string | `""` |  |
| NetExporter.NTPServers | string | `""` |  |
| additionalLabels | object | `{}` |  |
| controlPlaneSubnets | list | `[]` |  |
| daemonset.priorityClassName | string | `"system-node-critical"` |  |
| dns.label | string | `"coredns"` |  |
| dns.namespace | string | `"kube-system"` |  |
| dns.port | int | `1053` |  |
| dns.service | string | `"coredns"` |  |
| groupID | int | `1000` |  |
| image.name | string | `"giantswarm/net-exporter"` |  |
| image.registry | string | `"docker.io"` |  |
| image.tag | string | `"[[ .Version ]]"` |  |
| kubectl.image.name | string | `"giantswarm/docker-kubectl"` |  |
| kubectl.image.registry | string | `"docker.io"` |  |
| kubectl.image.tag | string | `"1.18.8"` |  |
| name | string | `"net-exporter"` |  |
| port | int | `8000` |  |
| selector.app | string | `"net-exporter"` |  |
| serviceType | string | `"managed"` |  |
| timeout | string | `"5s"` |  |
| userID | int | `1000` |  |

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| pciang |  | <https://github.com/pciang> |


text:
require_relative "../../spec_helper.rb"
require "ohai/mixin/softlayer_metadata"

describe ::Ohai::Mixin::SoftlayerMetadata do

  let(:mixin) do
    mixin = Object.new.extend(::Ohai::Mixin::SoftlayerMetadata)
    mixin
  end

  def make_request(item)
    "/rest/v3.1/SoftLayer_Resource_Metadata/#{item}"
  end

  def make_res(body)
    double("response", { :body => body, :code => "200" })
  end

  context "fetch_metadata" do
    it "riases error if softlayer api query results with error" do
      http_mock = double("http", { :ssl_version= => true, :use_ssl= => true, :ca_file= => true })
      allow(http_mock).to receive(:get).and_raise(StandardError.new("API return fake error"))
      allow(::Net::HTTP).to receive(:new).with("api.service.softlayer.com", 443).and_return(http_mock)

      expect(::Ohai::Log).to receive(:error).at_least(:once)
      expect { mixin.fetch_metadata }.to raise_error(StandardError)
    end

    it "query api service" do
      http_mock = double("http", { :ssl_version= => true, :use_ssl= => true, :ca_file= => true })
      allow(::Net::HTTP).to receive(:new).with("api.service.softlayer.com", 443).and_return(http_mock)

      expect(http_mock).to receive(:get).with(make_request("getFullyQualifiedDomainName.txt")).and_return(make_res("abc.host.org")).once
      expect(http_mock).to receive(:get).with(make_request("getPrimaryBackendIpAddress.txt")).and_return(make_res("10.0.1.10")).once
      expect(http_mock).to receive(:get).with(make_request("getPrimaryIpAddress.txt")).and_return(make_res("8.8.8.8")).once
      expect(http_mock).to receive(:get).with(make_request("getId.txt")).and_return(make_res("1111")).once
      expect(http_mock).to receive(:get).with(make_request("getDatacenter.txt")).and_return(make_res("dal05")).once

      metadata = mixin.fetch_metadata
      expect(metadata).not_to be_nil
      expect(metadata["public_fqdn"]).to eq("abc.host.org")
      expect(metadata["local_ipv4"]).to  eq("10.0.1.10")
      expect(metadata["instance_id"]).to eq("1111")
      expect(metadata["region"]).to      eq("dal05")
      expect(metadata["public_ipv4"]).to eq("8.8.8.8")
    end
  end
end

redpajama_set_name: RedPajamaGithub