Skip to content

Commit cb41b99

Browse files
committed
Remove unused function and add nolint where it's wrong
Signed-off-by: Tingmao Wang <[email protected]>
1 parent f1b3bcf commit cb41b99

File tree

3 files changed

+4
-22
lines changed

3 files changed

+4
-22
lines changed

pkg/securitypolicy/securitypolicy_linux.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const osType = "linux"
2424
// substituteUVMPath substitutes mount prefix to an appropriate path inside
2525
// UVM. At policy generation time, it's impossible to tell what the sandboxID
2626
// will be, so the prefix substitution needs to happen during runtime.
27+
//
28+
//nolint:unused // linting is wrong, this is used in rego_utils_test.go
2729
func substituteUVMPath(sandboxID string, m mountInternal) mountInternal {
2830
if strings.HasPrefix(m.Source, guestpath.SandboxMountPrefix) {
2931
m.Source = specInternal.SandboxMountSource(sandboxID, m.Source)

pkg/securitypolicy/securitypolicy_windows.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ const osType = "windows"
1212
// substituteUVMPath substitutes mount prefix to an appropriate path inside
1313
// UVM. At policy generation time, it's impossible to tell what the sandboxID
1414
// will be, so the prefix substitution needs to happen during runtime.
15+
//
16+
//nolint:unused // linting is wrong, this is used in rego_utils_test.go
1517
func substituteUVMPath(sandboxID string, m mountInternal) mountInternal {
1618
//no-op for windows
1719
_ = sandboxID

pkg/securitypolicy/securitypolicyenforcer.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package securitypolicy
22

33
import (
44
"context"
5-
"encoding/base64"
6-
"encoding/json"
75
"fmt"
86
"syscall"
97

@@ -144,26 +142,6 @@ func (s stringSet) contains(item string) bool {
144142
return contains
145143
}
146144

147-
func newSecurityPolicyFromBase64JSON(base64EncodedPolicy string) (*SecurityPolicy, error) {
148-
// base64 decode the incoming policy string
149-
// its base64 encoded because it is coming from an annotation
150-
// annotations are a map of string to string
151-
// we want to store a complex json object so.... base64 it is
152-
jsonPolicy, err := base64.StdEncoding.DecodeString(base64EncodedPolicy)
153-
if err != nil {
154-
return nil, errors.Wrap(err, "unable to decode policy from Base64 format")
155-
}
156-
157-
// json unmarshall the decoded to a SecurityPolicy
158-
securityPolicy := new(SecurityPolicy)
159-
err = json.Unmarshal(jsonPolicy, securityPolicy)
160-
if err != nil {
161-
return nil, errors.Wrap(err, "unable to unmarshal JSON policy")
162-
}
163-
164-
return securityPolicy, nil
165-
}
166-
167145
// CreateSecurityPolicyEnforcer returns an appropriate enforcer for input
168146
// parameters. Returns an error if the requested `enforcer` implementation
169147
// isn't registered.

0 commit comments

Comments
 (0)