Skip to content

Commit

Permalink
nit: improved method name
Browse files Browse the repository at this point in the history
Signed-off-by: Mritunjay <mritunjaysharma394@gmail.com>
  • Loading branch information
mritunjaysharma394 committed May 22, 2023
1 parent 801188a commit 9ecd81c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions docs/modules/k3s.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ Please read the [Create containers: Advanced Settings](../features/creating_cont

The K3s container exposes the following methods:

#### GetkubeConfigYaml
#### GetKubeConfig

GetkubeConfigYaml returns modified kubeconfig with server url that should be used for connecting
GetKubeConfig returns modified kubeconfig with server url that should be used for connecting
to the Kubernetes Rest Client API with your Kubernetes client. It'll be returned in the format:
`[]bytes`

<!--codeinclude-->
[Get Kubeconifg Yaml](../../modules/k3s/k3s_test.go) inside_block:getkubeConfigYaml
[Get KubeConifg](../../modules/k3s/k3s_test.go) inside_block:GetKubeConfig
<!--/codeinclude-->
10 changes: 5 additions & 5 deletions modules/k3s/k3s.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ func RunContainer(ctx context.Context, opts ...testcontainers.ContainerCustomize
return &K3sContainer{Container: container}, nil
}

// GetkubeConfigYaml returns the modified kubeconfig with server url
func (c *K3sContainer) GetkubeConfigYaml(ctx context.Context) ([]byte, error) {
// GetKubeConfig returns the modified kubeconfig with server url
func (c *K3sContainer) GetKubeConfig(ctx context.Context) ([]byte, error) {
hostIP, err := c.Host(ctx)
if err != nil {
return nil, fmt.Errorf("failed to get hostIP: %w", err)
Expand All @@ -93,15 +93,15 @@ func (c *K3sContainer) GetkubeConfigYaml(ctx context.Context) ([]byte, error) {
}

server := "https://" + fmt.Sprintf("%v:%d", hostIP, mappedPort.Int())
newkubeConfigYaml, err := kubeConfigYamlwithServer(string(kubeConfigYaml), server)
newKubeConfig, err := kubeConfigWithServerUrl(string(kubeConfigYaml), server)
if err != nil {
return nil, fmt.Errorf("failed to modify kubeconfig with server url: %w", err)
}

return newkubeConfigYaml, nil
return newKubeConfig, nil
}

func kubeConfigYamlwithServer(kubeConfigYaml, server string) ([]byte, error) {
func kubeConfigWithServerUrl(kubeConfigYaml, server string) ([]byte, error) {

kubeConfig, err := unmarshal([]byte(kubeConfigYaml))
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions modules/k3s/k3s_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ func TestK3s(t *testing.T) {
}
})

// getkubeConfigYaml {
kubeConfigYaml, err := container.GetkubeConfigYaml(ctx)
// GetKubeConfig {
kubeConfigYaml, err := container.GetKubeConfig(ctx)
if err != nil {
t.Fatalf("failed to get kube-config : %s", err)
}
Expand Down

0 comments on commit 9ecd81c

Please sign in to comment.