Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #8013 from zregvart/issue/8009
Browse files Browse the repository at this point in the history
fix(operator): provide default database image
  • Loading branch information
zregvart authored Mar 4, 2020
2 parents e925175 + 0d3a25a commit 10c7acf
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 71 deletions.
2 changes: 1 addition & 1 deletion install/operator/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ require (
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.4.0
github.com/testcontainers/testcontainers-go v0.3.0
gopkg.in/yaml.v2 v2.2.4
gopkg.in/yaml.v2 v2.2.8
k8s.io/api v0.17.2
k8s.io/apimachinery v0.17.2
k8s.io/client-go v12.0.0+incompatible
Expand Down
2 changes: 2 additions & 0 deletions install/operator/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,8 @@ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20190905181640-827449938966/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools v0.0.0-20181223230014-1083505acf35/go.mod h1:R//lfYlUuTOTfblYI3lGoAAAebUdzjvbmQsuB7Ykd90=
gotest.tools v2.1.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
Expand Down
58 changes: 58 additions & 0 deletions install/operator/pkg/cmd/internal/install/generator/generator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (C) 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.
*/
package main

import (
"fmt"
"io/ioutil"
"log"

"gopkg.in/yaml.v2"
)

type config struct {
Syndesis struct {
Components struct {
Database struct {
Image string `yaml:"Image"`
} `yaml:"Database"`
} `yaml:"Components"`
} `yaml:"Syndesis"`
}

func main() {
data, err := ioutil.ReadFile("../../../../build/conf/config.yaml")
if err != nil {
log.Fatal(err)
}

c := config{}

err = yaml.Unmarshal(data, &c)
if err != nil {
log.Fatal(err)
}

code := fmt.Sprintf(`package install
const defaultDatabaseImage = "%s"
`, c.Syndesis.Components.Database.Image)

err = ioutil.WriteFile("install_defaults.go", []byte(code), 0644)
if err != nil {
log.Fatal(err)
}
}
11 changes: 6 additions & 5 deletions install/operator/pkg/cmd/internal/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func New(parent *internal.Options) *cobra.Command {
util.ExitOnError(err)
},
}
forge.PersistentFlags().StringVarP(&configuration.TemplateConfig, "operator-config", "", "/conf/config.yaml", "Path to the operator configuration file.")
forge.PersistentFlags().StringVarP(&o.addons, "addons", "", "", "a coma separated list of addons that should be enabled")
cmd.AddCommand(forge)

Expand All @@ -121,10 +120,12 @@ func New(parent *internal.Options) *cobra.Command {
cmd.PersistentFlags().StringVarP(&o.tag, "tag", "", pkg.DefaultOperatorTag, "sets operator tag that gets installed")
cmd.PersistentFlags().BoolVarP(&o.wait, "wait", "w", false, "waits for the application to be running")
cmd.PersistentFlags().BoolVarP(&o.devSupport, "dev", "", false, "enable development mode by loading images from image stream tags.")
cmd.PersistentFlags().StringVarP(&configuration.TemplateConfig, "operator-config", "", "/conf/config.yaml", "Path to the operator configuration file.")
cmd.PersistentFlags().AddFlagSet(util.FlagSet)
return &cmd
}

//go:generate go run generator/generator.go
func (o *Install) before(_ *cobra.Command, args []string) (err error) {
switch o.eject {
case "":
Expand All @@ -147,13 +148,13 @@ func (o *Install) before(_ *cobra.Command, args []string) (err error) {
o.image = "syndesis-operator"
}

o.databaseImage = defaultDatabaseImage
config, err := configuration.GetProperties(configuration.TemplateConfig, o.Context, nil, &v1beta1.Syndesis{})
if err != nil {
return err
if err == nil {
o.databaseImage = config.Syndesis.Components.Database.Image
}
o.databaseImage = config.Syndesis.Components.Database.Image

return
return nil
}

func (o *Install) after(cmd *cobra.Command, args []string) {
Expand Down
3 changes: 0 additions & 3 deletions install/operator/pkg/cmd/internal/install/install_forge.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ type SyndesisEnvVar string

const EMPTY_FIELD = "<>"

// Location from where the template configuration is located
var TemplateConfig string

const (
EnvRouteHostname SyndesisEnvVar = "ROUTE_HOSTNAME"
EnvOpenShiftMaster SyndesisEnvVar = "OPENSHIFT_MASTER"
Expand Down
14 changes: 8 additions & 6 deletions install/operator/vendor/gopkg.in/yaml.v2/decode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

107 changes: 53 additions & 54 deletions install/operator/vendor/gopkg.in/yaml.v2/scannerc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion install/operator/vendor/gopkg.in/yaml.v2/yaml.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions install/operator/vendor/gopkg.in/yaml.v2/yamlh.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion install/operator/vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ google.golang.org/grpc/grpclog
gopkg.in/fsnotify.v1
# gopkg.in/inf.v0 v0.9.1
gopkg.in/inf.v0
# gopkg.in/yaml.v2 v2.2.4
# gopkg.in/yaml.v2 v2.2.8
gopkg.in/yaml.v2
# k8s.io/api v0.17.2 => k8s.io/api v0.0.0-20191016110408-35e52d86657a
k8s.io/api/core/v1
Expand Down

0 comments on commit 10c7acf

Please sign in to comment.