Commit Graph

19 Commits

Author SHA1 Message Date
Patrik Cyvoct
5ab6b88029
Add Scaleway provider in metadata package
Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2018-06-14 11:51:03 +02:00
Ian Campbell
826ee28c8d metadata: print Entry objects with %+v not %s
go_vet (via https://goreportcard.com/report/github.com/linuxkit/linuxkit)
reported:

    error: arg current for printf verb %s of wrong type: main.Entry (vet)

For each of these.

Signed-off-by: Ian Campbell <ijc@docker.com>
2018-01-15 17:24:36 +00:00
Avi Deitcher
2af908d1b7 Move metadata to /run instead of /var
Signed-off-by: Avi Deitcher <avi@deitcher.net>
2018-01-15 14:23:03 +02:00
Guillaume Rose
06e86154b6 metadata: handle json with more than 2 levels
Signed-off-by: Guillaume Rose <guillaume.rose@docker.com>
2017-11-13 14:35:17 +01:00
Nick Jones
5663112822
Fix typo which broke metadata retrieval
Signed-off-by: Nick Jones <nick@dischord.org>
2017-10-18 22:47:03 +01:00
Nick Jones
6deabe8a2f
[OpenStack] Metadata service support
This commit adds support for retrieving instance metadata on OpenStack
public clouds.

Signed-off-by: Nick Jones <nick@dischord.org>
2017-10-08 17:08:00 +01:00
Justin Cormack
92451cf2e4 Add packet metadata support, with bonding
Use the packet metadata to set up bonding, also get ssh keys and hostname.

This does not yet do anything with disk metadata.

Userdata is not used if it has been used for ipxe, but is otherwise available.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-08-19 19:25:14 +01:00
Justin Cormack
9d8f1bd900 Allow specifying a set of metadata providers
run with `cmd: ["metadata", "aws"]` to just check for AWS metadata for example.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-08-17 14:50:50 +01:00
Justin Cormack
4434ecc4af Support multiple CDROMS in metadata
This checks if any CDROM in the system has metadata. Useful if
you boot off CDROM and also have a metadata CDROM.

Also switch the metadata container to read only, as it is only
writing to bind mounted in directories, and /tmp.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
2017-08-03 14:16:02 +01:00
David Scott
5bf6526380 metadata: avoid printing large chunks of configuration json to the console
If the configuration .json has contents like:

{
  "etc": {
    "ssl": {
      "certs": {
        "ca-certificates.crt": {
          "perm": "0644",
          "content": "large amount of certificate text"
        }
      }
    }
  },
...
}

then we print a warning because the node "ssl" has no "perm".
Previously the warning would include the contents of "ssl", which
would be large (and in theory could include secret information).

This patch modifies the warning print to only print the key and
not the value.

Without this patch, I see on the console:

2017/07/20 10:03:04 CDROM: Probe succeeded
2017/07/20 10:03:04 No permission provided ssl:map[certs:map[ca-certificates.crt:map[perm:0644 content:large amount of certificate text]]]
 - 000-metadata

With this patch, I see on the console:

2017/07/20 09:54:18 CDROM: Probe succeeded
2017/07/20 09:54:18 No permission provided ssl
 - 000-metadata

Signed-off-by: David Scott <dave.scott@docker.com>
2017-07-20 11:10:59 +01:00
Rolf Neugebauer
f021bb8aaa pkg: In the metadata package, don't error if a dir exists
Use os.Mkdirall() instead of os.Mkdir() as it does not
error if the path already exists.

This enables specifying a default config file with the image
and then over writing it with metadata.

While at it, also update to the latest alpine base image.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
2017-07-07 18:29:02 +01:00
Luke Hodkinson
3dc23b96ac Add a metadata provider for Vultr
Vultr uses a very similar approach to AWS, including using the
same IP address for serving metadata. In fact, it seems
as though if AWS appears first in the list of providers, that
provider mistakenly believes to be running on AWS (hence the
insertion of `NewVultr` in between GCP and AWS. I don't believe
AWS servers will accidentally try to use the Vultr provider,
as it seems that the `/v1/` endpoint doesn't exist on AWS.

Signed-off-by: Luke Hodkinson <furious.luke@gmail.com>
2017-06-24 07:43:07 +10:00
Ken Cochrane
60d099176c Added AWS provider to metadata package
Signed-off-by: Ken Cochrane <kencochrane@gmail.com>
2017-06-01 16:44:58 -04:00
Ian Campbell
800badea42 metadata: Allow simple string keys
If a file is a simple string (as opposed to a map) then write it with the
default perms. This makes for slightly terser metadata when creating a simple
datafile.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-05-11 01:39:03 +01:00
Ian Campbell
8fd1a3cbdb metadata: Fix parsing of JSON
`ok` was not assigned when type casting to `map[string]interface{}` so the
subsequent check was testing a stale value.

Also, the error message upon failure had the wrong sense.

Signed-off-by: Ian Campbell <ian.campbell@docker.com>
2017-05-10 17:37:45 +01:00
Rolf Neugebauer
ce52c28cf6 metadata: Write the provider to /var/config/provider
This will be useful for testing.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
2017-04-12 15:39:08 +01:00
Rolf Neugebauer
b0a0b4ceb7 metadata: Make JSON parser more robust
Make sure the type conversions are OK.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
2017-04-12 15:39:08 +01:00
Rolf Neugebauer
626f02def2 metadata: Improve logging
Implementing a String() interface for each provider makes it
easier for users to prefix log strings with the provider.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
2017-04-12 15:39:08 +01:00
Rolf Neugebauer
766e1d95d3 pkg: Add a generic metadata package
This package handles meta and user data for different cloud
and other platforms. It should be easy to extend to new
platforms.

Currently, it handles GCP metadata and a simple CDROM userdata
provider.

Signed-off-by: Rolf Neugebauer <rolf.neugebauer@docker.com>
2017-04-11 15:32:17 +01:00