Skip to content

Commit

Permalink
Using security context during registration (#328)
Browse files Browse the repository at this point in the history
Signed-off-by: Prafulla Mahindrakar <[email protected]>
  • Loading branch information
pmahindrakar-oss authored Jun 4, 2022
1 parent b092146 commit 096e377
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion flytectl/cmd/register/register_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,8 +402,14 @@ func hydrateLaunchPlanSpec(configAssumableIamRole string, configK8sServiceAccoun
outputLocationPrefix := len(configOutputLocationPrefix) > 0
if assumableIamRole || k8sServiceAcct {
lpSpec.AuthRole = &admin.AuthRole{
AssumableIamRole: configAssumableIamRole,
KubernetesServiceAccount: configK8sServiceAccount,
AssumableIamRole: configAssumableIamRole,
}
lpSpec.SecurityContext = &core.SecurityContext{
RunAs: &core.Identity{
IamRole: configAssumableIamRole,
K8SServiceAccount: configK8sServiceAccount,
},
}
}
if outputLocationPrefix {
Expand Down
3 changes: 3 additions & 0 deletions flytectl/cmd/register/register_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ func TestHydrateLaunchPlanSpec(t *testing.T) {
err := hydrateLaunchPlanSpec(rconfig.DefaultFilesConfig.AssumableIamRole, rconfig.DefaultFilesConfig.K8sServiceAccount, rconfig.DefaultFilesConfig.OutputLocationPrefix, lpSpec)
assert.Nil(t, err)
assert.Equal(t, &admin.AuthRole{AssumableIamRole: "iamRole"}, lpSpec.AuthRole)
assert.Equal(t, &core.SecurityContext{RunAs: &core.Identity{IamRole: "iamRole"}}, lpSpec.SecurityContext)
})
t.Run("k8sService account override", func(t *testing.T) {
registerFilesSetup()
Expand All @@ -355,6 +356,7 @@ func TestHydrateLaunchPlanSpec(t *testing.T) {
err := hydrateLaunchPlanSpec(rconfig.DefaultFilesConfig.AssumableIamRole, rconfig.DefaultFilesConfig.K8sServiceAccount, rconfig.DefaultFilesConfig.OutputLocationPrefix, lpSpec)
assert.Nil(t, err)
assert.Equal(t, &admin.AuthRole{KubernetesServiceAccount: "k8Account"}, lpSpec.AuthRole)
assert.Equal(t, &core.SecurityContext{RunAs: &core.Identity{K8SServiceAccount: "k8Account"}}, lpSpec.SecurityContext)
})
t.Run("Both k8sService and IamRole", func(t *testing.T) {
registerFilesSetup()
Expand All @@ -365,6 +367,7 @@ func TestHydrateLaunchPlanSpec(t *testing.T) {
assert.Nil(t, err)
assert.Equal(t, &admin.AuthRole{AssumableIamRole: "iamRole",
KubernetesServiceAccount: "k8Account"}, lpSpec.AuthRole)
assert.Equal(t, &core.SecurityContext{RunAs: &core.Identity{IamRole: "iamRole", K8SServiceAccount: "k8Account"}}, lpSpec.SecurityContext)
})
t.Run("Output prefix", func(t *testing.T) {
registerFilesSetup()
Expand Down

0 comments on commit 096e377

Please sign in to comment.