-
Notifications
You must be signed in to change notification settings - Fork 246
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
providers: add support for ionos cloud
Add support for IONOS Cloud Add check to ignore cloud-config
- Loading branch information
1 parent
a204f42
commit b458ea9
Showing
6 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright 2019 Red Hat, 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 IONOSCloud provider fetches configurations from the userdata available in | ||
// the injected file /var/lib/cloud/seed/nocloud/user-data. | ||
// NOTE: This provider is still EXPERIMENTAL. | ||
|
||
package ionoscloud | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/coreos/ignition/v2/config/v3_6_experimental/types" | ||
"github.com/coreos/ignition/v2/internal/platform" | ||
"github.com/coreos/ignition/v2/internal/providers/util" | ||
"github.com/coreos/ignition/v2/internal/resource" | ||
|
||
"github.com/coreos/vcontext/report" | ||
) | ||
|
||
const ( | ||
defaultFilename = "/var/lib/cloud/seed/nocloud/user-data" | ||
) | ||
|
||
func init() { | ||
platform.Register(platform.Provider{ | ||
Name: "ionoscloud", | ||
Fetch: fetchConfig, | ||
}) | ||
} | ||
|
||
func fetchConfig(f *resource.Fetcher) (types.Config, report.Report, error) { | ||
f.Logger.Info("using config file at %q", defaultFilename) | ||
|
||
rawConfig, err := os.ReadFile(defaultFilename) | ||
if err != nil { | ||
f.Logger.Err("couldn't read config %q: %v", defaultFilename, err) | ||
return types.Config{}, report.Report{}, err | ||
} | ||
|
||
if util.IsCloudConfig(rawConfig) { | ||
f.Logger.Debug("config drive (%q) contains a cloud-config configuration, ignoring", defaultFilename) | ||
return types.Config{}, report.Report{}, err | ||
} | ||
|
||
return util.ParseConfig(f.Logger, rawConfig) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package util | ||
|
||
import ( | ||
"bytes" | ||
) | ||
|
||
func IsCloudConfig(contents []byte) bool { | ||
header := []byte("#cloud-config\n") | ||
if bytes.HasPrefix(contents, header) { | ||
return true | ||
} | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters