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 aff099e commit a704e39
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion pkg/controller/imagebuild/component/builddispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (c *BuildDispatcherComponent) Reconcile(ctx *core.Context) (ctrl.Result, er
return ctrl.Result{}, c.phase.SetFailed(ctx, obj, err)
}

if c.keycloakCfg.Enabled {
if obj.Spec.EnableServiceAccountTokenInjection && c.keycloakCfg.Enabled {
buildLog.Info("Acquiring Keycloak service account token")
kc := gocloak.NewClient(c.keycloakCfg.Server)
jwt, err := kc.LoginClient(buildCtx, c.keycloakCfg.ClientID, c.keycloakCfg.ClientSecret, c.keycloakCfg.Realm)
Expand Down

0 comments on commit a704e39

Please sign in to comment.