Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions internal/exec/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/coreos/ignition/internal/config/types"
"github.com/coreos/ignition/internal/exec/stages"
"github.com/coreos/ignition/internal/log"
"github.com/coreos/ignition/internal/oem"
"github.com/coreos/ignition/internal/platform"
"github.com/coreos/ignition/internal/providers"
"github.com/coreos/ignition/internal/providers/cmdline"
"github.com/coreos/ignition/internal/providers/system"
Expand All @@ -44,12 +44,12 @@ const (

// Engine represents the entity that fetches and executes a configuration.
type Engine struct {
ConfigCache string
FetchTimeout time.Duration
Logger *log.Logger
Root string
OEMConfig oem.Config
Fetcher *resource.Fetcher
ConfigCache string
FetchTimeout time.Duration
Logger *log.Logger
Root string
PlatformConfig platform.Config
Fetcher *resource.Fetcher
}

// Run executes the stage of the given name. It returns true if the stage
Expand Down Expand Up @@ -173,7 +173,7 @@ func (e *Engine) fetchProviderConfig() (types.Config, error) {
fetchers := []providers.FuncFetchConfig{
cmdline.FetchConfig,
system.FetchConfig,
e.OEMConfig.FetchFunc(),
e.PlatformConfig.FetchFunc(),
}

var cfg types.Config
Expand Down
28 changes: 14 additions & 14 deletions internal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
_ "github.com/coreos/ignition/internal/exec/stages/mount"
_ "github.com/coreos/ignition/internal/exec/stages/umount"
"github.com/coreos/ignition/internal/log"
"github.com/coreos/ignition/internal/oem"
"github.com/coreos/ignition/internal/platform"
"github.com/coreos/ignition/internal/version"
)

Expand All @@ -36,7 +36,7 @@ func main() {
clearCache bool
configCache string
fetchTimeout time.Duration
oem oem.Name
platform platform.Name
root string
stage stages.Name
version bool
Expand All @@ -46,7 +46,7 @@ func main() {
flag.BoolVar(&flags.clearCache, "clear-cache", false, "clear any cached config")
flag.StringVar(&flags.configCache, "config-cache", "/run/ignition.json", "where to cache the config")
flag.DurationVar(&flags.fetchTimeout, "fetch-timeout", exec.DefaultFetchTimeout, "initial duration for which to wait for config")
flag.Var(&flags.oem, "oem", fmt.Sprintf("current oem. %v", oem.Names()))
flag.Var(&flags.platform, "platform", fmt.Sprintf("current platform. %v", platform.Names()))
flag.StringVar(&flags.root, "root", "/", "root of the filesystem")
flag.Var(&flags.stage, "stage", fmt.Sprintf("execution stage. %v", stages.Names()))
flag.BoolVar(&flags.version, "version", false, "print the version and exit")
Expand All @@ -59,8 +59,8 @@ func main() {
return
}

if flags.oem == "" {
fmt.Fprint(os.Stderr, "'--oem' must be provided\n")
if flags.platform == "" {
fmt.Fprint(os.Stderr, "'--platform' must be provided\n")
os.Exit(2)
}

Expand All @@ -80,23 +80,23 @@ func main() {
}
}

oemConfig := oem.MustGet(flags.oem.String())
fetcher, err := oemConfig.NewFetcherFunc()(&logger)
platformConfig := platform.MustGet(flags.platform.String())
fetcher, err := platformConfig.NewFetcherFunc()(&logger)
if err != nil {
logger.Crit("failed to generate fetcher: %s", err)
os.Exit(3)
}
engine := exec.Engine{
Root: flags.root,
FetchTimeout: flags.fetchTimeout,
Logger: &logger,
ConfigCache: flags.configCache,
OEMConfig: oemConfig,
Fetcher: &fetcher,
Root: flags.root,
FetchTimeout: flags.fetchTimeout,
Logger: &logger,
ConfigCache: flags.configCache,
PlatformConfig: platformConfig,
Fetcher: &fetcher,
}

err = engine.Run(flags.stage.String())
if statusErr := engine.OEMConfig.Status(flags.stage.String(), *engine.Fetcher, err); statusErr != nil {
if statusErr := engine.PlatformConfig.Status(flags.stage.String(), *engine.Fetcher, err); statusErr != nil {
logger.Err("POST Status error: %v", statusErr.Error())
}
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/oem/name.go → internal/platform/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package oem
package platform

import (
"fmt"
)

// Name is used to identify an OEM. It must be in the set of registered OEMs.
// Name is used to identify an platform. It must be in the set of registered platforms.
type Name string

func (s Name) String() string {
Expand All @@ -27,7 +27,7 @@ func (s Name) String() string {

func (s *Name) Set(val string) error {
if _, ok := Get(val); !ok {
return fmt.Errorf("%s is not a valid oem", val)
return fmt.Errorf("%s is not a valid platform", val)
}

*s = Name(val)
Expand Down
8 changes: 4 additions & 4 deletions internal/oem/oem.go → internal/platform/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package oem
package platform

import (
"fmt"
Expand All @@ -35,7 +35,7 @@ import (
"github.com/coreos/ignition/internal/resource"
)

// Config represents a set of options that map to a particular OEM.
// Config represents a set of options that map to a particular platform.
type Config struct {
name string
fetch providers.FuncFetchConfig
Expand Down Expand Up @@ -70,7 +70,7 @@ func (c Config) Status(stageName string, f resource.Fetcher, statusErr error) er
return nil
}

var configs = registry.Create("oem configs")
var configs = registry.Create("platform configs")

func init() {
configs.Register(Config{
Expand Down Expand Up @@ -138,7 +138,7 @@ func MustGet(name string) Config {
if config, ok := Get(name); ok {
return config
} else {
panic(fmt.Sprintf("invalid OEM name %q provided", name))
panic(fmt.Sprintf("invalid platform name %q provided", name))
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/providers/noop/noop.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// The noop provider does nothing, for use by unimplemented oems.
// The noop provider does nothing, for use by unimplemented platforms.

package noop

Expand Down
2 changes: 1 addition & 1 deletion tests/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func umountPartition(p *types.Partition) error {

// returns true if no error, false if error
func runIgnition(t *testing.T, ctx context.Context, stage, root, cwd string, appendEnv []string) error {
args := []string{"-clear-cache", "-oem", "file", "-stage", stage,
args := []string{"-clear-cache", "-platform", "file", "-stage", stage,
"-root", root, "-log-to-stdout", "--config-cache", filepath.Join(cwd, "ignition.json")}
cmd := exec.CommandContext(ctx, "ignition", args...)
t.Log("ignition", args)
Expand Down