Skip to content

Commit

Permalink
Merge branch 'main' into dtogetversion
Browse files Browse the repository at this point in the history
  • Loading branch information
rjbrache committed Jul 29, 2024
2 parents a0c90be + e853441 commit c51f2cf
Show file tree
Hide file tree
Showing 20 changed files with 300 additions and 1,369 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
egress-policy: audit

- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: dotenv-linter/action-dotenv-linter@5c7d44c1ddb097d3ae75f6fbb53caf521b23405c # v2.22.0
- uses: dotenv-linter/action-dotenv-linter@9c9a09ba60235ae0b92b2e2ed8f4268ac76d075f # v2.23.0
with:
reporter: github-pr-review

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13
uses: github/codeql-action/init@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -62,7 +62,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13
uses: github/codeql-action/autobuild@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -76,7 +76,7 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13
uses: github/codeql-action/analyze@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15
- name: Generate Security Report
continue-on-error: true
uses: rsdmike/github-security-report-action@544ffd6318f4982cb6fe21197e93bebae5ec217e # v3.0.4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ jobs:

# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13
uses: github/codeql-action/upload-sarif@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15
with:
sarif_file: results.sarif
2 changes: 1 addition & 1 deletion .github/workflows/trivy-scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
vuln-type: "os,library"
severity: "UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL"
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@2d790406f505036ef40ecba973cc774a50395aac # v3.25.13
uses: github/codeql-action/upload-sarif@afb54ba388a7dca6ecae48f608c4ff05ff4cc77a # v3.25.15
if: always()
with:
sarif_file: "trivy-results.sarif"
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Step 1: Modules caching
FROM golang:1.22-alpine3.20@sha256:8c9183f715b0b4eca05b8b3dbf59766aaedb41ec07477b132ee2891ac0110a07 as modules
FROM golang:1.22-alpine3.20@sha256:0d3653dd6f35159ec6e3d10263a42372f6f194c3dea0b35235d72aabde86486e as modules
COPY go.mod go.sum /modules/
WORKDIR /modules
RUN go mod download

# Step 2: Builder
FROM golang:1.22-alpine3.20@sha256:8c9183f715b0b4eca05b8b3dbf59766aaedb41ec07477b132ee2891ac0110a07 as builder
FROM golang:1.22-alpine3.20@sha256:0d3653dd6f35159ec6e3d10263a42372f6f194c3dea0b35235d72aabde86486e as builder
COPY --from=modules /go/pkg /go/pkg
COPY . /app
WORKDIR /app
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/open-amt-cloud-toolkit/go-wsman-messages/v2 v2.11.1
github.com/open-amt-cloud-toolkit/go-wsman-messages/v2 v2.11.2
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJm
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/open-amt-cloud-toolkit/go-wsman-messages/v2 v2.11.1 h1:Q+Yj4E1i+5rzN+9QqXRAP3zX2ggkqrO53IpvkG/DkhA=
github.com/open-amt-cloud-toolkit/go-wsman-messages/v2 v2.11.1/go.mod h1:LyY8fOvYBt5gawHYuivROR7EBySRuSR0u/k8QosnCeU=
github.com/open-amt-cloud-toolkit/go-wsman-messages/v2 v2.11.2 h1:kVIa92FqvorgF3UEK/HO+W/skejllc892aRuYqs68bA=
github.com/open-amt-cloud-toolkit/go-wsman-messages/v2 v2.11.2/go.mod h1:LyY8fOvYBt5gawHYuivROR7EBySRuSR0u/k8QosnCeU=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
Expand Down
15 changes: 15 additions & 0 deletions internal/controller/http/v1/devicemanagement.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func NewAmtRoutes(handler *gin.RouterGroup, d devices.Feature, amt amtexplorer.F
h.DELETE("alarmOccurrences/:guid", r.deleteAlarmOccurrences)

h.GET("hardwareInfo/:guid", r.getHardwareInfo)
h.GET("diskInfo/:guid", r.getDiskInfo)
h.GET("power/state/:guid", r.getPowerState)
h.POST("power/action/:guid", r.powerAction)
h.POST("power/bootOptions/:guid", r.setBootOptions)
Expand Down Expand Up @@ -188,6 +189,20 @@ func (r *deviceManagementRoutes) getHardwareInfo(c *gin.Context) {
c.JSON(http.StatusOK, hwInfo)
}

func (r *deviceManagementRoutes) getDiskInfo(c *gin.Context) {
guid := c.Param("guid")

diskInfo, err := r.d.GetDiskInfo(c.Request.Context(), guid)
if err != nil {
r.l.Error(err, "http - v1 - getHardwareInfo")
ErrorResponse(c, err)

return
}

c.JSON(http.StatusOK, diskInfo)
}

func (r *deviceManagementRoutes) getPowerState(c *gin.Context) {
guid := c.Param("guid")

Expand Down
15 changes: 15 additions & 0 deletions internal/controller/http/v1/devicemanagement_mocks_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions internal/controller/http/v1/devicemanagement_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ func TestDeviceManagement(t *testing.T) {
expectedCode: http.StatusOK,
response: map[string]interface{}{"hardware": "info"},
},
{
name: "getDiskInfo - successful retrieval",
url: "/api/v1/amt/diskInfo/valid-guid",
method: http.MethodGet,
mock: func(m *MockDeviceManagementFeature) {
m.EXPECT().GetDiskInfo(context.Background(), "valid-guid").
Return(map[string]interface{}{"disk": "info"}, nil)
},
expectedCode: http.StatusOK,
response: map[string]interface{}{"disk": "info"},
},
{
name: "getPowerState - successful retrieval",
url: "/api/v1/amt/power/state/valid-guid",
Expand Down
15 changes: 15 additions & 0 deletions internal/controller/http/v1/wsman_mocks_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c51f2cf

Please sign in to comment.