mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
Change check-lint to use golangci-lint (#3465)
golint is deprecated. The author of the code no longer supports the codebase. golangci-lint is faster than golint, and is in use by other opa repositories (e.g. Gatekeeper). This commit changes tools.go to reference golangci (so it ends up in vendor) and modifies check-lint to use golangci instead. Breaking API Changes: - plugins/rest/rest.go: Fix typo "AllowInsureTLS" -> "AllowInsecureTLS" - storage/errors.go: Removed unused IndexingNotSupportedErr Signed-off-by: Will Beason <willbeason@google.com>
This commit is contained in:
+6
-5
@@ -92,7 +92,7 @@ func (c *Compiler) WithAsBundle(enabled bool) *Compiler {
|
||||
}
|
||||
|
||||
// WithEntrypoints sets the policy entrypoints on the compiler. Entrypoints tell the
|
||||
// compiler what rules to expect and where optimizations can be targetted. The wasm
|
||||
// compiler what rules to expect and where optimizations can be targeted. The wasm
|
||||
// target requires at least one entrypoint as does optimization.
|
||||
func (c *Compiler) WithEntrypoints(e ...string) *Compiler {
|
||||
c.entrypoints = c.entrypoints.Append(e...)
|
||||
@@ -446,7 +446,10 @@ func (c *Compiler) compileWasm(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// dump policy IR (if "debug" wasn't requested, debug.Witer will discard it)
|
||||
ir.Pretty(c.debug.Writer(), policy)
|
||||
err = ir.Pretty(c.debug.Writer(), policy)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Compile the policy into a wasm binary.
|
||||
m, err := compiler.WithPolicy(policy).WithDebug(c.debug.Writer()).Compile()
|
||||
@@ -533,9 +536,7 @@ func pruneBundleEntrypoints(b *bundle.Bundle, entrypointrefs []*ast.Term) error
|
||||
pkgPath := mf.Parsed.Package.Path.String()
|
||||
if imports, ok := requiredImports[pkgPath]; ok {
|
||||
mf.Raw = nil
|
||||
for _, newImport := range imports {
|
||||
mf.Parsed.Imports = append(mf.Parsed.Imports, newImport)
|
||||
}
|
||||
mf.Parsed.Imports = append(mf.Parsed.Imports, imports...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ func TestCompilerInputBundle(t *testing.T) {
|
||||
|
||||
b := &bundle.Bundle{
|
||||
Modules: []bundle.ModuleFile{
|
||||
bundle.ModuleFile{
|
||||
{
|
||||
URL: "/foo.rego",
|
||||
Path: "/foo.rego",
|
||||
Raw: []byte("package test\np = 7"),
|
||||
@@ -274,13 +274,13 @@ func TestCompilerInputInvalidBundle(t *testing.T) {
|
||||
|
||||
b := &bundle.Bundle{
|
||||
Modules: []bundle.ModuleFile{
|
||||
bundle.ModuleFile{
|
||||
{
|
||||
URL: "/url",
|
||||
Path: "/foo.rego",
|
||||
Raw: []byte("package test\np = 0"),
|
||||
Parsed: ast.MustParseModule("package test\np = 0"),
|
||||
},
|
||||
bundle.ModuleFile{
|
||||
{
|
||||
URL: "/url",
|
||||
Path: "/bar.rego",
|
||||
Raw: []byte("package test\nq = 1"),
|
||||
@@ -360,12 +360,15 @@ func TestCompilerOptimizationL1(t *testing.T) {
|
||||
// here. If this becomes a common pattern, we could refactor (e.g.,
|
||||
// allow caller to control var prefix, split into a reusable function,
|
||||
// etc.)
|
||||
ast.TransformVars(optimizedExp, func(x ast.Var) (ast.Value, error) {
|
||||
_, err = ast.TransformVars(optimizedExp, func(x ast.Var) (ast.Value, error) {
|
||||
if x == ast.Var("X") {
|
||||
return ast.Var("$_term_1_01"), nil
|
||||
}
|
||||
return x, nil
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if len(compiler.bundle.Modules) != 1 {
|
||||
t.Fatalf("expected 1 module but got: %v", compiler.bundle.Modules)
|
||||
@@ -494,8 +497,8 @@ func TestCompilerWasmTargetWithCapabilitiesMismatch(t *testing.T) {
|
||||
test.WithTempFS(files, func(root string) {
|
||||
|
||||
for note, wabis := range map[string][]ast.WasmABIVersion{
|
||||
"none": []ast.WasmABIVersion{},
|
||||
"mismatch": []ast.WasmABIVersion{{Version: 0}, {Version: 1, Minor: 2}},
|
||||
"none": {},
|
||||
"mismatch": {{Version: 0}, {Version: 1, Minor: 2}},
|
||||
} {
|
||||
t.Run(note, func(t *testing.T) {
|
||||
caps := ast.CapabilitiesForThisVersion()
|
||||
|
||||
Reference in New Issue
Block a user