Skip to content

Commit 6fd2b94

Browse files
committed
fix: add migration to the contexts
1 parent f335423 commit 6fd2b94

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

cmd/rhoas/main.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,31 @@ func initProfiles(f *factory.Factory) error {
120120
return err
121121
}
122122

123-
ctxFile = &servicecontext.Context{}
123+
configFile, err := f.Config.Load()
124+
125+
if err != nil {
126+
return err
127+
}
128+
129+
kafkaId, _ := configFile.GetKafkaIdOk()
130+
serviceRegistryId, _ := configFile.GetServiceRegistryIdOk()
131+
ctxFile = &servicecontext.Context{
132+
CurrentContext: "default",
133+
Contexts: map[string]servicecontext.ServiceConfig{
134+
"default": {
135+
KafkaID: kafkaId,
136+
ServiceRegistryID: serviceRegistryId,
137+
},
138+
},
139+
}
140+
124141
if err := f.ServiceContext.Save(ctxFile); err != nil {
125142
return err
126143
}
144+
145+
configFile.Services = config.ServiceConfigMap{}
146+
_ = f.Config.Save(configFile)
147+
127148
return nil
128149
}
129150

pkg/core/config/type.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ type Config struct {
2828

2929
// ServiceConfigMap is a map of configs for the application services
3030
type ServiceConfigMap struct {
31-
Kafka *KafkaConfig `json:"kafka"`
32-
ServiceRegistry *ServiceRegistryConfig `json:"serviceregistry"`
31+
Kafka *KafkaConfig `json:"kafka,omitempty"`
32+
ServiceRegistry *ServiceRegistryConfig `json:"serviceregistry,omitempty"`
3333
}
3434

3535
// KafkaConfig is the config for the Kafka service

0 commit comments

Comments
 (0)