Skip to content

Commit

Permalink
Merge pull request #869 from ashcrow/aliyun
Browse files Browse the repository at this point in the history
providers/aliyun: Add aliyun
  • Loading branch information
ashcrow committed Oct 9, 2019
2 parents 2bb7d93 + 19d0d6c commit 497ef9b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/platform/platform.go
Expand Up @@ -19,6 +19,7 @@ import (

"github.com/coreos/ignition/v2/internal/log"
"github.com/coreos/ignition/v2/internal/providers"
"github.com/coreos/ignition/v2/internal/providers/aliyun"
"github.com/coreos/ignition/v2/internal/providers/aws"
"github.com/coreos/ignition/v2/internal/providers/azure"
"github.com/coreos/ignition/v2/internal/providers/cloudstack"
Expand Down Expand Up @@ -73,6 +74,10 @@ func (c Config) Status(stageName string, f resource.Fetcher, statusErr error) er
var configs = registry.Create("platform configs")

func init() {
configs.Register(Config{
name: "aliyun",
fetch: aliyun.FetchConfig,
})
configs.Register(Config{
name: "azure",
fetch: azure.FetchConfig,
Expand Down
47 changes: 47 additions & 0 deletions internal/providers/aliyun/aliyun.go
@@ -0,0 +1,47 @@
// Copyright 2019 Red Hat
//
// 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 aliyun provider fetches a remote configuration from the
// aliyun user-data metadata service URL.

package aliyun

import (
"net/url"

"github.com/coreos/ignition/v2/config/v3_1_experimental/types"
"github.com/coreos/ignition/v2/internal/providers/util"
"github.com/coreos/ignition/v2/internal/resource"

"github.com/coreos/vcontext/report"
)

var (
userdataUrl = url.URL{
Scheme: "http",
Host: "100.100.100.200",
Path: "latest/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 && err != resource.ErrNotFound {
return types.Config{}, report.Report{}, err
}

return util.ParseConfig(f.Logger, data)
}

0 comments on commit 497ef9b

Please sign in to comment.