Skip to content

Commit

Permalink
Merge pull request #537 from kiegroup/master
Browse files Browse the repository at this point in the history
Merge branch 'master' into release-v7.9.x
  • Loading branch information
openshift-merge-robot authored Oct 27, 2020
2 parents d5a168a + 26bfab5 commit b776202
Show file tree
Hide file tree
Showing 16 changed files with 560 additions and 216 deletions.
1 change: 1 addition & 0 deletions OWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ reviewers:
- bmozaffa
- tchughesiv
- ruromero
- spolti
approvers:
- bmozaffa
- tchughesiv
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ BUNDLE=${IMAGE}:${VERSION}

$ docker push ${BUNDLE}
BUNDLE_DIGEST=$(docker inspect --format='{{index .RepoDigests 0}}' ${BUNDLE})
INDEX_VERSION=v4.5 # v4.6
INDEX_VERSION=v4.6
INDEX_IMAGE=quay.io/${USERNAME}/ba-operator-index:${INDEX_VERSION}
INDEX_FROM=${INDEX_IMAGE}_$(go run getversion.go --prior)
INDEX_TO=${INDEX_IMAGE}_${VERSION}
Expand Down
236 changes: 236 additions & 0 deletions deploy/crds/kieapp.crd.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deploy/crs/v2/snippets/immutable_s2i.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###
# This CR deploys 1 kie server set that will build an image containing the
# library process deployed.
# Besides it will deploy the resulting image and a monitoring console
# Besides it will deploy the resulting image and a monitoring console if enabled
###
apiVersion: app.kiegroup.org/v2
kind: KieApp
Expand Down
26 changes: 26 additions & 0 deletions deploy/crs/v2/snippets/immutable_s2i_extra_buildconfig_envs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
###
# This CR deploys 1 kie server set that will build an image containing the
# library process deployed.
# Besides it will deploy the resulting image and a monitoring console if enabled
###
apiVersion: app.kiegroup.org/v2
kind: KieApp
metadata:
name: library-s2i
annotations:
consoleName: snippet-library-s2i-with-extra-buildconfig-envs
consoleTitle: S2I Immutable Deployment with extra Build Config environment variables
consoleDesc: Use this snippet to configure an immutable deployment with s2i passing extra Build Config environment variables.
consoleSnippet: true
spec:
objects:
servers:
- build:
kieServerContainerDeployment: rhpam-kieserver-library=org.openshift.quickstarts:rhpam-kieserver-library:1.5.0-SNAPSHOT
gitSource:
uri: https://github.com/jboss-container-images/rhpam-7-openshift-image.git
reference: master
contextDir: quickstarts/library-process/library
env:
- name: "JAVA_OPTS_APPEND"
value: "-Dmy.custom.property=prop-test"

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.0 h1:yTUvW7Vhb89inJ+8irsUqiWjh8iT6sQPZiQzI6ReGkA=
github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5/go.mod h1:/iP1qXHoty45bqomnu2LM+VVyAEdWN+vtSHGlQgyxbw=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
Expand Down Expand Up @@ -1308,6 +1309,7 @@ golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4Iltr
golang.org/x/oauth2 v0.0.0-20190402181905-9f3314589c9a/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 h1:SVwTIAaPC2U/AvvLNZ2a7OVsmBpC8L5BlwK1whH3hm0=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6 h1:pE8b58s1HRDMi8RDc79m0HISf9D4TzseP40cEA6IGfs=
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down
10 changes: 5 additions & 5 deletions hack/go-mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ source ./hack/go-mod-env.sh

echo Reset vendor directory

if [[ -z ${CI} ]]; then
go mod tidy
go mod vendor
else
go mod vendor -v
go mod tidy
go mod vendor

