Skip to content

Commit

Permalink
Add EnableServiceAccountTokenInjection to CRD
Browse files Browse the repository at this point in the history
  • Loading branch information
ddl-ebrown committed Jun 22, 2023
1 parent 245af02 commit 3043408
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ spec:
description: DisableCacheLayerExport will remove the "inline" cache
metadata from the image configuration.
type: boolean
enableServiceAccountTokenInjection:
description: EnableServiceAccountTokenInjection adds a service account
JWT token as build-arg to the images. This supports use cases like
model building that must access other Domino services
type: boolean
images:
description: Images is a list of images to build and push.
items:
Expand Down
3 changes: 3 additions & 0 deletions pkg/api/hephaestus/v1/imagebuild_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ type ImageBuildSpec struct {
DisableLocalBuildCache bool `json:"disableBuildCache,omitempty"`
// DisableCacheLayerExport will remove the "inline" cache metadata from the image configuration.
DisableCacheLayerExport bool `json:"disableCacheExport,omitempty"`
// EnableServiceAccountTokenInjection adds a service account JWT token as build-arg to the images.
// This supports use cases like model building that must access other Domino services
EnableServiceAccountTokenInjection bool `json:"enableServiceAccountTokenInjection,omitempty"`
}

type ImageBuildTransition struct {
Expand Down
3 changes: 1 addition & 2 deletions pkg/controller/imagebuild/component/builddispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ func (c *BuildDispatcherComponent) Reconcile(ctx *core.Context) (ctrl.Result, er
}
clientInitSeg.End()

// TODO: Also inspect CR to determine if JWT injection is allowed
if c.keycloakCfg.Enabled {
if obj.Spec.EnableServiceAccountTokenInjection && c.keycloakCfg.Enabled {
kc := gocloak.NewClient(c.keycloakCfg.Server)
jwt, err := kc.LoginClient(buildCtx, c.keycloakCfg.ClientID, c.keycloakCfg.ClientSecret, c.keycloakCfg.Realm)
if err != nil {
Expand Down

0 comments on commit 3043408

Please sign in to comment.