Skip to content

Commit

Permalink
Merge branch 'master' into fix-create-timestamp-null
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrancisc authored Aug 6, 2024
2 parents 7806a48 + de57ecd commit d0e0da2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
9 changes: 2 additions & 7 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ func NewClient(token, apiEndpoint string) (runtimeclient.Client, error) {
return NewClientWithTransport(token, apiEndpoint, newTlsVerifySkippingTransport())
}

func NewClientFromRestConfig(config *rest.Config) (runtimeclient.Client, error) {
config.Insecure = true
return newClientFromRestConfig(config)
}

func NewClientWithTransport(token, apiEndpoint string, transport http.RoundTripper) (runtimeclient.Client, error) {
cfg, err := clientcmd.BuildConfigFromFlags(apiEndpoint, "")
if err != nil {
Expand All @@ -78,10 +73,10 @@ func NewClientWithTransport(token, apiEndpoint string, transport http.RoundTripp
cfg.Burst = 50
cfg.Timeout = 60 * time.Second

return newClientFromRestConfig(cfg)
return NewClientFromRestConfig(cfg)
}

func newClientFromRestConfig(cfg *rest.Config) (runtimeclient.Client, error) {
func NewClientFromRestConfig(cfg *rest.Config) (runtimeclient.Client, error) {
if err := AddToScheme(); err != nil {
return nil, err
}
Expand Down
26 changes: 7 additions & 19 deletions pkg/cmd/adm/register_member.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,25 @@ import (
"net/http"
"os"
"os/exec"
"path/filepath"
"strings"
"time"

toolchainv1alpha1 "github.com/codeready-toolchain/api/api/v1alpha1"
"github.com/codeready-toolchain/toolchain-common/pkg/cluster"
"github.com/codeready-toolchain/toolchain-common/pkg/condition"
"github.com/kubesaw/ksctl/pkg/client"
"github.com/kubesaw/ksctl/pkg/cmd/flags"
"github.com/kubesaw/ksctl/pkg/configuration"
clicontext "github.com/kubesaw/ksctl/pkg/context"
"github.com/kubesaw/ksctl/pkg/ioutils"
"github.com/kubesaw/ksctl/pkg/utils"
errs "github.com/pkg/errors"
"github.com/spf13/cobra"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
"k8s.io/client-go/util/homedir"

errs "github.com/pkg/errors"
"github.com/spf13/cobra"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -80,26 +78,16 @@ func NewRegisterMemberCmd() *cobra.Command {
},
}

defaultKubeConfigPath := ""

// first check if KUBECONFIG env variable is set
if kubeconfigPath := os.Getenv("KUBECONFIG"); kubeconfigPath != "" {
defaultKubeConfigPath = kubeconfigPath
} else if home := homedir.HomeDir(); home != "" {
// use home kubeconfig if no KUBECONFIG env var was set
defaultKubeConfigPath = filepath.Join(home, ".kube", "config")
}

// keep these values in sync with the values in defaultRegisterMemberArgs() function in the tests.
defaultHostKubeConfig := defaultKubeConfigPath
defaultMemberKubeConfig := defaultKubeConfigPath
defaultLetsEncrypt := true
defaultNameSuffix := ""
defaultHostNs := "toolchain-host-operator"
defaultMemberNs := "toolchain-member-operator"

cmd.Flags().StringVar(&commandArgs.hostKubeConfig, "host-kubeconfig", defaultKubeConfigPath, fmt.Sprintf("Path to the kubeconfig file of the host cluster (default: '%s')", defaultHostKubeConfig))
cmd.Flags().StringVar(&commandArgs.memberKubeConfig, "member-kubeconfig", defaultMemberKubeConfig, fmt.Sprintf("Path to the kubeconfig file of the member cluster (default: '%s')", defaultMemberKubeConfig))
cmd.Flags().StringVar(&commandArgs.hostKubeConfig, "host-kubeconfig", "", "Path to the kubeconfig file of the host cluster")
flags.MustMarkRequired(cmd, "host-kubeconfig")
cmd.Flags().StringVar(&commandArgs.memberKubeConfig, "member-kubeconfig", "", "Path to the kubeconfig file of the member cluster")
flags.MustMarkRequired(cmd, "member-kubeconfig")
cmd.Flags().BoolVar(&commandArgs.useLetsEncrypt, "lets-encrypt", defaultLetsEncrypt, fmt.Sprintf("Whether to use Let's Encrypt certificates or rely on the cluster certs (default: %t)", defaultLetsEncrypt))
cmd.Flags().StringVar(&commandArgs.nameSuffix, "name-suffix", defaultNameSuffix, fmt.Sprintf("The suffix to append to the member name used when there are multiple members in a single cluster (default: '%s')", defaultNameSuffix))
cmd.Flags().StringVar(&commandArgs.hostNamespace, "host-ns", defaultHostNs, fmt.Sprintf("The namespace of the host operator in the host cluster (default: '%s')", defaultHostNs))
Expand Down

0 comments on commit d0e0da2

Please sign in to comment.