Skip to content

Commit

Permalink
fix: interview revision
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <csatib02@gmail.com>
  • Loading branch information
csatib02 committed Sep 8, 2024
1 parent 61f7a55 commit 6928c03
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
19 changes: 12 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ fmt: ## Format code

##@ Dependencies

deps: bin/golangci-lint bin/kind
deps: ## Install dependencies

# Dependency versions
GOLANGCI_LINT_VERSION = 1.60.3
KIND_VERSION = 0.24.0
Expand All @@ -101,16 +98,24 @@ GOLANGCI_LINT_BIN := golangci-lint
KIND_BIN := kind
HELM_BIN := helm

bin/golangci-lint:
deps: bin/golangci-lint-${GOLANGCI_LINT_VERSION} bin/kind-${KIND_VERSION} bin/helm
deps: ## Install dependencies
@ln -sf golangci-lint-${GOLANGCI_LINT_VERSION} bin/golangci-lint
@ln -sf kind-${KIND_VERSION} bin/kind

bin/golangci-lint-${GOLANGCI_LINT_VERSION}:
@mkdir -p bin
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- v${GOLANGCI_LINT_VERSION}
@mv bin/golangci-lint $@

bin/kind:
bin/kind-${KIND_VERSION}:
@mkdir -p bin
curl -Lo bin/kind https://kind.sigs.k8s.io/dl/v${KIND_VERSION}/kind-$(shell uname -s | tr '[:upper:]' '[:lower:]')-$(shell uname -m | sed -e "s/aarch64/arm64/; s/x86_64/amd64/")
@chmod +x bin/kind
@mv bin/kind $@
@chmod +x $@

bin/helm:
@mkdir -p bin
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | USE_SUDO=false HELM_INSTALL_DIR=bin bash
@chmod +x bin/helm
@mv bin/helm $@
@chmod +x $@
7 changes: 5 additions & 2 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ type Config struct {
Mode string `mapstructure:"mode"`
LogLevel string `mapstructure:"log_level"`
JSONLog bool `mapstructure:"json_log"`
LogServerAddress string `mapstructure:"log_server"`
LogServerAddress string `mapstructure:"log_server_address"`
LogServerNetwork string `mapstructure:"log_server_network"`
}

func LoadConfig() (*Config, error) {
Expand All @@ -47,7 +48,9 @@ func LoadConfig() (*Config, error) {

_ = v.BindEnv("json_log")

_ = v.BindEnv("log_server")
_ = v.BindEnv("log_server_address")

_ = v.BindEnv("log_server_network")

config := &Config{}
if err := v.Unmarshal(config); err != nil {
Expand Down
8 changes: 4 additions & 4 deletions internal/k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ func NewClient() (*Client, error) {
return &Client{clientset: clientset}, nil
}

func (c *Client) ListResource(ctx context.Context, resource common.Resources) (common.Resources, error) {
switch resource.(type) {
case common.ResourceType:
func (c *Client) ListResource(ctx context.Context, resource common.ResourceType) (common.Resources, error) {
switch resource {
case common.PodResourceType:
return c.listPods(ctx)
default:
return nil, fmt.Errorf("unsupported resource type: %T", resource)
return nil, fmt.Errorf("unsupported resource type: %s", resource)
}
}

Expand Down
2 changes: 1 addition & 1 deletion internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func New(config *config.Config) (*Server, error) {
gin.SetMode(config.Mode)

if config.LogServerAddress != "" {
writer, err := net.Dial("udp", config.LogServerAddress)
writer, err := net.Dial(config.LogServerNetwork, config.LogServerAddress)
if err != nil {
return nil, fmt.Errorf("failed to connect to log server: %w", err)
}
Expand Down

0 comments on commit 6928c03

Please sign in to comment.