-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
162 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
package barbican | ||
|
||
const ( | ||
ServiceName = "barbican" | ||
ServiceName = "barbican" | ||
DatabaseName = "barbican" | ||
KollaConfigDbSync = "/var/lib/config-data/merged/db-sync-config.json" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package barbican | ||
|
||
import ( | ||
corev1 "k8s.io/api/core/v1" | ||
) | ||
|
||
// APIDetails information | ||
type APIDetails struct { | ||
ContainerImage string | ||
DatabaseHost string | ||
DatabaseUser string | ||
DatabaseName string | ||
TransportURL string | ||
OSPSecret string | ||
DBPasswordSelector string | ||
UserPasswordSelector string | ||
VolumeMounts []corev1.VolumeMount | ||
} | ||
|
||
const ( | ||
InitContainerCommand = "/usr/local/bin/container-scripts/init.sh" | ||
) | ||
|
||
// InitContainer - init container for barbican api pods | ||
func InitContainer(init APIDetails) []corev1.Container { | ||
runAsUser := int64(0) | ||
|
||
args := []string{ | ||
"-c", | ||
InitContainerCommand, | ||
} | ||
|
||
envs := []corev1.EnvVar{} | ||
/* | ||
envVars := map[string]env.Setter{} | ||
envVars["DatabaseHost"] = env.SetValue(init.DatabaseHost) | ||
envVars["DatabaseUser"] = env.SetValue(init.DatabaseUser) | ||
envVars["DatabaseName"] = env.SetValue(init.DatabaseName) | ||
envs := []corev1.EnvVar{ | ||
{ | ||
Name: "DatabasePassword", | ||
ValueFrom: &corev1.EnvVarSource{ | ||
SecretKeyRef: &corev1.SecretKeySelector{ | ||
LocalObjectReference: corev1.LocalObjectReference{ | ||
Name: init.OSPSecret, | ||
}, | ||
Key: init.DBPasswordSelector, | ||
}, | ||
}, | ||
}, | ||
{ | ||
Name: "GlancePassword", | ||
ValueFrom: &corev1.EnvVarSource{ | ||
SecretKeyRef: &corev1.SecretKeySelector{ | ||
LocalObjectReference: corev1.LocalObjectReference{ | ||
Name: init.OSPSecret, | ||
}, | ||
Key: init.UserPasswordSelector, | ||
}, | ||
}, | ||
}, | ||
// TODO | ||
// { | ||
// Name: "TransportUrl", | ||
// ValueFrom: &corev1.EnvVarSource{ | ||
// SecretKeyRef: &corev1.SecretKeySelector{ | ||
// LocalObjectReference: corev1.LocalObjectReference{ | ||
// Name: init.OSPSecret, | ||
// }, | ||
// Key: "TransportUrl", | ||
// }, | ||
// }, | ||
// }, | ||
} | ||
envs = env.MergeEnvs(envs, envVars) | ||
*/ | ||
return []corev1.Container{ | ||
{ | ||
Name: "init", | ||
Image: init.ContainerImage, | ||
SecurityContext: &corev1.SecurityContext{ | ||
RunAsUser: &runAsUser, | ||
}, | ||
Command: []string{ | ||
"/bin/bash", | ||
}, | ||
Args: args, | ||
Env: envs, | ||
VolumeMounts: init.VolumeMounts, | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters