Skip to content

Commit 3e71840

Browse files
committed
Add ability to supply different krb5 based on environment
1 parent d2d08f3 commit 3e71840

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.MD

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,22 @@ Linux shell
9999
zip -ur KerberosBuildpack-linux-x64-v1.0.0.zip deps
100100
```
101101

102+
### Multiple environment control
102103

104+
If krb5.conf need to be different across environments, multiple krb5.conf can be embedded into the buildpack by creating a folder structure similar to the following and applying steps above:
105+
106+
```
107+
.
108+
├── KerberosBuildpack-linux-x64-v1.0.0.zip
109+
├── deps
110+
│ └── krb5
111+
│ ├── prod
112+
│ │ └── krb5.conf
113+
│ └── qa
114+
│ └── krb5.conf
115+
```
116+
117+
You can control which `krb5.conf` is used by setting `KRB_ENVIRONMENT` environmental variable so it matches the folder name.
103118

104119
## Troubleshooting
105120

src/KerberosBuildpack/KerberosBuildpack.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,20 @@ protected override void Apply(AbsolutePath buildPath, AbsolutePath cachePath, Ab
1717
EnvironmentalVariables["KRB5_KTNAME"] = "/home/vcap/app/.krb5/service.keytab";
1818
EnvironmentalVariables["KRB5_CLIENT_KTNAME"] = "/home/vcap/app/.krb5/service.keytab";
1919

20+
21+
2022
Directory.CreateDirectory(krb5TargetDir);
2123

2224
var currentAssemblyDir = ((AbsolutePath)Assembly.GetExecutingAssembly().Location).Parent;
2325
var buildpackDir = currentAssemblyDir.Parent;
2426
var sidecarSrcDir = buildpackDir / "deps" / "sidecar";
2527
var sidecarTargetDir = myDependenciesDirectory / "sidecar";
2628
var krb5SourceDir = buildpackDir / "deps" / ".krb5";
29+
var krb5Environment = Environment.GetEnvironmentVariable("KRB_ENVIRONMENT");
30+
if (krb5Environment != null)
31+
{
32+
krb5SourceDir = krb5SourceDir / krb5Environment;
33+
}
2734
if (Directory.Exists(krb5SourceDir))
2835
{
2936
FileSystemTasks.CopyDirectoryRecursively(krb5SourceDir, krb5TargetDir, DirectoryExistsPolicy.Merge, FileExistsPolicy.Skip);

0 commit comments

Comments
 (0)