Skip to content

Commit 5dac482

Browse files
committed
merge master
2 parents 8fe1ddf + bf6c48e commit 5dac482

File tree

11 files changed

+152
-26
lines changed

11 files changed

+152
-26
lines changed

.golangci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
run:
2+
timeout: 15m
3+
tests: false # Exclude test files from linting
4+
5+
# Linter options and descriptions: https://golangci-lint.run/usage/linters/
6+
linters:
7+
enable:
8+
- errcheck
9+
- govet
10+
- ineffassign
11+
- staticcheck
12+
disable:
13+
# Disabling these two default linters for now as their checks are not a priority
14+
- gosimple
15+
- unused
16+
17+
linters-settings:
18+
staticcheck:
19+
checks:
20+
- all
21+
- -SA1019 # Ignore pkg deprecation warnings from staticcheck

.pipelines/build.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,46 @@ jobs:
7070
BuildDropPath: $(System.DefaultWorkingDirectory)/manifest
7171
- publish: $(System.DefaultWorkingDirectory)/manifest
7272
artifact: manifest
73+
74+
- job: Lint
75+
displayName: 'Lint'
76+
77+
pool:
78+
vmImage: 'ubuntu-latest'
79+
80+
variables:
81+
- group: moc-build
82+
- name: GO111MODULE
83+
value: 'on'
84+
85+
steps:
86+
- task: GoTool@0
87+
inputs:
88+
version: '1.22.5'
89+
90+
- task: InstallSSHKey@0
91+
inputs:
92+
knownHostsEntry: |
93+
$(KNOWN_HOST_GITHUB)
94+
$(KNOWN_HOST_GITHUB_ECDSA)
95+
$(KNOWN_HOST_GITHUB_Ed25519)
96+
sshPublicKey: '$(SSH_PUBLIC_KEY)'
97+
sshKeySecureFile: 'azure-pipelines-ssh-key-new'
98+
99+
- task: AzureCLI@2
100+
inputs:
101+
azureSubscription: 'kva-azuredevops-gcm'
102+
scriptType: 'bash'
103+
scriptLocation: 'inlineScript'
104+
inlineScript: |
105+
# Obtain Azure DevOps access token
106+
aadToken=$(az account get-access-token --query accessToken --resource 499b84ac-1321-427f-aa17-267ca6975798 -o tsv)
107+
# Set git configuration for authentication
108+
git config --global http.extraheader "AUTHORIZATION: bearer $aadToken"
109+
git config --global url."ssh://git@github.com/".insteadOf "https://github.com/"
110+
displayName: 'Set git config'
111+
112+
- script: |
113+
make golangci-lint
114+
displayName: 'Run GolangCI-Lint'
115+
workingDirectory: '$(System.DefaultWorkingDirectory)'

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
GOCMD=go
44
GOBUILD=$(GOCMD) build -v #-mod=vendor
55
GOHOSTOS=$(strip $(shell $(GOCMD) env get GOHOSTOS))
6+
GOPATH_BIN := $(shell go env GOPATH)/bin
67
GOTEST=GOOS=$(GOHOSTOS) $(GOCMD) test -v -coverprofile=coverage.out -covermode count -timeout 60m0s
78
TESTDIRECTORIES= ./services/compute/virtualmachine/internal ./services/security/keyvault/key/internal
89

@@ -36,4 +37,10 @@ build:
3637
GOARCH=amd64 go build -v ./...
3738

3839
unittest:
39-
$(GOTEST) $(TESTDIRECTORIES)
40+
$(GOTEST) $(TESTDIRECTORIES)
41+
42+
golangci-lint:
43+
$(GOCMD) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
44+
$(GOPATH_BIN)/golangci-lint run --config .golangci.yml
45+
46+

go.mod

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@ module github.com/microsoft/wssd-sdk-for-go
22

33
go 1.22.4
44

