Skip to content

Commit 883a3f3

Browse files
committed
fix: read GitHub token from Secret
1 parent 08c8777 commit 883a3f3

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

examples/providerconfig/providerconfig.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ spec:
66
credentials:
77
source: Secret
88
secretRef:
9-
name: example-creds
9+
name: github-creds
1010
namespace: crossplane-system
1111
key: credentials

examples/providerconfig/secret.yaml.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: Secret
33
metadata:
4-
name: example-creds
4+
name: github-creds
55
namespace: crossplane-system
66
type: Opaque
77
stringData:

internal/clients/github.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package clients
1919
import (
2020
"context"
2121
"encoding/json"
22+
"fmt"
2223

2324
"github.com/crossplane/crossplane-runtime/pkg/resource"
2425
"github.com/pkg/errors"
@@ -40,6 +41,12 @@ const (
4041
// GitHub provider config
4142
keyBaseURL = "base_url"
4243
keyOwner = "owner"
44+
keyToken = "token"
45+
46+
// GitHub credentials environment variable names
47+
envToken = "GITHUB_TOKEN"
48+
49+
fmtEnvVar = "%s=%s"
4350
)
4451

4552
// TerraformSetupBuilder builds Terraform a terraform.SetupFn function which
@@ -85,6 +92,11 @@ func TerraformSetupBuilder(version, providerSource, providerVersion string) terr
8592
ps.Configuration[keyOwner] = v
8693
}
8794

95+
// set environment variables for sensitive provider configuration
96+
ps.Env = []string{
97+
fmt.Sprintf(fmtEnvVar, envToken, githubCreds[keyToken]),
98+
}
99+
88100
return ps, nil
89101
}
90102
}

0 commit comments

Comments
 (0)