Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ jobs:
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries
runs-on: ${{ matrix.os }}
env:
GOVER: 1.21
GOLANGCILINT_VER: 1.56.2
GOLANGCILINT_VER: 'v2.7.1'
GOOS: ${{ matrix.target_os }}
GOARCH: ${{ matrix.target_arch }}
GOPROXY: https://proxy.golang.org
Expand All @@ -59,22 +58,23 @@ jobs:
- os: windows-latest
target_arch: arm64
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v6
- name: Setup node ${{ env.NODE_VERSION }} and npm
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install angular cli
run: npm install -g @angular/cli
- name: Set up Go ${{ env.GOVER }}
uses: actions/setup-go@v2
- name: Set up Go (using root 'go.mod' version)
uses: actions/setup-go@v6
with:
go-version: ${{ env.GOVER }}
- name: Install golangci-lint
if: matrix.target_arch == 'amd64' && matrix.target_os == 'linux'
run: |
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${{ env.GOROOT }}/bin" v${{ env.GOLANGCILINT_VER }}
- name: Check out code into the Go module directory
uses: actions/checkout@v2
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v9
with:
version: ${{ env.GOLANGCILINT_VER }}
skip-cache: true
- name: Parse release version and set REL_VERSION
run: python ./.github/scripts/get_release_version.py
- name: Run make lint
Expand Down
12 changes: 10 additions & 2 deletions cmd/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,11 @@ func getLogStreamsHandler(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
defer c.Close()
defer func() {
if err := c.Close(); err != nil {
log.Println("websocket close:", err)
}
}()
streams, err := inst.GetLogStream(scope, id, container)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
Expand All @@ -258,7 +262,11 @@ func getLogStreamsHandler(w http.ResponseWriter, r *http.Request) {

var readStreams []io.Reader
for _, stream := range streams {
defer stream.Close()
defer func(s io.Closer) {
if err := s.Close(); err != nil {
log.Println("fail to close stream:", err)
}
}(stream)
readStreams = append(readStreams, stream)
}
reader := io.MultiReader(readStreams...)
Expand Down
276 changes: 138 additions & 138 deletions go.mod

Large diffs are not rendered by default.

656 changes: 303 additions & 353 deletions go.sum

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions pkg/components/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,13 @@ func NewComponents(platform platforms.Platform, daprClient scheme.Interface, com
c := components{}
c.platform = platform

if platform == platforms.Kubernetes {
switch platform {
case platforms.Kubernetes:
c.getComponentsFn = c.getKubernetesComponents
c.daprClient = daprClient
} else if platform == platforms.Standalone {
case platforms.Standalone:
c.getComponentsFn = c.getStandaloneComponents
} else if platform == platforms.DockerCompose {
case platforms.DockerCompose:
c.getComponentsFn = c.getDockerComposeComponents
c.componentsPath = componentsPath
}
Expand Down
7 changes: 4 additions & 3 deletions pkg/configurations/configurations.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,13 @@ func NewConfigurations(platform platforms.Platform, daprClient scheme.Interface,
c := configurations{}
c.platform = platform

if platform == platforms.Kubernetes {
switch platform {
case platforms.Kubernetes:
c.getConfigurationsFn = c.getKubernetesConfigurations
c.daprClient = daprClient
} else if platform == platforms.Standalone {
case platforms.Standalone:
c.getConfigurationsFn = c.getStandaloneConfigurations
} else if platform == platforms.DockerCompose {
case platforms.DockerCompose:
c.getConfigurationsFn = c.getDockerComposeConfigurations
c.configPath = configPath
}
Expand Down
25 changes: 15 additions & 10 deletions pkg/instances/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,15 @@ func NewInstances(platform platforms.Platform, kubeClient *kubernetes.Clientset,
i.metadataClient = http.Client{}
i.daprApiToken = os.Getenv("DAPR_API_TOKEN")

if i.platform == platforms.Kubernetes {
switch i.platform {
case platforms.Kubernetes:
i.getInstancesFn = i.getKubernetesInstances
i.getScopesFn = i.getKubernetesScopes
i.kubeClient = kubeClient
} else if i.platform == platforms.Standalone {
case platforms.Standalone:
i.getInstancesFn = i.getStandaloneInstances
i.getScopesFn = i.getStandaloneScopes
} else if i.platform == platforms.DockerCompose {
case platforms.DockerCompose:
i.getInstancesFn = i.getDockerComposeInstances
i.getScopesFn = i.getDockerComposeScopes
i.dockerComposePath = dockerComposePath
Expand Down Expand Up @@ -214,7 +215,7 @@ func (i *instances) GetLogStream(scope, id, containerName string) ([]io.ReadClos
var logstreams []io.ReadCloser

for _, p := range pods.Items {
name := p.ObjectMeta.Name
name := p.Name

for _, container := range p.Spec.Containers {
if container.Name == containerName {
Expand Down Expand Up @@ -259,7 +260,7 @@ func (i *instances) GetLogStream(scope, id, containerName string) ([]io.ReadClos
var logstreams []io.ReadCloser

for _, p := range pods.Items {
name := p.ObjectMeta.Name
name := p.Name

for _, container := range p.Spec.Containers {
if container.Name == containerName {
Expand Down Expand Up @@ -314,8 +315,8 @@ func (i *instances) GetDeploymentConfiguration(scope string, id string) string {
if len(pods.Items) > 0 {
p := pods.Items[0]

name := p.ObjectMeta.Name
nspace := p.ObjectMeta.Namespace
name := p.Name
nspace := p.Namespace

restClient := i.kubeClient.CoreV1().RESTClient()
if err != nil {
Expand Down Expand Up @@ -372,8 +373,8 @@ func (i *instances) GetDeploymentConfiguration(scope string, id string) string {
if len(pods.Items) > 0 {
p := pods.Items[0]

name := p.ObjectMeta.Name
nspace := p.ObjectMeta.Namespace
name := p.Name
nspace := p.Namespace

restClient := i.kubeClient.CoreV1().RESTClient()
if err != nil {
Expand Down Expand Up @@ -642,7 +643,11 @@ func (i *instances) getMetadataOutputFromURLs(primaryURL string, secondaryURL st
return MetadataOutput{}
}

defer resp.Body.Close()
defer func() {
if err := resp.Body.Close(); err != nil {
log.Println("failed to close response body:", err)
}
}()
body, err := io.ReadAll(resp.Body)
if err != nil {
log.Println(err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/instances/instances_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (

func newTestSimpleK8s(objects ...runtime.Object) instances {
client := instances{}
client.kubeClient = fake.NewSimpleClientset(objects...)
client.kubeClient = fake.NewSimpleClientset(objects...) //nolint:staticcheck
return client
}

Expand Down
Loading
Loading