Add caBundle to bitbucket

Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
pull/2121/head
Somtochi Onyekwere 3 years ago
parent 43c6a1531a
commit a03574f8c3

@ -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…
Cancel
Save