Skip to content

Commit

Permalink
fix configmap version logic
Browse files Browse the repository at this point in the history
Signed-off-by: tchughesiv <[email protected]>
  • Loading branch information
tchughesiv committed Jul 31, 2019
1 parent 832db7c commit fe4ea5e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
8 changes: 2 additions & 6 deletions pkg/controller/kieapp/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,12 +624,12 @@ func getWebhookSecret(webhookType v1.WebhookType, webhooks []v1.WebhookSecret) s

// important to parse template first with this function, before unmarshalling into object
func loadYaml(service v1.PlatformService, filename, productVersion, namespace string, env v1.EnvTemplate) ([]byte, error) {
filename = strings.Join([]string{productVersion, filename}, "/")
if _, _, useEmbedded := UseEmbeddedFiles(service); useEmbedded {
box := packr.New("config", "../../../../config")
if !box.HasDir(productVersion) {
return nil, fmt.Errorf("Product version %s configs are not available in this Operator, %s", productVersion, version.Version)
}
filename = strings.Join([]string{productVersion, filename}, "/")
if box.Has(filename) {
yamlString, err := box.FindString(filename)
if err != nil {
Expand Down Expand Up @@ -680,14 +680,10 @@ func convertToConfigMapName(filename string) (configMapName, file string) {

// ConfigMapsFromFile reads the files under the config folder and creates
// configmaps in the given namespace. It sets OwnerRef to operator deployment.
func ConfigMapsFromFile(myDep *appsv1.Deployment, ns, productVersion string, scheme *runtime.Scheme) []corev1.ConfigMap {
func ConfigMapsFromFile(myDep *appsv1.Deployment, ns string, scheme *runtime.Scheme) []corev1.ConfigMap {
box := packr.New("config", "../../../../config")
if !box.HasDir(productVersion) {
log.Errorf("Product version %s configs are not available in this Operator, %s", productVersion, version.Version)
}
cmList := map[string][]map[string]string{}
for _, filename := range box.List() {
filename := strings.Join([]string{productVersion, filename}, "/")
s, err := box.FindString(filename)
if err != nil {
log.Error("Error finding file with packr. ", err)
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/kieapp/kieapp_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (reconciler *Reconciler) Reconcile(request reconcile.Request) (reconcile.Re
// started creating as versioned configs
// if versioned one already exists, reconcile??
// if not, but prior version exists, check deltas and apply as new versioned config
reconciler.CreateConfigMaps(myDep, constants.CurrentVersion)
reconciler.CreateConfigMaps(myDep)
if shouldDeployConsole() {
deployConsole(reconciler, myDep)
}
Expand Down Expand Up @@ -758,8 +758,8 @@ func (reconciler *Reconciler) GetRouteHost(route routev1.Route, cr *v1.KieApp) s
}

// CreateConfigMaps generates & creates necessary versioned ConfigMaps from embedded product files
func (reconciler *Reconciler) CreateConfigMaps(myDep *appsv1.Deployment, productVersion string) {
configMaps := defaults.ConfigMapsFromFile(myDep, myDep.Namespace, productVersion, reconciler.Service.GetScheme())
func (reconciler *Reconciler) CreateConfigMaps(myDep *appsv1.Deployment) {
configMaps := defaults.ConfigMapsFromFile(myDep, myDep.Namespace, reconciler.Service.GetScheme())
for _, configMap := range configMaps {
var testDir bool
result := strings.Split(configMap.Name, "-")
Expand Down

0 comments on commit fe4ea5e

Please sign in to comment.