Skip to content

Commit

Permalink
chore: gofmt fix and enable in CI (k8sgpt-ai#414)
Browse files Browse the repository at this point in the history
* gofmt the files

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>

* add UT and goFMT to PR Gate (Github Action for PR)

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>

---------

Signed-off-by: Peter Pan <Peter.Pan@daocloud.io>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
  • Loading branch information
panpan0000 and AlexsJones authored May 15, 2023
1 parent aafe669 commit e66de8c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}

- name: Test
run: go test -v ./...
- name: Unit Test
run: make test

- name: Fmt Test
run: fmtFiles=$(make fmt); if [ "$fmtFiles" != "" ];then exit 1; fi

2 changes: 1 addition & 1 deletion pkg/ai/noopai.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (a *NoOpAIClient) Parse(ctx context.Context, prompt []string, cache cache.I
return "", err
}

err = cache.Store(cacheKey, base64.StdEncoding.EncodeToString([]byte(response)))
err = cache.Store(cacheKey, base64.StdEncoding.EncodeToString([]byte(response)))

if err != nil {
color.Red("error storing value to cache: %v", err)
Expand Down
28 changes: 14 additions & 14 deletions pkg/analyzer/hpaAnalyzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ func TestHPAAnalyzerWithExistingScaleTargetRefAsDeployment(t *testing.T) {
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "example",
Name: "example",
Image: "nginx",
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
"cpu": resource.MustParse("100m"),
"cpu": resource.MustParse("100m"),
"memory": resource.MustParse("128Mi"),
},
Limits: corev1.ResourceList{
"cpu": resource.MustParse("200m"),
"cpu": resource.MustParse("200m"),
"memory": resource.MustParse("256Mi"),
},
},
Expand Down Expand Up @@ -269,15 +269,15 @@ func TestHPAAnalyzerWithExistingScaleTargetRefAsReplicationController(t *testing
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "example",
Name: "example",
Image: "nginx",
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
"cpu": resource.MustParse("100m"),
"cpu": resource.MustParse("100m"),
"memory": resource.MustParse("128Mi"),
},
Limits: corev1.ResourceList{
"cpu": resource.MustParse("200m"),
"cpu": resource.MustParse("200m"),
"memory": resource.MustParse("256Mi"),
},
},
Expand Down Expand Up @@ -333,15 +333,15 @@ func TestHPAAnalyzerWithExistingScaleTargetRefAsReplicaSet(t *testing.T) {
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "example",
Name: "example",
Image: "nginx",
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
"cpu": resource.MustParse("100m"),
"cpu": resource.MustParse("100m"),
"memory": resource.MustParse("128Mi"),
},
Limits: corev1.ResourceList{
"cpu": resource.MustParse("200m"),
"cpu": resource.MustParse("200m"),
"memory": resource.MustParse("256Mi"),
},
},
Expand Down Expand Up @@ -397,15 +397,15 @@ func TestHPAAnalyzerWithExistingScaleTargetRefAsStatefulSet(t *testing.T) {
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "example",
Name: "example",
Image: "nginx",
Resources: corev1.ResourceRequirements{
Requests: corev1.ResourceList{
"cpu": resource.MustParse("100m"),
"cpu": resource.MustParse("100m"),
"memory": resource.MustParse("128Mi"),
},
Limits: corev1.ResourceList{
"cpu": resource.MustParse("200m"),
"cpu": resource.MustParse("200m"),
"memory": resource.MustParse("256Mi"),
},
},
Expand Down Expand Up @@ -461,7 +461,7 @@ func TestHPAAnalyzerWithExistingScaleTargetRefWithoutSpecifyingResources(t *test
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "example",
Name: "example",
Image: "nginx",
},
},
Expand All @@ -487,7 +487,7 @@ func TestHPAAnalyzerWithExistingScaleTargetRefWithoutSpecifyingResources(t *test
var errorFound bool
for _, analysis := range analysisResults {
for _, err := range analysis.Error {
if strings.Contains(err.Text, "does not have resource configured."){
if strings.Contains(err.Text, "does not have resource configured.") {
errorFound = true
break
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/analyzer/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (NodeAnalyzer) Analyze(a common.Analyzer) ([]common.Result, error) {
}

if len(failures) > 0 {
preAnalysis[node.Name]= common.PreAnalysis{
preAnalysis[node.Name] = common.PreAnalysis{
Node: node,
FailureDetails: failures,
}
Expand Down

0 comments on commit e66de8c

Please sign in to comment.