if [[ -n ${CI} ]]; then
git diff --exit-code
fi
2 changes: 1 addition & 1 deletion image-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ labels:
value: "true"
- name: com.redhat.openshift.versions
# change to this label for 7.10+ releases ?? # value: v4.7
value: v4.5,v4.6
value: v4.6
modules:
repositories:
- path: deploy/olm-catalog/prod
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/app/v2/kieapp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ type KieAppObject struct {

// KieAppBuildObject Data to define how to build an application from source
type KieAppBuildObject struct {
// Env set environment variables for BuildConfigs
Env []corev1.EnvVar `json:"env,omitempty"`
// The Maven GAV to deploy, e.g., rhpam-kieserver-library=org.openshift.quickstarts:rhpam-kieserver-library:1.5.0-SNAPSHOT
KieServerContainerDeployment string `json:"kieServerContainerDeployment,omitempty"`
GitSource GitSource `json:"gitSource,omitempty"`
Expand Down
7 changes: 7 additions & 0 deletions pkg/apis/app/v2/zz_generated.deepcopy.go

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

7 changes: 5 additions & 2 deletions pkg/controller/kieapp/defaults/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,12 @@ func configureSSO(cr *api.KieApp, envTemplate *api.EnvTemplate) error {
}
cr.Status.Applied.Auth.SSO.PrincipalAttribute = constants.SSODefaultPrincipalAttribute
}
if cr.Status.Applied.Objects.Console.SSOClient != nil {
envTemplate.Console.SSOAuthClient = *cr.Status.Applied.Objects.Console.SSOClient.DeepCopy()
if cr.Status.Applied.Objects.Console != nil {
if cr.Status.Applied.Objects.Console.SSOClient != nil {
envTemplate.Console.SSOAuthClient = *cr.Status.Applied.Objects.Console.SSOClient.DeepCopy()
}
}

if cr.Status.Applied.Auth.SSO != nil {
envTemplate.Auth.SSO = *cr.Status.Applied.Auth.SSO.DeepCopy()
for index := range envTemplate.Servers {
Expand Down
54 changes: 43 additions & 11 deletions pkg/controller/kieapp/defaults/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,17 +192,7 @@ func TestAuthSSOConfig(t *testing.T) {
env, err := GetEnvironment(cr, test.MockService())
assert.Nil(t, err, "Error getting trial environment")

expectedEnvs := []corev1.EnvVar{
{Name: "SSO_URL", Value: "https://sso.example.com:8080"},
{Name: "SSO_REALM", Value: "rhpam-test"},
{Name: "SSO_OPENIDCONNECT_DEPLOYMENTS", Value: "ROOT.war"},
{Name: "SSO_PRINCIPAL_ATTRIBUTE", Value: "preferred_username"},
{Name: "SSO_DISABLE_SSL_CERTIFICATE_VALIDATION", Value: "false"},
{Name: "SSO_USERNAME"},
{Name: "SSO_PASSWORD"},
{Name: "SSO_PASSWORD"},
}
for _, expectedEnv := range expectedEnvs {
for _, expectedEnv := range getExpectedSSOEnvs() {
assert.Contains(t, env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, expectedEnv, "Console should contain env %v", expectedEnv)
for i := range env.Servers {
assert.Contains(t, env.Servers[i].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, expectedEnv, "Server %v should contain env %v", i, expectedEnv)
Expand All @@ -223,6 +213,35 @@ func TestAuthSSOConfig(t *testing.T) {
}
}

func TestAuthSSOConfigWithRHDMImmutable(t *testing.T) {
cr := &api.KieApp{
ObjectMeta: metav1.ObjectMeta{
Name: "test",
},
Spec: api.KieAppSpec{
Environment: "rhdm-production-immutable",
Auth: &api.KieAppAuthObject{
SSO: &api.SSOAuthConfig{
URL: "https://sso.example.com:8080",
Realm: "rhpam-test",
},
},
},
}

env, err := GetEnvironment(cr, test.MockService())
assert.Nil(t, err, "Error getting rhdm-production-immutable environment")

// console dc should be nil
assert.Nil(t, env.Console.DeploymentConfigs, "Console should be nil")

for _, expectedEnv := range getExpectedSSOEnvs() {
for i := range env.Servers {
assert.Contains(t, env.Servers[i].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, expectedEnv, "Server %v should contain env %v", i, expectedEnv)
}
}
}

func TestAuthSSOConfigWithClients(t *testing.T) {
cr := &api.KieApp{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -553,3 +572,16 @@ func TestAuthRoleMapperConfig(t *testing.T) {
}
}
}

func getExpectedSSOEnvs() []corev1.EnvVar {
return []corev1.EnvVar{
{Name: "SSO_URL", Value: "https://sso.example.com:8080"},
{Name: "SSO_REALM", Value: "rhpam-test"},
{Name: "SSO_OPENIDCONNECT_DEPLOYMENTS", Value: "ROOT.war"},
{Name: "SSO_PRINCIPAL_ATTRIBUTE", Value: "preferred_username"},
{Name: "SSO_DISABLE_SSL_CERTIFICATE_VALIDATION", Value: "false"},
{Name: "SSO_USERNAME"},
{Name: "SSO_PASSWORD"},
{Name: "SSO_PASSWORD"},
}
}
9 changes: 9 additions & 0 deletions pkg/controller/kieapp/defaults/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ func getServersConfig(cr *api.KieApp) ([]api.ServerTemplate, error) {
KeystoreSecret: serverSet.KeystoreSecret,
StorageClassName: serverSet.StorageClassName,
}

if cr.Status.Applied.Objects.Console == nil || cr.Status.Applied.Environment == api.RhdmProductionImmutable {
template.OmitConsole = true
}
Expand Down Expand Up @@ -569,6 +570,7 @@ func getServersConfig(cr *api.KieApp) ([]api.ServerTemplate, error) {

servers = append(servers, *instanceTemplate)
}

}
return servers, nil
}
Expand Down Expand Up @@ -625,6 +627,12 @@ func ConsolidateObjects(env api.Environment, cr *api.KieApp) api.Environment {
for index := range env.Servers {
serverSet, _ := GetServerSet(cr, index)
env.Servers[index] = ConstructObject(env.Servers[index], serverSet.KieAppObject)
// apply the build config envs provided through cr to the given kieSerever BuildConfig Spec envs
for bcindex := range env.Servers[index].BuildConfigs {
env.Servers[index].BuildConfigs[bcindex].Spec.Strategy.SourceStrategy.Env = shared.EnvOverride(
env.Servers[index].BuildConfigs[bcindex].Spec.Strategy.SourceStrategy.Env,
serverSet.Build.Env)
}
}
return env
}
Expand Down Expand Up @@ -702,6 +710,7 @@ func getBuildConfig(product string, cr *api.KieApp, serverSet *api.KieServerSet)
ArtifactDir: serverSet.Build.ArtifactDir,
}
}

buildTemplate.From, _, _ = getDefaultKieServerImage(product, cr, serverSet, true)
if serverSet.Build.From != nil {
buildTemplate.From = *serverSet.Build.From
Expand Down
34 changes: 30 additions & 4 deletions pkg/controller/kieapp/defaults/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1008,6 +1008,16 @@ func TestBuildConfiguration(t *testing.T) {
{
Name: serverName,
Build: &api.KieAppBuildObject{
Env: []corev1.EnvVar{
{
Name: "JAVA_OPTS_APPEND",
Value: "-Dmyprop=test",
},
{
Name: "OTHER_ENV",
Value: "other",
},
},
KieServerContainerDeployment: "rhpam-kieserver-library=org.openshift.quickstarts:rhpam-kieserver-library:1.5.0-SNAPSHOT",
MavenMirrorURL: "https://maven.mirror.com/",
ArtifactDir: "dir",
Expand All @@ -1020,7 +1030,7 @@ func TestBuildConfiguration(t *testing.T) {
},
{
Build: &api.KieAppBuildObject{
KieServerContainerDeployment: "rhpam-kieserver-library=org.openshift.quickstarts:rhpam-kieserver-library:1.5.0-SNAPSHOT",
KieServerContainerDeployment: "rhpam-kieserver-library=org.openshift.quickstarts:rhpam-kieserver-library:1.6.0-SNAPSHOT",
MavenMirrorURL: "https://maven.mirror.com/",
ArtifactDir: "dir",
GitSource: api.GitSource{
Expand All @@ -1032,14 +1042,20 @@ func TestBuildConfiguration(t *testing.T) {
},
{
Build: &api.KieAppBuildObject{
KieServerContainerDeployment: "rhpam-kieserver-library=org.openshift.quickstarts:rhpam-kieserver-library:1.5.0-SNAPSHOT",
KieServerContainerDeployment: "rhpam-kieserver-library=org.openshift.quickstarts:rhpam-kieserver-library:1.7.0-SNAPSHOT",
MavenMirrorURL: "https://maven.mirror.com/",
ArtifactDir: "dir",
GitSource: api.GitSource{
URI: "http://git.example.com",
Reference: "somebranch",
ContextDir: "example2",
},
Env: []corev1.EnvVar{
{
Name: "ANOTHER_ENV",
Value: "AnotherEnv",
},
},
},
},
{
Expand Down Expand Up @@ -1086,6 +1102,9 @@ func TestBuildConfiguration(t *testing.T) {
cr.Spec.Objects.Servers[2].Build.Webhooks = []api.WebhookSecret{{Type: api.GitHubWebhook, Secret: secret2}}
env, err = GetEnvironment(cr, test.MockService())
assert.Nil(t, err, "Error getting prod environment")

// ConsolidateObjects
ConsolidateObjects(env, cr)
assert.Len(t, cr.Spec.Objects.Servers[1].Build.Webhooks, 1)
assert.Len(t, cr.Spec.Objects.Servers[2].Build.Webhooks, 1)
assert.Equal(t, secret1, cr.Spec.Objects.Servers[1].Build.Webhooks[0].Secret)
Expand All @@ -1098,8 +1117,12 @@ func TestBuildConfiguration(t *testing.T) {
// Server Test
crServer := cr.Status.Applied.Objects.Servers[0]
server := env.Servers[0]

assert.Equal(t, serverName, crServer.Name)
assert.Equal(t, crServer.Name+latestTag, server.DeploymentConfigs[0].Spec.Triggers[0].ImageChangeParams.From.Name)
assert.Equal(t, "rhpam-kieserver-library=org.openshift.quickstarts:rhpam-kieserver-library:1.5.0-SNAPSHOT", server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env[0].Value)
assert.Equal(t, "-Dmyprop=test", server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env[3].Value)
assert.Equal(t, "other", server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env[4].Value)

// Server #1
crServer = cr.Status.Applied.Objects.Servers[1]
Expand All @@ -1108,9 +1131,11 @@ func TestBuildConfiguration(t *testing.T) {
assert.Equal(t, buildv1.BuildSourceGit, server.BuildConfigs[0].Spec.Source.Type)
assert.Equal(t, "http://git.example.com", server.BuildConfigs[0].Spec.Source.Git.URI)
assert.Equal(t, "somebranch", server.BuildConfigs[0].Spec.Source.Git.Ref)
assert.Equal(t, "rhpam-kieserver-library=org.openshift.quickstarts:rhpam-kieserver-library:1.5.0-SNAPSHOT", server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env[0].Value)
assert.Equal(t, "rhpam-kieserver-library=org.openshift.quickstarts:rhpam-kieserver-library:1.6.0-SNAPSHOT", server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env[0].Value)
assert.Equal(t, "https://maven.mirror.com/", server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env[1].Value)
assert.Equal(t, "dir", server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env[2].Value)
// default envs size is 3
assert.Equal(t, 3, len(server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env))
for _, s := range server.BuildConfigs[0].Spec.Triggers {
if s.GitHubWebHook != nil {
assert.NotEmpty(t, s.GitHubWebHook.Secret)
Expand All @@ -1128,9 +1153,10 @@ func TestBuildConfiguration(t *testing.T) {
assert.Equal(t, buildv1.BuildSourceGit, server.BuildConfigs[0].Spec.Source.Type)
assert.Equal(t, "http://git.example.com", server.BuildConfigs[0].Spec.Source.Git.URI)
assert.Equal(t, "somebranch", server.BuildConfigs[0].Spec.Source.Git.Ref)
assert.Equal(t, "rhpam-kieserver-library=org.openshift.quickstarts:rhpam-kieserver-library:1.5.0-SNAPSHOT", server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env[0].Value)
assert.Equal(t, "rhpam-kieserver-library=org.openshift.quickstarts:rhpam-kieserver-library:1.7.0-SNAPSHOT", server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env[0].Value)
assert.Equal(t, "https://maven.mirror.com/", server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env[1].Value)
assert.Equal(t, "dir", server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env[2].Value)
assert.Equal(t, "AnotherEnv", server.BuildConfigs[0].Spec.Strategy.SourceStrategy.Env[3].Value)
for _, s := range server.BuildConfigs[0].Spec.Triggers {
if s.GitHubWebHook != nil {
assert.NotEmpty(t, s.GitHubWebHook.Secret)
Expand Down

0 comments on commit b776202

Please sign in to comment.