Skip to content
This repository has been archived by the owner on Jan 20, 2023. It is now read-only.

Naming convention #49

Merged
merged 5 commits into from
Apr 24, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 4 additions & 9 deletions brokers/unified/broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,18 @@ func NewBroker() *Broker {
}

// DownloadMetasAndStart downloads metas from plugin registry for specified
// pluginFQNs and then calls Start for those metas
func (b *Broker) DownloadMetasAndStart(pluginFQNs []model.PluginFQN, defaultRegistry string) {
// pluginFQNs and then executes plugins metas processing and sending data to Che master
func (b *Broker) Start(pluginFQNs []model.PluginFQN, defaultRegistry string) {
pluginMetas, err := b.getPluginMetas(pluginFQNs, defaultRegistry)
if err != nil {
b.PrintFatal("Failed to download plugin metas: %s", err)
}
b.Start(pluginMetas)
}

// Start executes plugins metas processing and sending data to Che master
func (b *Broker) Start(metas []model.PluginMeta) {
defer b.CloseConsumers()
b.PubStarted()
b.PrintInfo("Unified Che Plugin Broker")
b.PrintPlan(metas)
b.PrintPlan(pluginMetas)

err := b.ProcessPlugins(metas)
err = b.ProcessPlugins(pluginMetas)
if err != nil {
b.PubFailed(err.Error())
b.PrintFatal(err.Error())
Expand Down
16 changes: 4 additions & 12 deletions brokers/unified/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,9 @@ func main() {
broker.PushEvents(statusTun)
}

if cfg.DownloadMetas {
pluginFQNs, err := cfg.ParsePluginFQNs()
if err != nil {
broker.PrintFatal("Failed to process plugin fully qualified names from config: %s", err)
}
broker.DownloadMetasAndStart(pluginFQNs, cfg.RegistryAddress)
} else {
pluginMetas, err := cfg.ReadConfig()
if err != nil {
broker.PrintFatal("Failed to process plugin fully qualified names from config: %s", err)
}
broker.Start(pluginMetas)
pluginFQNs, err := cfg.ParsePluginFQNs()
if err != nil {
broker.PrintFatal("Failed to process plugin fully qualified names from config: %s", err)
}
broker.Start(pluginFQNs, cfg.RegistryAddress)
}
29 changes: 0 additions & 29 deletions cfg/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ var (
// RegistryAddress address of the plugin registry, if plugin IDs are specified in config instead of metas.
// Used as a default registry if a plugin fully-qualified name does not specify a registry.
RegistryAddress string

// DownloadMetas specifies whether the broker should download plugin metas from the registry. If
// true, then config file should be a list of plugin fully-qualified names. Otherwise, the config
// file should contain the plugin metas to be processed.
DownloadMetas bool
garagatyi marked this conversation as resolved.
Show resolved Hide resolved
)

func init() {
Expand Down Expand Up @@ -126,12 +121,6 @@ func init() {
"",
"Default address of registry from which to retrieve meta.yamls when plugin FQNs do not specify a registry. Ignored unless --download-metas is set",
garagatyi marked this conversation as resolved.
Show resolved Hide resolved
)
flag.BoolVar(
&DownloadMetas,
"download-metas",
false,
"Download plugin metadata from registry instead of process already-downloaded metas",
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this now would result in a minor version bump (0.16.x) and require changes in upstream Che.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I'm considering change version to v1.0.0 since it is backward incompatible and first number is supposed be reflect such changes. WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to either option but worry we're not to the point of calling it a v1.0 release, especially with the various naming convention/registry changes still coming down the pipe. It's still okay to break backward compatibility in version zero so I'm leaning more in that direction.

}

// Parse parses configuration.
Expand Down Expand Up @@ -180,24 +169,6 @@ func Print() {
log.Printf(" OwnerId: %s", RuntimeID.OwnerId)
}

// ReadConfig reads content of file by path cfg.FilePath,
// parses its content as array of Che plugin meta objects and returns it.
// If any error occurs during read, log.Fatal is called.
//
// Deprecated
func ReadConfig() ([]model.PluginMeta, error) {
raw, err := readConfigFile()
if err != nil {
return nil, fmt.Errorf("failed to read config file: %s", err)
}

metas := make([]model.PluginMeta, 0)
if err := json.Unmarshal(raw, &metas); err != nil {
return nil, fmt.Errorf("failed to unmarshal plugin metas: %s", err)
}
return metas, nil
}

// ParsePluginFQNs reads content of file at path cfg.Filepath and parses its
// content as a list of fully-qualified Plugin names (id, version, registry).
// If any error occurs, log.Fatal is called.
Expand Down