From b9fe7a0a54760a22014f56528c2ed5fc9edd3f30 Mon Sep 17 00:00:00 2001 From: dedene Date: Tue, 27 Nov 2018 09:24:56 +0100 Subject: [PATCH 1/2] providers: add initial hetzner cloud support --- doc/supported-platforms.md | 1 + internal/oem/oem.go | 5 ++++ internal/providers/hcloud/hcloud.go | 46 +++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 internal/providers/hcloud/hcloud.go diff --git a/doc/supported-platforms.md b/doc/supported-platforms.md index 60adc7a21..283db3bcb 100644 --- a/doc/supported-platforms.md +++ b/doc/supported-platforms.md @@ -11,6 +11,7 @@ Ignition is currently only supported for the following platforms: * [Packet] - Ignition will read its configuration from the instance userdata. SSH keys are handled by coreos-metadata. * [QEMU] - Ignition will read its configuration from the 'opt/com.coreos/config' key on the QEMU Firmware Configuration Device. * [DigitalOcean] - Ignition will read its configuration from the droplet userdata. SSH keys and network configuration are handled by coreos-metadata. +* [Hetzner Cloud] - Ignition will read its configuration from the instance userdata. SSH keys are handled by coreos-metadata. Ignition is under active development so expect this list to expand in the coming months. diff --git a/internal/oem/oem.go b/internal/oem/oem.go index e7d422ddc..6ec18856d 100644 --- a/internal/oem/oem.go +++ b/internal/oem/oem.go @@ -25,6 +25,7 @@ import ( "github.com/coreos/ignition/internal/providers/ec2" "github.com/coreos/ignition/internal/providers/file" "github.com/coreos/ignition/internal/providers/gce" + "github.com/coreos/ignition/internal/providers/hcloud" "github.com/coreos/ignition/internal/providers/noop" "github.com/coreos/ignition/internal/providers/openstack" "github.com/coreos/ignition/internal/providers/packet" @@ -110,6 +111,10 @@ func init() { name: "gce", fetch: gce.FetchConfig, }) + configs.Register(Config{ + name: "hcloud", + fetch: hcloud.FetchConfig, + }) configs.Register(Config{ name: "hyperv", fetch: noop.FetchConfig, diff --git a/internal/providers/hcloud/hcloud.go b/internal/providers/hcloud/hcloud.go new file mode 100644 index 000000000..acf22fee5 --- /dev/null +++ b/internal/providers/hcloud/hcloud.go @@ -0,0 +1,46 @@ +// Copyright 2018 CoreOS, Inc. +// +// 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. + +// The hcloud provider fetches a remote configuration from the Hetzner Cloud user-data +// metadata service URL. + +package hcloud + +import ( + "net/url" + + "github.com/coreos/ignition/config/validate/report" + "github.com/coreos/ignition/internal/config/types" + "github.com/coreos/ignition/internal/providers/util" + "github.com/coreos/ignition/internal/resource" +) + +var ( + userdataUrl = url.URL{ + Scheme: "http", + Host: "169.254.169.254", + Path: "2009-04-04/user-data", + } +) + +func FetchConfig(f resource.Fetcher) (types.Config, report.Report, error) { + data, err := f.FetchToBuffer(userdataUrl, resource.FetchOptions{ + Headers: resource.ConfigHeaders, + }) + if err != nil { + return types.Config{}, report.Report{}, err + } + + return util.ParseConfig(f.Logger, data) +} From 444c8a64b556e16c0a91a128949b646d43b00537 Mon Sep 17 00:00:00 2001 From: Peter Dedene Date: Thu, 29 Nov 2018 14:15:51 +0100 Subject: [PATCH 2/2] providers/hcloud: add link to Hetzner Cloud --- doc/supported-platforms.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/supported-platforms.md b/doc/supported-platforms.md index 283db3bcb..06685375d 100644 --- a/doc/supported-platforms.md +++ b/doc/supported-platforms.md @@ -24,3 +24,4 @@ Ignition is under active development so expect this list to expand in the coming [Packet]: https://github.com/coreos/docs/blob/master/os/booting-on-packet.md [QEMU]: https://github.com/qemu/qemu/blob/d75aa4372f0414c9960534026a562b0302fcff29/docs/specs/fw_cfg.txt [DigitalOcean]: https://github.com/coreos/docs/blob/master/os/booting-on-digitalocean.md +[Hetzner Cloud]: https://www.hetzner.com/cloud \ No newline at end of file