5-
toolchain go1.22.7
6-
75
require (
86
code.cloudfoundry.org/bytefmt v0.0.0-20200131002437-cf55d5288a48
97
github.com/golang/protobuf v1.5.4
108
github.com/google/go-cmp v0.6.0
11-
github.com/microsoft/moc v0.25.3
9+
github.com/microsoft/moc v0.25.4
1210
github.com/spf13/viper v1.15.0
1311
github.com/stretchr/testify v1.9.0
1412
go.opencensus.io v0.24.0
1513
google.golang.org/grpc v1.60.1
16-
google.golang.org/protobuf v1.36.0
14+
google.golang.org/protobuf v1.36.2
1715
k8s.io/klog v1.0.0
1816
)
1917

@@ -38,10 +36,10 @@ require (
3836
github.com/spf13/pflag v1.0.5 // indirect
3937
github.com/subosito/gotenv v1.4.2 // indirect
4038
go.uber.org/multierr v1.11.0 // indirect
41-
golang.org/x/net v0.33.0 // indirect
42-
golang.org/x/sys v0.28.0 // indirect
39+
golang.org/x/net v0.34.0 // indirect
40+
golang.org/x/sys v0.29.0 // indirect
4341
golang.org/x/text v0.21.0 // indirect
44-
google.golang.org/genproto/googleapis/rpc v0.0.0-20241219184827-bd154493cd20 // indirect
42+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250106144421-5f5ef82da422 // indirect
4543
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
4644
gopkg.in/ini.v1 v1.67.0 // indirect
4745
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
162162
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
163163
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
164164
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
165-
github.com/microsoft/moc v0.25.3 h1:px6a7dK3ICzCJmAthFgexvNYcPDoylSpDImF0ceQxiE=
166-
github.com/microsoft/moc v0.25.3/go.mod h1:BcebmEU4OhkNl6j/3C5VjpArTU0uyd4f1RmxiCpioKk=
165+
github.com/microsoft/moc v0.25.4 h1:J6Rpa0TSQbH1QDTtoveEVhQ9KHevgsty0r4tQ1QdVdc=
166+
github.com/microsoft/moc v0.25.4/go.mod h1:PwmwdbVF3n8fnCJloNgyck+/XvgPjqdXMTrzNzkH+u0=
167167
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
168168
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
169169
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
@@ -304,8 +304,8 @@ golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v
304304
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
305305
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
306306
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
307-
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
308-
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
307+
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
308+
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
309309
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
310310
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
311311
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@@ -454,8 +454,8 @@ google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6D
454454
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
455455
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
456456
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
457-
google.golang.org/genproto/googleapis/rpc v0.0.0-20241219184827-bd154493cd20 h1:aiR3J9AR6kgxKXDbsWpnjcNbN8dsYMAw6IJVl40rzX8=
458-
google.golang.org/genproto/googleapis/rpc v0.0.0-20241219184827-bd154493cd20/go.mod h1:lcTa1sDdWEIHMWlITnIczmw5w60CF9ffkb8Z+DVmmjA=
457+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250106144421-5f5ef82da422 h1:3UsHvIr4Wc2aW4brOaSCmcxh9ksica6fHEr8P1XhkYw=
458+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250106144421-5f5ef82da422/go.mod h1:3ENsm/5D1mzDyhpzeRi1NR784I0BcofWBoSc5QqqMK4=
459459
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
460460
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
461461
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
@@ -486,8 +486,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj
486486
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
487487
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
488488
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
489-
google.golang.org/protobuf v1.36.0 h1:mjIs9gYtt56AzC4ZaffQuh88TZurBGhIJMBZGSxNerQ=
490-
google.golang.org/protobuf v1.36.0/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
489+
google.golang.org/protobuf v1.36.2 h1:R8FeyR1/eLmkutZOM5CWghmo5itiG9z0ktFlTVLuTmU=
490+
google.golang.org/protobuf v1.36.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE=
491491
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
492492
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
493493
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=

services/admin/logging/internal/wssd.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ func (c *client) ForwardLogFile(ctx context.Context, forwardFunc func([]byte, er
4646

4747
}
4848
return loggingHelpers.Forward(ctx, forwardFunc, recFunc)
49-
50-
return nil
5149
}
5250

5351
// Get

services/compute/virtualmachine/internal/virtualmachine.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ func (c *client) getVirtualMachineLinuxConfiguration(linuxConfiguration *wssdcom
747747
}
748748

749749
func (c *client) getVirtualMachineOSProfile(o *wssdcompute.OperatingSystemConfiguration) *compute.OSProfile {
750-
osBootstrapEngine := compute.CloudInit
750+
var osBootstrapEngine compute.OperatingSystemBootstrapEngine
751751
switch o.OsBootstrapEngine {
752752
case wssdcommonproto.OperatingSystemBootstrapEngine_WINDOWS_ANSWER_FILES:
753753
osBootstrapEngine = compute.WindowsAnswerFiles

services/compute/virtualmachinescaleset/internal/wssd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ func (c *client) getVirtualMachineLinuxConfiguration(linuxConfiguration *wssdcom
373373
}
374374

375375
func (c *client) getVirtualMachineScaleSetOSProfile(o *wssdcompute.OperatingSystemConfiguration) *compute.OSProfile {
376-
osBootstrapEngine := compute.CloudInit
376+
var osBootstrapEngine compute.OperatingSystemBootstrapEngine
377377
switch o.OsBootstrapEngine {
378378
case wssdcommonproto.OperatingSystemBootstrapEngine_WINDOWS_ANSWER_FILES:
379379
osBootstrapEngine = compute.WindowsAnswerFiles
@@ -656,7 +656,7 @@ func (c *client) getWssdVirtualMachineScaleSetOSConfiguration(s *compute.OSProfi
656656
adminuser.Password = *s.AdminPassword
657657
}
658658

659-
osBootstrapEngine := wssdcommonproto.OperatingSystemBootstrapEngine_CLOUD_INIT
659+
var osBootstrapEngine wssdcommonproto.OperatingSystemBootstrapEngine
660660
switch s.OsBootstrapEngine {
661661
case compute.WindowsAnswerFiles:
662662
osBootstrapEngine = wssdcommonproto.OperatingSystemBootstrapEngine_WINDOWS_ANSWER_FILES

services/security/certificate/internal/wssd.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,9 @@ func getWssdCSR(csr *security.CertificateRequest) (*wssdsecurity.CertificateSign
226226
var csrRequest []byte
227227
var err error
228228
if csr.PrivateKey != nil {
229-
pemKey, err := marshal.FromBase64(*csr.PrivateKey)
230-
if err != nil {
231-
return nil, "", err
229+
pemKey, marshalErr := marshal.FromBase64(*csr.PrivateKey)
230+
if marshalErr != nil {
231+
return nil, "", marshalErr
232232
}
233233
csrRequest, key, err = certs.GenerateCertificateRequest(&conf, pemKey)
234234
} else {

services/storage/virtualharddisk/client.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type Service interface {
1717
CreateOrUpdate(context.Context, string, string, *storage.VirtualHardDisk) (*storage.VirtualHardDisk, error)
1818
Delete(context.Context, string, string) error
1919
Hydrate(context.Context, string, string, *storage.VirtualHardDisk) (*storage.VirtualHardDisk, error)
20+
Upload(context.Context, string, string, string) error
2021
}
2122

2223
// Client structure
@@ -56,3 +57,8 @@ func (c *VirtualHardDiskClient) Delete(ctx context.Context, container, name stri
5657
func (c *VirtualHardDiskClient) Hydrate(ctx context.Context, container, name string, vhdDef *storage.VirtualHardDisk) (*storage.VirtualHardDisk, error) {
5758
return c.internal.Hydrate(ctx, container, name, vhdDef)
5859
}
60+
61+
// CreateOrUpdate methods invokes create or update on the client
62+
func (c *VirtualHardDiskClient) Upload(ctx context.Context, container, name string, targeturl string) error {
63+
return c.internal.Upload(ctx, container, name, targeturl)
64+
}

0 commit comments

Comments
 (0)