Skip to content

Commit

Permalink
[library usage] Move modules under pkg to pkg/internal (#376)
Browse files Browse the repository at this point in the history
* refactor: move packages into `pkg/internal`

* feat: hide sub commands from package exports

* fix: revert go version change
  • Loading branch information
bcho authored Dec 20, 2023
1 parent 3e83c88 commit c6802f6
Show file tree
Hide file tree
Showing 58 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions pkg/cmd/convert.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package cmd

import (
"github.com/Azure/kubelogin/pkg/converter"
"github.com/Azure/kubelogin/pkg/internal/converter"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/clientcmd"
)

// NewConvertCmd provides a cobra command for convert sub command
func NewConvertCmd() *cobra.Command {
// newConvertCmd provides a cobra command for convert sub command
func newConvertCmd() *cobra.Command {
o := converter.New()

cmd := &cobra.Command{
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/removetokencache.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package cmd
import (
"os"

"github.com/Azure/kubelogin/pkg/token"
"github.com/Azure/kubelogin/pkg/internal/token"
"github.com/spf13/cobra"
klog "k8s.io/klog/v2"
)

// NewRemoveTokenCacheCmd provides a cobra command for removing token cache sub command
func NewRemoveTokenCacheCmd() *cobra.Command {
// newRemoveTokenCacheCmd provides a cobra command for removing token cache sub command
func newRemoveTokenCacheCmd() *cobra.Command {
var tokenCacheDir string

cmd := &cobra.Command{
Expand Down
6 changes: 3 additions & 3 deletions pkg/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ func NewRootCmd(version string) *cobra.Command {
},
}

cmd.AddCommand(NewConvertCmd())
cmd.AddCommand(NewTokenCmd())
cmd.AddCommand(NewRemoveTokenCacheCmd())
cmd.AddCommand(newConvertCmd())
cmd.AddCommand(newTokenCmd())
cmd.AddCommand(newRemoveTokenCacheCmd())

return cmd
}
6 changes: 3 additions & 3 deletions pkg/cmd/token.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package cmd

import (
"github.com/Azure/kubelogin/pkg/token"
"github.com/Azure/kubelogin/pkg/internal/token"
"github.com/spf13/cobra"
)

// NewTokenCmd provides a cobra command for convert sub command
func NewTokenCmd() *cobra.Command {
// newTokenCmd provides a cobra command for convert sub command
func newTokenCmd() *cobra.Command {
o := token.NewOptions()

cmd := &cobra.Command{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/Azure/kubelogin/pkg/token"
"github.com/Azure/kubelogin/pkg/internal/token"
"k8s.io/client-go/tools/clientcmd"
"k8s.io/client-go/tools/clientcmd/api"
klog "k8s.io/klog/v2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"path/filepath"
"testing"

"github.com/Azure/kubelogin/pkg/token"
"github.com/Azure/kubelogin/pkg/internal/token"
"github.com/spf13/pflag"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/tools/clientcmd"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package converter
import (
"fmt"

"github.com/Azure/kubelogin/pkg/token"
"github.com/Azure/kubelogin/pkg/internal/token"
"github.com/spf13/pflag"
"k8s.io/cli-runtime/pkg/genericclioptions"
)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pkg/pop/msal_test.go → pkg/internal/pop/msal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
"github.com/Azure/kubelogin/pkg/testutils"
"github.com/Azure/kubelogin/pkg/internal/testutils"
"github.com/AzureAD/microsoft-authentication-library-for-go/apps/confidential"
"github.com/golang-jwt/jwt/v4"
"github.com/google/uuid"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package token
import (
"testing"

"github.com/Azure/kubelogin/pkg/testutils"
"github.com/Azure/kubelogin/pkg/internal/testutils"
)

func TestNewAzureCLITokenEmpty(t *testing.T) {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/kubelogin/pkg/testutils"
"github.com/Azure/kubelogin/pkg/internal/testutils"
)

func TestNewDeviceCodeTokenProviderEmpty(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package token

//go:generate sh -c "mockgen -destination mock_$GOPACKAGE/execCredentialPlugin.go github.com/Azure/kubelogin/pkg/token ExecCredentialPlugin"
//go:generate sh -c "mockgen -destination mock_$GOPACKAGE/execCredentialPlugin.go github.com/Azure/kubelogin/pkg/internal/token ExecCredentialPlugin"

import (
"fmt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"time"

"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/kubelogin/pkg/token/mock_token"
"github.com/Azure/kubelogin/pkg/internal/token/mock_token"
"github.com/golang/mock/gomock"
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package token

//go:generate sh -c "mockgen -destination mock_$GOPACKAGE/execCredentialWriter.go github.com/Azure/kubelogin/pkg/token ExecCredentialWriter"
//go:generate sh -c "mockgen -destination mock_$GOPACKAGE/execCredentialWriter.go github.com/Azure/kubelogin/pkg/internal/token ExecCredentialWriter"

import (
"encoding/json"
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"testing"

"github.com/Azure/kubelogin/pkg/testutils"
"github.com/Azure/kubelogin/pkg/internal/testutils"
)

func TestNewWorkloadIdentityTokenProviderEmpty(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/kubelogin/pkg/pop"
"github.com/Azure/kubelogin/pkg/internal/pop"
)

type InteractiveToken struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"testing"

"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/kubelogin/pkg/testutils"
"github.com/Azure/kubelogin/pkg/internal/testutils"
"github.com/google/go-cmp/cmp"
)

Expand Down
File renamed without changes.
File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"testing"
"time"

"github.com/Azure/kubelogin/pkg/testutils"
"github.com/Azure/kubelogin/pkg/internal/testutils"
"github.com/google/go-cmp/cmp"
"github.com/spf13/pflag"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/token/provider.go → pkg/internal/token/provider.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package token

//go:generate sh -c "mockgen -destination mock_$GOPACKAGE/provider.go github.com/Azure/kubelogin/pkg/token TokenProvider"
//go:generate sh -c "mockgen -destination mock_$GOPACKAGE/provider.go github.com/Azure/kubelogin/pkg/internal/token TokenProvider"

import (
"errors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package token
import (
"testing"

"github.com/Azure/kubelogin/pkg/testutils"
"github.com/Azure/kubelogin/pkg/internal/testutils"
"github.com/google/go-cmp/cmp"
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
"github.com/Azure/go-autorest/autorest/adal"
"github.com/Azure/kubelogin/pkg/testutils"
"github.com/Azure/kubelogin/pkg/internal/testutils"
"github.com/golang-jwt/jwt/v5"
"github.com/google/go-cmp/cmp"
"github.com/google/uuid"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/kubelogin/pkg/pop"
"github.com/Azure/kubelogin/pkg/internal/pop"
"github.com/AzureAD/microsoft-authentication-library-for-go/apps/confidential"
"golang.org/x/crypto/pkcs12"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package token
import (
"testing"

"github.com/Azure/kubelogin/pkg/testutils"
"github.com/Azure/kubelogin/pkg/internal/testutils"
)

func TestMissingCertFile(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/Azure/azure-sdk-for-go/sdk/azcore"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/policy"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/kubelogin/pkg/pop"
"github.com/Azure/kubelogin/pkg/internal/pop"
"github.com/AzureAD/microsoft-authentication-library-for-go/apps/confidential"
)

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package token

//go:generate sh -c "mockgen -destination mock_$GOPACKAGE/tokenCache.go github.com/Azure/kubelogin/pkg/token TokenCache"
//go:generate sh -c "mockgen -destination mock_$GOPACKAGE/tokenCache.go github.com/Azure/kubelogin/pkg/internal/token TokenCache"

import (
"os"
Expand Down

0 comments on commit c6802f6

Please sign in to comment.