mirror of
https://github.com/fluxcd/flux2.git
synced 2026-02-24 00:21:46 +00:00
Add caBundle to bitbucket
Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
This commit is contained in:
parent
43c6a1531a
commit
a03574f8c3
2 changed files with 14 additions and 0 deletions
|
|
@ -141,12 +141,22 @@ func bootstrapBServerCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
user = bServerArgs.owner
|
user = bServerArgs.owner
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var caBundle []byte
|
||||||
|
if bootstrapArgs.caFile != "" {
|
||||||
|
var err error
|
||||||
|
caBundle, err = os.ReadFile(bootstrapArgs.caFile)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("unable to read TLS CA file: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Build Bitbucket Server provider
|
// Build Bitbucket Server provider
|
||||||
providerCfg := provider.Config{
|
providerCfg := provider.Config{
|
||||||
Provider: provider.GitProviderStash,
|
Provider: provider.GitProviderStash,
|
||||||
Hostname: bServerArgs.hostname,
|
Hostname: bServerArgs.hostname,
|
||||||
Username: user,
|
Username: user,
|
||||||
Token: bitbucketToken,
|
Token: bitbucketToken,
|
||||||
|
CaBundle: caBundle,
|
||||||
}
|
}
|
||||||
|
|
||||||
providerClient, err := provider.BuildGitProvider(providerCfg)
|
providerClient, err := provider.BuildGitProvider(providerCfg)
|
||||||
|
|
@ -243,6 +253,7 @@ func bootstrapBServerCmdRun(cmd *cobra.Command, args []string) error {
|
||||||
bootstrap.WithReadWriteKeyPermissions(bServerArgs.readWriteKey),
|
bootstrap.WithReadWriteKeyPermissions(bServerArgs.readWriteKey),
|
||||||
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
bootstrap.WithKubeconfig(rootArgs.kubeconfig, rootArgs.kubecontext),
|
||||||
bootstrap.WithLogger(logger),
|
bootstrap.WithLogger(logger),
|
||||||
|
bootstrap.WithCABundle(caBundle),
|
||||||
}
|
}
|
||||||
if bootstrapArgs.sshHostname != "" {
|
if bootstrapArgs.sshHostname != "" {
|
||||||
bootstrapOpts = append(bootstrapOpts, bootstrap.WithSSHHostname(bootstrapArgs.sshHostname))
|
bootstrapOpts = append(bootstrapOpts, bootstrap.WithSSHHostname(bootstrapArgs.sshHostname))
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,9 @@ func BuildGitProvider(config Config) (gitprovider.Client, error) {
|
||||||
if config.Hostname != "" {
|
if config.Hostname != "" {
|
||||||
opts = append(opts, gitprovider.WithDomain(config.Hostname))
|
opts = append(opts, gitprovider.WithDomain(config.Hostname))
|
||||||
}
|
}
|
||||||
|
if config.CaBundle != nil {
|
||||||
|
opts = append(opts, gitprovider.WithCustomCAPostChainTransportHook(config.CaBundle))
|
||||||
|
}
|
||||||
if client, err = stash.NewStashClient(config.Username, config.Token, opts...); err != nil {
|
if client, err = stash.NewStashClient(config.Username, config.Token, opts...); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue