Skip to content

Commit

Permalink
Change where the keychain dockercreds are read
Browse files Browse the repository at this point in the history
  • Loading branch information
xtreme-shane-lattanzio committed Nov 29, 2023
1 parent 5a99b7d commit 60ff8a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 6 additions & 0 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,47 @@ update_settings( max_parallel_updates = 5, k8s_upsert_timeout_secs = 200 )

pack('controller',
deps = ['./cmd/controller/build'],
builder='gcriocfbuildservice/kpack-builder:latest',
live_update = [ sync('./cmd/controller/build', '/tmp/tilt'),
run('cp -rf /tmp/tilt/* /layers/paketo-buildpacks_go-build/targets/bin', trigger=['./cmd/controller/build']),
],
env_vars=['BP_GO_TARGETS=./cmd/controller', 'BP_LIVE_RELOAD_ENABLED=true']
)
pack('webhook',
deps = ['./cmd/webhook/build'],
builder='gcriocfbuildservice/kpack-builder:latest',
live_update = [ sync('./cmd/webhook/build', '/tmp/tilt'),
run('cp -rf /tmp/tilt/* /layers/paketo-buildpacks_go-build/targets/bin', trigger=['./cmd/webhook/build']),
],
env_vars=['BP_GO_TARGETS=./cmd/webhook', 'BP_LIVE_RELOAD_ENABLED=true']
)
pack('build-init',
deps = ['./cmd/build-init/build'],
builder='gcriocfbuildservice/kpack-builder:latest',
live_update = [ sync('./cmd/build-init/build', '/tmp/tilt'),
run('cp -rf /tmp/tilt/* /layers/paketo-buildpacks_go-build/targets/bin', trigger=['./cmd/build-init/build']),
],
env_vars=['BP_GO_TARGETS=./cmd/build-init', 'BP_LIVE_RELOAD_ENABLED=true']
)
pack('build-waiter',
deps = ['./cmd/build-waiter/build'],
builder='gcriocfbuildservice/kpack-builder:latest',
live_update = [ sync('./cmd/build-waiter/build', '/tmp/tilt'),
run('cp -rf /tmp/tilt/* /layers/paketo-buildpacks_go-build/targets/bin', trigger=['./cmd/build-waiter/build']),
],
env_vars=['BP_GO_TARGETS=./cmd/build-waiter', 'BP_LIVE_RELOAD_ENABLED=true']
)
pack('rebase',
deps = ['./cmd/rebase/build'],
builder='gcriocfbuildservice/kpack-builder:latest',
live_update = [ sync('./cmd/rebase/build', '/tmp/tilt'),
run('cp -rf /tmp/tilt/* /layers/paketo-buildpacks_go-build/targets/bin', trigger=['./cmd/rebase/build']),
],
env_vars=['BP_GO_TARGETS=./cmd/rebase', 'BP_LIVE_RELOAD_ENABLED=true']
)
pack('completion',
deps = ['./cmd/completion/build'],
builder='gcriocfbuildservice/kpack-builder:latest',
live_update = [ sync('./cmd/completion/build', '/tmp/tilt'),
run('cp -rf /tmp/tilt/* /layers/paketo-buildpacks_go-build/targets/bin/', trigger=['./cmd/completion/build']),
],
Expand Down
13 changes: 5 additions & 8 deletions pkg/dockercreds/k8sdockercreds/k8s_keychain.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,18 @@ type k8sSecretKeychainFactory struct {
}

func NewSecretKeychainFactory(client k8sclient.Interface) (registry.KeychainFactory, error) {
volumeKeychain, err := dockercreds.NewVolumeSecretKeychain()
if err != nil {
return nil, err
}

return &k8sSecretKeychainFactory{client: client, volumeKeychain: volumeKeychain}, nil
return &k8sSecretKeychainFactory{client: client}, nil
}

func (f *k8sSecretKeychainFactory) KeychainForSecretRef(ctx context.Context, ref registry.SecretRef) (authn.Keychain, error) {
volumeKeychain, err := dockercreds.NewVolumeSecretKeychain()

if !ref.IsNamespaced() {
k8sKeychain, err := k8schain.NewNoClient(context.Background())
if err != nil {
return nil, err
}
return authn.NewMultiKeychain(f.volumeKeychain, k8sKeychain, azureFileKeychain), nil // k8s keychain with no secrets
return authn.NewMultiKeychain(volumeKeychain, k8sKeychain, azureFileKeychain), nil // k8s keychain with no secrets
}

serviceAccountKeychain, err := keychainFromServiceAccount(ctx, ref, &secret.Fetcher{Client: f.client})
Expand All @@ -56,7 +53,7 @@ func (f *k8sSecretKeychainFactory) KeychainForSecretRef(ctx context.Context, ref
return nil, err
}

return authn.NewMultiKeychain(serviceAccountKeychain, f.volumeKeychain, k8sKeychain, azureFileKeychain), nil
return authn.NewMultiKeychain(serviceAccountKeychain, volumeKeychain, k8sKeychain, azureFileKeychain), nil
}

func toStringPullSecrets(secrets []corev1.LocalObjectReference) []string {
Expand Down

0 comments on commit 60ff8a2

Please sign in to comment.