mirror of
https://github.com/vmware-tanzu/pinniped.git
synced 2026-08-28 03:46:10 +00:00
Rename project
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
"k8s.io/component-base/logs"
|
||||
"k8s.io/klog/v2"
|
||||
|
||||
"github.com/suzerain-io/placeholder-name/internal/server"
|
||||
"github.com/suzerain-io/pinniped/internal/server"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -16,8 +16,8 @@ import (
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
clientauthenticationv1beta1 "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1"
|
||||
|
||||
"github.com/suzerain-io/placeholder-name/internal/constable"
|
||||
"github.com/suzerain-io/placeholder-name/pkg/client"
|
||||
"github.com/suzerain-io/pinniped/internal/constable"
|
||||
"github.com/suzerain-io/pinniped/pkg/client"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -37,19 +37,19 @@ func run(envGetter envGetter, tokenExchanger tokenExchanger, outputWriter io.Wri
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
token, varExists := envGetter("PLACEHOLDER_NAME_TOKEN")
|
||||
token, varExists := envGetter("PINNIPED_TOKEN")
|
||||
if !varExists {
|
||||
return envVarNotSetError("PLACEHOLDER_NAME_TOKEN")
|
||||
return envVarNotSetError("PINNIPED_TOKEN")
|
||||
}
|
||||
|
||||
caBundle, varExists := envGetter("PLACEHOLDER_NAME_CA_BUNDLE")
|
||||
caBundle, varExists := envGetter("PINNIPED_CA_BUNDLE")
|
||||
if !varExists {
|
||||
return envVarNotSetError("PLACEHOLDER_NAME_CA_BUNDLE")
|
||||
return envVarNotSetError("PINNIPED_CA_BUNDLE")
|
||||
}
|
||||
|
||||
apiEndpoint, varExists := envGetter("PLACEHOLDER_NAME_K8S_API_ENDPOINT")
|
||||
apiEndpoint, varExists := envGetter("PINNIPED_K8S_API_ENDPOINT")
|
||||
if !varExists {
|
||||
return envVarNotSetError("PLACEHOLDER_NAME_K8S_API_ENDPOINT")
|
||||
return envVarNotSetError("PINNIPED_K8S_API_ENDPOINT")
|
||||
}
|
||||
|
||||
cred, err := tokenExchanger(ctx, token, caBundle, apiEndpoint)
|
||||
@@ -12,13 +12,13 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/suzerain-io/placeholder-name/internal/testutil"
|
||||
"github.com/suzerain-io/pinniped/internal/testutil"
|
||||
|
||||
"github.com/sclevine/spec"
|
||||
"github.com/sclevine/spec/report"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/suzerain-io/placeholder-name/pkg/client"
|
||||
"github.com/suzerain-io/pinniped/pkg/client"
|
||||
)
|
||||
|
||||
func TestRun(t *testing.T) {
|
||||
@@ -40,29 +40,29 @@ func TestRun(t *testing.T) {
|
||||
r = require.New(t)
|
||||
buffer = new(bytes.Buffer)
|
||||
fakeEnv = map[string]string{
|
||||
"PLACEHOLDER_NAME_TOKEN": "token from env",
|
||||
"PLACEHOLDER_NAME_CA_BUNDLE": "ca bundle from env",
|
||||
"PLACEHOLDER_NAME_K8S_API_ENDPOINT": "k8s api from env",
|
||||
"PINNIPED_TOKEN": "token from env",
|
||||
"PINNIPED_CA_BUNDLE": "ca bundle from env",
|
||||
"PINNIPED_K8S_API_ENDPOINT": "k8s api from env",
|
||||
}
|
||||
})
|
||||
|
||||
when("env vars are missing", func() {
|
||||
it("returns an error when PLACEHOLDER_NAME_TOKEN is missing", func() {
|
||||
delete(fakeEnv, "PLACEHOLDER_NAME_TOKEN")
|
||||
it("returns an error when PINNIPED_TOKEN is missing", func() {
|
||||
delete(fakeEnv, "PINNIPED_TOKEN")
|
||||
err := run(envGetter, tokenExchanger, buffer, 30*time.Second)
|
||||
r.EqualError(err, "failed to get credential: environment variable not set: PLACEHOLDER_NAME_TOKEN")
|
||||
r.EqualError(err, "failed to get credential: environment variable not set: PINNIPED_TOKEN")
|
||||
})
|
||||
|
||||
it("returns an error when PLACEHOLDER_NAME_CA_BUNDLE is missing", func() {
|
||||
delete(fakeEnv, "PLACEHOLDER_NAME_CA_BUNDLE")
|
||||
it("returns an error when PINNIPED_CA_BUNDLE is missing", func() {
|
||||
delete(fakeEnv, "PINNIPED_CA_BUNDLE")
|
||||
err := run(envGetter, tokenExchanger, buffer, 30*time.Second)
|
||||
r.EqualError(err, "failed to get credential: environment variable not set: PLACEHOLDER_NAME_CA_BUNDLE")
|
||||
r.EqualError(err, "failed to get credential: environment variable not set: PINNIPED_CA_BUNDLE")
|
||||
})
|
||||
|
||||
it("returns an error when PLACEHOLDER_NAME_K8S_API_ENDPOINT is missing", func() {
|
||||
delete(fakeEnv, "PLACEHOLDER_NAME_K8S_API_ENDPOINT")
|
||||
it("returns an error when PINNIPED_K8S_API_ENDPOINT is missing", func() {
|
||||
delete(fakeEnv, "PINNIPED_K8S_API_ENDPOINT")
|
||||
err := run(envGetter, tokenExchanger, buffer, 30*time.Second)
|
||||
r.EqualError(err, "failed to get credential: environment variable not set: PLACEHOLDER_NAME_K8S_API_ENDPOINT")
|
||||
r.EqualError(err, "failed to get credential: environment variable not set: PINNIPED_K8S_API_ENDPOINT")
|
||||
})
|
||||
})
|
||||
|
||||
@@ -129,9 +129,9 @@ func TestRun(t *testing.T) {
|
||||
it("writes the execCredential to the given writer", func() {
|
||||
err := run(envGetter, tokenExchanger, buffer, 30*time.Second)
|
||||
r.NoError(err)
|
||||
r.Equal(fakeEnv["PLACEHOLDER_NAME_TOKEN"], actualToken)
|
||||
r.Equal(fakeEnv["PLACEHOLDER_NAME_CA_BUNDLE"], actualCaBundle)
|
||||
r.Equal(fakeEnv["PLACEHOLDER_NAME_K8S_API_ENDPOINT"], actualAPIEndpoint)
|
||||
r.Equal(fakeEnv["PINNIPED_TOKEN"], actualToken)
|
||||
r.Equal(fakeEnv["PINNIPED_CA_BUNDLE"], actualCaBundle)
|
||||
r.Equal(fakeEnv["PINNIPED_K8S_API_ENDPOINT"], actualAPIEndpoint)
|
||||
expected := `{
|
||||
"kind": "ExecCredential",
|
||||
"apiVersion": "client.authentication.k8s.io/v1beta1",
|
||||
Reference in New Issue
Block a user