Skip to content

Commit

Permalink
Merge pull request #147 from schemahero/use-right-image-tag
Browse files Browse the repository at this point in the history
Use the schemahero image name from the env
  • Loading branch information
marccampbell committed Apr 7, 2020
2 parents 1431f04 + df9ba67 commit 5de0014
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
5 changes: 5 additions & 0 deletions pkg/controller/migration/objects.go
Expand Up @@ -2,6 +2,7 @@ package migration

import (
"fmt"
"os"

databasesv1alpha3 "github.com/schemahero/schemahero/pkg/apis/databases/v1alpha3"
schemasv1alpha3 "github.com/schemahero/schemahero/pkg/apis/schemas/v1alpha3"
Expand Down Expand Up @@ -55,6 +56,10 @@ func podNameForMigrationApply(databaseName string, tableName string, migrationID

func getApplyPod(migrationID string, namespace string, connectionURI string, database *databasesv1alpha3.Database, table *schemasv1alpha3.Table) (*corev1.Pod, error) {
imageName := "schemahero/schemahero:alpha"
if os.Getenv("SCHEMAHERO_IMAGE_NAME") != "" {
imageName = os.Getenv("SCHEMAHERO_IMAGE_NAME")
}

nodeSelector := make(map[string]string)

if database.Spec.SchemaHero != nil {
Expand Down
5 changes: 5 additions & 0 deletions pkg/controller/table/objects.go
Expand Up @@ -3,6 +3,7 @@ package table
import (
"crypto/sha256"
"fmt"
"os"

"github.com/pkg/errors"
databasesv1alpha3 "github.com/schemahero/schemahero/pkg/apis/databases/v1alpha3"
Expand Down Expand Up @@ -81,6 +82,10 @@ func getPlanConfigMap(database *databasesv1alpha3.Database, table *schemasv1alph

func (r *ReconcileTable) getPlanPod(database *databasesv1alpha3.Database, table *schemasv1alpha3.Table) (*corev1.Pod, error) {
imageName := "schemahero/schemahero:alpha"
if os.Getenv("SCHEMAHERO_IMAGE_NAME") != "" {
imageName = os.Getenv("SCHEMAHERO_IMAGE_NAME")
}

nodeSelector := make(map[string]string)
driver := ""
connectionURI := ""
Expand Down
16 changes: 15 additions & 1 deletion pkg/installer/manager.go
Expand Up @@ -3,9 +3,12 @@ package installer
import (
"bytes"
"context"
"fmt"
"strings"

"github.com/pkg/errors"
"github.com/schemahero/schemahero/pkg/client/schemaheroclientset/scheme"
"github.com/schemahero/schemahero/pkg/version"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
kuberneteserrors "k8s.io/apimachinery/pkg/api/errors"
Expand Down Expand Up @@ -188,16 +191,27 @@ func manager(isEnterprise bool, namespace string) *appsv1.StatefulSet {
},
}

schemaheroTag := version.Version()
if strings.HasPrefix(schemaheroTag, "v") {
schemaheroTag = strings.TrimPrefix(schemaheroTag, "v")
}
schemaHeroImage := fmt.Sprintf("schemahero/schemahero:%s", schemaheroTag)

if isEnterprise {
env = append(env, corev1.EnvVar{
Name: "SCHEMAHERO_IMAGE_NAME",
Value: `repl{{ LocalImageName "schemahero/schemahero:0.8.0"}}`,
Value: fmt.Sprintf(`repl{{ LocalImageName "%s"}}`, schemaHeroImage),
})

env = append(env, corev1.EnvVar{
Name: "SCHEMAHERO_IMAGE_PULLSECRET",
Value: `repl{{ LocalRegistryImagePullSecret }}`,
})
} else {
env = append(env, corev1.EnvVar{
Name: "SCHEMAHERO_IMAGE_NAME",
Value: schemaHeroImage,
})
}

return &appsv1.StatefulSet{
Expand Down

0 comments on commit 5de0014

Please sign in to comment.