Skip to content

Commit

Permalink
Merge github.com:np-guard/netpol-analyzer into support_admin_netpolicy
Browse files Browse the repository at this point in the history
  • Loading branch information
shireenf-ibm committed Jun 13, 2024
2 parents cc14430 + 3a1326a commit bb14609
Show file tree
Hide file tree
Showing 63 changed files with 372 additions and 213 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@cdcdbb579706841c47f7063dda365e292e5cad7a
uses: github/codeql-action/init@f079b8493333aace61c81488f8bd40919487bd9f
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -56,7 +56,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@cdcdbb579706841c47f7063dda365e292e5cad7a
uses: github/codeql-action/autobuild@f079b8493333aace61c81488f8bd40919487bd9f

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

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@cdcdbb579706841c47f7063dda365e292e5cad7a
uses: github/codeql-action/analyze@f079b8493333aace61c81488f8bd40919487bd9f
4 changes: 2 additions & 2 deletions .github/workflows/go-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29

- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
with:
go-version-file: ./go.mod

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ jobs:
name: golangci-lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29
- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
with:
go-version-file: ./go.mod
cache: false
- uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804
- uses: golangci/golangci-lint-action@a4f60bb28d35aeee14e6880718e0c85ff1882e64
with:
version: latest
4 changes: 2 additions & 2 deletions .github/workflows/make-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29

- name: Set up Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7
with:
go-version-file: ./go.mod

Expand Down
35 changes: 22 additions & 13 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ linters-settings:
lines: 100
statements: 50
gci:
local-prefixes: github.com/np-guard
prefix: github.com/np-guard
goconst:
min-len: 2
min-occurrences: 2
Expand All @@ -18,18 +18,24 @@ linters-settings:
- style
gocyclo:
min-complexity: 15
goheader:
values:
const:
COMPANY: IBM Inc.
template: |-
Copyright 2023- {{ COMPANY }} All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
goimports:
local-prefixes: github.com/np-guard
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: argument,case,condition,return
ignored-numbers: 0,1,2,3
ignored-functions: strings.SplitN
mnd:
# don't include the "operation" and "assign"
checks: argument,case,condition,return
ignored-numbers: 0,1,2,3
ignored-functions: strings.SplitN

govet:
check-shadowing: true
shadow: true
lll:
line-length: 140
misspell:
Expand Down Expand Up @@ -70,6 +76,7 @@ linters:
- dupl
- durationcheck
- errcheck
- errname
- errorlint
- exportloopref
- funlen
Expand All @@ -79,8 +86,9 @@ linters:
- gocritic
- gocyclo
- gofmt
- goheader
- goimports
- gomnd
- mnd
- gomoddirectives
- goprintffuncname
- gosec
Expand Down Expand Up @@ -108,7 +116,6 @@ linters:
- tagliatelle
- tenv
- testableexamples
- tparallel
- typecheck
- unconvert
- unparam
Expand All @@ -124,7 +131,9 @@ issues:
- revive
- goconst
- funlen
- errcheck


run:
timeout: 5m

output:
print-issued-lines: false
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
REPOSITORY := github.com/np-guard/netpol-analyzer
EXE:=k8snetpolicy
COVERAGE:=netpolicy.coverprofile

mod: go.mod
@echo -- $@ --
Expand All @@ -23,10 +24,10 @@ build:

test:
@echo -- $@ --
go test ./... -v -cover -coverprofile netpolicy.coverprofile
go test ./... -v -coverpkg=./... -coverprofile $(COVERAGE)

coverage:
go tool cover -html="netpolicy.coverprofile"
go tool cover -html="$(COVERAGE)"

test-update: # overrides/ generates tests' expected output files for relevant tests
# if the format is dot - generates also png files
Expand Down
19 changes: 6 additions & 13 deletions cmd/netpolicy/main.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2022
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package main

import (
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.21

require (
github.com/hashicorp/golang-lru/v2 v2.0.7
github.com/np-guard/models v0.3.1
github.com/np-guard/models v0.3.2
github.com/openshift/api v0.0.0-20230502160752-c71432710382
github.com/spf13/cobra v1.8.0
github.com/stretchr/testify v1.9.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 h1:n6/
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00/go.mod h1:Pm3mSP3c5uWn86xMLZ5Sa7JB9GsEZySvHYXCTK4E9q4=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/np-guard/models v0.3.1 h1:U4z/IVW8gf7e3rgodLkFb36D/MmHGVmJWWFnrq5dJyc=
github.com/np-guard/models v0.3.1/go.mod h1:mqE2Irf8r+7HWh8fII0fWbWyQRMHGEo2SgSLN/6VKs8=
github.com/np-guard/models v0.3.2 h1:f9/PuxQD63BE/Ih5j4AXEzv6rkpmu1UfSvr/XHGmnDE=
github.com/np-guard/models v0.3.2/go.mod h1:mqE2Irf8r+7HWh8fII0fWbWyQRMHGEo2SgSLN/6VKs8=
github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4=
github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o=
github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg=
Expand Down
6 changes: 6 additions & 0 deletions pkg/cli/command_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package cli

import (
Expand Down
19 changes: 6 additions & 13 deletions pkg/cli/diff.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2022
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package cli

import (
Expand Down
19 changes: 6 additions & 13 deletions pkg/cli/evaluate.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2022
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package cli

import (
Expand Down
19 changes: 6 additions & 13 deletions pkg/cli/list.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2022
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package cli

import (
Expand Down
19 changes: 6 additions & 13 deletions pkg/cli/root.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
// Copyright 2022
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package cli

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/internal/netpolerrors/netpol_errors.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package netpolerrors

import "fmt"
Expand Down
6 changes: 6 additions & 0 deletions pkg/internal/output/output.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package output

import "os"
Expand Down
6 changes: 6 additions & 0 deletions pkg/internal/projectpath/projectpath.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package projectpath

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/internal/testutils/testutils.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package testutils

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/logger/logger.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package logger

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/manifests/fsscanner/manifests.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package fsscanner

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/manifests/fsscanner/manifests_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package fsscanner

import (
Expand Down
6 changes: 6 additions & 0 deletions pkg/manifests/parser/error_types.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright 2023- IBM Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package parser

import (
Expand Down
Loading

0 comments on commit bb14609

Please sign in to comment.