From e0a9bef6ceab0cf20a36c307fb75098d06a2dee3 Mon Sep 17 00:00:00 2001 From: Matt Moyer Date: Tue, 17 Nov 2020 12:46:54 -0600 Subject: [PATCH] Move `./internal/oidcclient` to `./pkg/oidcclient`. This will allow it to be imported by Go code outside of our repository, which was something we have planned for since this code was written. Signed-off-by: Matt Moyer --- Dockerfile | 1 + cmd/pinniped/cmd/login_oidc.go | 4 ++-- cmd/pinniped/cmd/login_oidc_test.go | 2 +- internal/oidc/auth/auth_handler.go | 4 ++-- internal/oidc/auth/auth_handler_test.go | 4 ++-- internal/oidc/provider/manager/manager.go | 4 ++-- {internal => pkg}/oidcclient/filesession/cachefile.go | 2 +- {internal => pkg}/oidcclient/filesession/cachefile_test.go | 2 +- {internal => pkg}/oidcclient/filesession/filesession.go | 2 +- .../oidcclient/filesession/filesession_test.go | 2 +- .../oidcclient/filesession/testdata/invalid.yaml | 0 .../oidcclient/filesession/testdata/valid.yaml | 0 .../oidcclient/filesession/testdata/wrong-version.yaml | 0 {internal => pkg}/oidcclient/login.go | 6 +++--- {internal => pkg}/oidcclient/login_test.go | 6 +++--- {internal => pkg}/oidcclient/nonce/nonce.go | 0 {internal => pkg}/oidcclient/nonce/nonce_test.go | 0 {internal => pkg}/oidcclient/pkce/pkce.go | 0 {internal => pkg}/oidcclient/pkce/pkce_test.go | 0 {internal => pkg}/oidcclient/state/state.go | 0 {internal => pkg}/oidcclient/state/state_test.go | 0 {internal => pkg}/oidcclient/types.go | 0 test/integration/cli_test.go | 4 ++-- test/integration/supervisor_login_test.go | 6 +++--- 24 files changed, 25 insertions(+), 24 deletions(-) rename {internal => pkg}/oidcclient/filesession/cachefile.go (99%) rename {internal => pkg}/oidcclient/filesession/cachefile_test.go (99%) rename {internal => pkg}/oidcclient/filesession/filesession.go (99%) rename {internal => pkg}/oidcclient/filesession/filesession_test.go (99%) rename {internal => pkg}/oidcclient/filesession/testdata/invalid.yaml (100%) rename {internal => pkg}/oidcclient/filesession/testdata/valid.yaml (100%) rename {internal => pkg}/oidcclient/filesession/testdata/wrong-version.yaml (100%) rename {internal => pkg}/oidcclient/login.go (98%) rename {internal => pkg}/oidcclient/login_test.go (99%) rename {internal => pkg}/oidcclient/nonce/nonce.go (100%) rename {internal => pkg}/oidcclient/nonce/nonce_test.go (100%) rename {internal => pkg}/oidcclient/pkce/pkce.go (100%) rename {internal => pkg}/oidcclient/pkce/pkce_test.go (100%) rename {internal => pkg}/oidcclient/state/state.go (100%) rename {internal => pkg}/oidcclient/state/state_test.go (100%) rename {internal => pkg}/oidcclient/types.go (100%) diff --git a/Dockerfile b/Dockerfile index 7ddea4d4..73803e6e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,6 +13,7 @@ RUN go mod download # Copy only the production source code to avoid cache misses when editing other files COPY generated ./generated COPY cmd ./cmd +COPY pkg ./pkg COPY internal ./internal COPY tools ./tools COPY hack ./hack diff --git a/cmd/pinniped/cmd/login_oidc.go b/cmd/pinniped/cmd/login_oidc.go index bf12e7be..1677c00f 100644 --- a/cmd/pinniped/cmd/login_oidc.go +++ b/cmd/pinniped/cmd/login_oidc.go @@ -18,8 +18,8 @@ import ( clientauthenticationv1beta1 "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1" "k8s.io/klog/v2/klogr" - "go.pinniped.dev/internal/oidcclient" - "go.pinniped.dev/internal/oidcclient/filesession" + "go.pinniped.dev/pkg/oidcclient" + "go.pinniped.dev/pkg/oidcclient/filesession" ) //nolint: gochecknoinits diff --git a/cmd/pinniped/cmd/login_oidc_test.go b/cmd/pinniped/cmd/login_oidc_test.go index a8bb03ed..3a61934d 100644 --- a/cmd/pinniped/cmd/login_oidc_test.go +++ b/cmd/pinniped/cmd/login_oidc_test.go @@ -12,7 +12,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "go.pinniped.dev/internal/here" - "go.pinniped.dev/internal/oidcclient" + "go.pinniped.dev/pkg/oidcclient" ) func TestLoginOIDCCommand(t *testing.T) { diff --git a/internal/oidc/auth/auth_handler.go b/internal/oidc/auth/auth_handler.go index de3c7f71..ec752cf3 100644 --- a/internal/oidc/auth/auth_handler.go +++ b/internal/oidc/auth/auth_handler.go @@ -19,9 +19,9 @@ import ( "go.pinniped.dev/internal/httputil/httperr" "go.pinniped.dev/internal/oidc/csrftoken" "go.pinniped.dev/internal/oidc/provider" - "go.pinniped.dev/internal/oidcclient/nonce" - "go.pinniped.dev/internal/oidcclient/pkce" "go.pinniped.dev/internal/plog" + "go.pinniped.dev/pkg/oidcclient/nonce" + "go.pinniped.dev/pkg/oidcclient/pkce" ) const ( diff --git a/internal/oidc/auth/auth_handler_test.go b/internal/oidc/auth/auth_handler_test.go index e0fdbacd..dcd2f9d6 100644 --- a/internal/oidc/auth/auth_handler_test.go +++ b/internal/oidc/auth/auth_handler_test.go @@ -21,8 +21,8 @@ import ( "go.pinniped.dev/internal/oidc" "go.pinniped.dev/internal/oidc/csrftoken" "go.pinniped.dev/internal/oidc/provider" - "go.pinniped.dev/internal/oidcclient/nonce" - "go.pinniped.dev/internal/oidcclient/pkce" + "go.pinniped.dev/pkg/oidcclient/nonce" + "go.pinniped.dev/pkg/oidcclient/pkce" ) func TestAuthorizationEndpoint(t *testing.T) { diff --git a/internal/oidc/provider/manager/manager.go b/internal/oidc/provider/manager/manager.go index 0687ba22..723cfe67 100644 --- a/internal/oidc/provider/manager/manager.go +++ b/internal/oidc/provider/manager/manager.go @@ -16,9 +16,9 @@ import ( "go.pinniped.dev/internal/oidc/discovery" "go.pinniped.dev/internal/oidc/jwks" "go.pinniped.dev/internal/oidc/provider" - "go.pinniped.dev/internal/oidcclient/nonce" - "go.pinniped.dev/internal/oidcclient/pkce" "go.pinniped.dev/internal/plog" + "go.pinniped.dev/pkg/oidcclient/nonce" + "go.pinniped.dev/pkg/oidcclient/pkce" ) // Manager can manage multiple active OIDC providers. It acts as a request router for them. diff --git a/internal/oidcclient/filesession/cachefile.go b/pkg/oidcclient/filesession/cachefile.go similarity index 99% rename from internal/oidcclient/filesession/cachefile.go rename to pkg/oidcclient/filesession/cachefile.go index 14c055f3..3629ca5f 100644 --- a/internal/oidcclient/filesession/cachefile.go +++ b/pkg/oidcclient/filesession/cachefile.go @@ -16,7 +16,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "sigs.k8s.io/yaml" - "go.pinniped.dev/internal/oidcclient" + "go.pinniped.dev/pkg/oidcclient" ) var ( diff --git a/internal/oidcclient/filesession/cachefile_test.go b/pkg/oidcclient/filesession/cachefile_test.go similarity index 99% rename from internal/oidcclient/filesession/cachefile_test.go rename to pkg/oidcclient/filesession/cachefile_test.go index d9094271..0ddcdf9b 100644 --- a/internal/oidcclient/filesession/cachefile_test.go +++ b/pkg/oidcclient/filesession/cachefile_test.go @@ -11,7 +11,7 @@ import ( "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "go.pinniped.dev/internal/oidcclient" + "go.pinniped.dev/pkg/oidcclient" ) // validSession should be the same data as `testdata/valid.yaml`. diff --git a/internal/oidcclient/filesession/filesession.go b/pkg/oidcclient/filesession/filesession.go similarity index 99% rename from internal/oidcclient/filesession/filesession.go rename to pkg/oidcclient/filesession/filesession.go index 880d608e..47e0f761 100644 --- a/internal/oidcclient/filesession/filesession.go +++ b/pkg/oidcclient/filesession/filesession.go @@ -15,7 +15,7 @@ import ( "github.com/gofrs/flock" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "go.pinniped.dev/internal/oidcclient" + "go.pinniped.dev/pkg/oidcclient" ) const ( diff --git a/internal/oidcclient/filesession/filesession_test.go b/pkg/oidcclient/filesession/filesession_test.go similarity index 99% rename from internal/oidcclient/filesession/filesession_test.go rename to pkg/oidcclient/filesession/filesession_test.go index 8dd07bc9..1b28e184 100644 --- a/internal/oidcclient/filesession/filesession_test.go +++ b/pkg/oidcclient/filesession/filesession_test.go @@ -15,7 +15,7 @@ import ( "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "go.pinniped.dev/internal/oidcclient" + "go.pinniped.dev/pkg/oidcclient" ) func TestNew(t *testing.T) { diff --git a/internal/oidcclient/filesession/testdata/invalid.yaml b/pkg/oidcclient/filesession/testdata/invalid.yaml similarity index 100% rename from internal/oidcclient/filesession/testdata/invalid.yaml rename to pkg/oidcclient/filesession/testdata/invalid.yaml diff --git a/internal/oidcclient/filesession/testdata/valid.yaml b/pkg/oidcclient/filesession/testdata/valid.yaml similarity index 100% rename from internal/oidcclient/filesession/testdata/valid.yaml rename to pkg/oidcclient/filesession/testdata/valid.yaml diff --git a/internal/oidcclient/filesession/testdata/wrong-version.yaml b/pkg/oidcclient/filesession/testdata/wrong-version.yaml similarity index 100% rename from internal/oidcclient/filesession/testdata/wrong-version.yaml rename to pkg/oidcclient/filesession/testdata/wrong-version.yaml diff --git a/internal/oidcclient/login.go b/pkg/oidcclient/login.go similarity index 98% rename from internal/oidcclient/login.go rename to pkg/oidcclient/login.go index 6fda48c9..0898f944 100644 --- a/internal/oidcclient/login.go +++ b/pkg/oidcclient/login.go @@ -20,9 +20,9 @@ import ( "go.pinniped.dev/internal/httputil/httperr" "go.pinniped.dev/internal/httputil/securityheader" - "go.pinniped.dev/internal/oidcclient/nonce" - "go.pinniped.dev/internal/oidcclient/pkce" - "go.pinniped.dev/internal/oidcclient/state" + "go.pinniped.dev/pkg/oidcclient/nonce" + "go.pinniped.dev/pkg/oidcclient/pkce" + "go.pinniped.dev/pkg/oidcclient/state" ) const ( diff --git a/internal/oidcclient/login_test.go b/pkg/oidcclient/login_test.go similarity index 99% rename from internal/oidcclient/login_test.go rename to pkg/oidcclient/login_test.go index 35574ba0..b323f586 100644 --- a/internal/oidcclient/login_test.go +++ b/pkg/oidcclient/login_test.go @@ -23,9 +23,9 @@ import ( "go.pinniped.dev/internal/httputil/httperr" "go.pinniped.dev/internal/mocks/mockkeyset" - "go.pinniped.dev/internal/oidcclient/nonce" - "go.pinniped.dev/internal/oidcclient/pkce" - "go.pinniped.dev/internal/oidcclient/state" + "go.pinniped.dev/pkg/oidcclient/nonce" + "go.pinniped.dev/pkg/oidcclient/pkce" + "go.pinniped.dev/pkg/oidcclient/state" ) // mockSessionCache exists to avoid an import cycle if we generate mocks into another package. diff --git a/internal/oidcclient/nonce/nonce.go b/pkg/oidcclient/nonce/nonce.go similarity index 100% rename from internal/oidcclient/nonce/nonce.go rename to pkg/oidcclient/nonce/nonce.go diff --git a/internal/oidcclient/nonce/nonce_test.go b/pkg/oidcclient/nonce/nonce_test.go similarity index 100% rename from internal/oidcclient/nonce/nonce_test.go rename to pkg/oidcclient/nonce/nonce_test.go diff --git a/internal/oidcclient/pkce/pkce.go b/pkg/oidcclient/pkce/pkce.go similarity index 100% rename from internal/oidcclient/pkce/pkce.go rename to pkg/oidcclient/pkce/pkce.go diff --git a/internal/oidcclient/pkce/pkce_test.go b/pkg/oidcclient/pkce/pkce_test.go similarity index 100% rename from internal/oidcclient/pkce/pkce_test.go rename to pkg/oidcclient/pkce/pkce_test.go diff --git a/internal/oidcclient/state/state.go b/pkg/oidcclient/state/state.go similarity index 100% rename from internal/oidcclient/state/state.go rename to pkg/oidcclient/state/state.go diff --git a/internal/oidcclient/state/state_test.go b/pkg/oidcclient/state/state_test.go similarity index 100% rename from internal/oidcclient/state/state_test.go rename to pkg/oidcclient/state/state_test.go diff --git a/internal/oidcclient/types.go b/pkg/oidcclient/types.go similarity index 100% rename from internal/oidcclient/types.go rename to pkg/oidcclient/types.go diff --git a/test/integration/cli_test.go b/test/integration/cli_test.go index 6a1c2a15..48c65833 100644 --- a/test/integration/cli_test.go +++ b/test/integration/cli_test.go @@ -26,8 +26,8 @@ import ( "gopkg.in/square/go-jose.v2" clientauthenticationv1beta1 "k8s.io/client-go/pkg/apis/clientauthentication/v1beta1" - "go.pinniped.dev/internal/oidcclient" - "go.pinniped.dev/internal/oidcclient/filesession" + "go.pinniped.dev/pkg/oidcclient" + "go.pinniped.dev/pkg/oidcclient/filesession" "go.pinniped.dev/test/library" ) diff --git a/test/integration/supervisor_login_test.go b/test/integration/supervisor_login_test.go index 7c19abfe..3ac2fab8 100644 --- a/test/integration/supervisor_login_test.go +++ b/test/integration/supervisor_login_test.go @@ -19,9 +19,9 @@ import ( "golang.org/x/oauth2" idpv1alpha1 "go.pinniped.dev/generated/1.19/apis/supervisor/idp/v1alpha1" - "go.pinniped.dev/internal/oidcclient/nonce" - "go.pinniped.dev/internal/oidcclient/pkce" - "go.pinniped.dev/internal/oidcclient/state" + "go.pinniped.dev/pkg/oidcclient/nonce" + "go.pinniped.dev/pkg/oidcclient/pkce" + "go.pinniped.dev/pkg/oidcclient/state" "go.pinniped.dev/test/library" )