Skip to content

Commit

Permalink
Fix the formatting of the files and change misleading test name
Browse files Browse the repository at this point in the history
  • Loading branch information
Senan Zedan (EXT-Nokia) committed Jan 3, 2025
1 parent 391f086 commit 8723902
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 52 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/kind-cluster-custom-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ name: Test policy-controller with custom resource

on:
pull_request:
branches: [ 'main', 'release-*' ]
branches: ["main", "release-*"]

defaults:
run:
Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5.1.0
with:
go-version-file: './go.mod'
go-version-file: "./go.mod"
check-latest: true

# will use the latest release available for ko
Expand All @@ -122,7 +122,7 @@ jobs:
k8s-version: ${{ matrix.k8s-version}}
version: ${{ env.SCAFFOLDING_RELEASE_VERSION }}

- name: Install policy-controller-with-only-pod-resource
- name: Install policy-controller-with-replicasets-daemonsets-resource
env:
GIT_HASH: ${{ github.sha }}
GIT_VERSION: ci
Expand All @@ -141,6 +141,7 @@ jobs:
- name: Run Custom resources Tests
timeout-minutes: 5
run: |
chmod +x ./test/e2e_test_policy_custom_resource.sh
./test/e2e_test_policy_custom_resource.sh
- name: Collect diagnostics
Expand Down
14 changes: 7 additions & 7 deletions cmd/webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ var (
disableTUF = flag.Bool("disable-tuf", false, "Disable TUF support.")

// Validate specific resources.
// https://github.com/sigstore/policy-controller/issues/1388
resourcesNames = flag.String("resource-name", "replicasets, deployments, pods, cronjobs, jobs, statefulsets, daemonsets", "Comma-separated list of resources")
// Split the input string into a slice of strings
listResources []string
types map[schema.GroupVersionKind]resourcesemantics.GenericCRD
// https://github.com/sigstore/policy-controller/issues/1388
resourcesNames = flag.String("resource-name", "replicasets, deployments, pods, cronjobs, jobs, statefulsets, daemonsets", "Comma-separated list of resources")
// Split the input string into a slice of strings
listResources []string
types map[schema.GroupVersionKind]resourcesemantics.GenericCRD

// mutatingCIPWebhookName holds the name of the mutating webhook configuration
// resource dispatching admission requests to policy-webhook.
Expand Down Expand Up @@ -125,7 +125,7 @@ func main() {

flag.Parse()
resourcesNamesList := strings.Split(*resourcesNames, ",")
listResources = append(listResources, resourcesNamesList...)
listResources = append(listResources, resourcesNamesList...)

Check warning on line 128 in cmd/webhook/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/webhook/main.go#L127-L128

Added lines #L127 - L128 were not covered by tests

// If TUF has been disabled do not try to set it up.
if !*disableTUF {
Expand Down Expand Up @@ -300,7 +300,7 @@ func NewMutatingAdmissionController(ctx context.Context, _ configmap.Watcher) *c
}
ctx = webhook.WithOptions(ctx, *woptions)
validator := cwebhook.NewValidator(ctx)
types = createTypesMap(listResources)
types = createTypesMap(listResources)

Check warning on line 303 in cmd/webhook/main.go

View check run for this annotation

Codecov / codecov/patch

cmd/webhook/main.go#L303

Added line #L303 was not covered by tests
return defaulting.NewAdmissionController(ctx,
// Name of the resource webhook.
*webhookName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@
// connecting to the same hosts repeatedly from the same client, you can use
// DefaultPooledClient to receive a client that has connection pooling
// semantics similar to http.DefaultClient.
//
package cleanhttp
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ func ParseKeyValues(input string, out map[string]string, sep string) error {

// ParseArbitraryKeyValues parses arbitrary <key,value> tuples. The input
// can be one of the following:
// * JSON string
// * Base64 encoded JSON string
// * Comma separated list of `<key>=<value>` pairs
// * Base64 encoded string containing comma separated list of
// `<key>=<value>` pairs
// - JSON string
// - Base64 encoded JSON string
// - Comma separated list of `<key>=<value>` pairs
// - Base64 encoded string containing comma separated list of
// `<key>=<value>` pairs
//
// Input will be parsed into the output parameter, which should
// be a non-nil map[string]string.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func init() {
//
// ```
// $ sockaddr eval -r '{{GetPrivateInterfaces | attr "address"}}'
/// ```
// / ```
func GetPrivateIP() (string, error) {
privateIfs, err := GetPrivateInterfaces()
if err != nil {
Expand All @@ -39,7 +39,7 @@ func GetPrivateIP() (string, error) {
//
// ```
// $ sockaddr eval -r '{{GetAllInterfaces | include "RFC" "6890" | join "address" " "}}'
/// ```
// / ```
func GetPrivateIPs() (string, error) {
ifAddrs, err := GetAllInterfaces()
if err != nil {
Expand Down Expand Up @@ -86,7 +86,7 @@ func GetPrivateIPs() (string, error) {
//
// ```
// $ sockaddr eval -r '{{GetPublicInterfaces | attr "address"}}'
/// ```
// / ```
func GetPublicIP() (string, error) {
publicIfs, err := GetPublicInterfaces()
if err != nil {
Expand All @@ -108,7 +108,7 @@ func GetPublicIP() (string, error) {
//
// ```
// $ sockaddr eval -r '{{GetAllInterfaces | exclude "RFC" "6890" | join "address" " "}}'
/// ```
// / ```
func GetPublicIPs() (string, error) {
ifAddrs, err := GetAllInterfaces()
if err != nil {
Expand Down Expand Up @@ -147,7 +147,7 @@ func GetPublicIPs() (string, error) {
//
// ```
// $ sockaddr eval -r '{{GetAllInterfaces | include "name" <<ARG>> | sort "type,size" | include "flag" "forwardable" | attr "address" }}'
/// ```
// / ```
func GetInterfaceIP(namedIfRE string) (string, error) {
ifAddrs, err := GetAllInterfaces()
if err != nil {
Expand Down Expand Up @@ -188,7 +188,7 @@ func GetInterfaceIP(namedIfRE string) (string, error) {
//
// ```
// $ sockaddr eval -r '{{GetAllInterfaces | include "name" <<ARG>> | sort "type,size" | join "address" " "}}'
/// ```
// / ```
func GetInterfaceIPs(namedIfRE string) (string, error) {
ifAddrs, err := GetAllInterfaces()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func GetDefaultInterfaces() (IfAddrs, error) {
//
// ```
// $ sockaddr eval -r '{{GetAllInterfaces | include "type" "ip" | include "flags" "forwardable" | include "flags" "up" | sort "default,type,size" | include "RFC" "6890" }}'
/// ```
// / ```
func GetPrivateInterfaces() (IfAddrs, error) {
privateIfs, err := GetAllInterfaces()
if err != nil {
Expand Down Expand Up @@ -351,7 +351,7 @@ func GetPrivateInterfaces() (IfAddrs, error) {
//
// ```
// $ sockaddr eval -r '{{GetAllInterfaces | include "type" "ip" | include "flags" "forwardable" | include "flags" "up" | sort "default,type,size" | exclude "RFC" "6890" }}'
/// ```
// / ```
func GetPublicInterfaces() (IfAddrs, error) {
publicIfs, err := GetAllInterfaces()
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ func (ipv4 IPv4Addr) BroadcastAddress() IPv4Network {

// CmpAddress follows the Cmp() standard protocol and returns:
//
// - -1 If the receiver should sort first because its address is lower than arg
// - 0 if the SockAddr arg is equal to the receiving IPv4Addr or the argument is
// of a different type.
// - 1 If the argument should sort first.
// - -1 If the receiver should sort first because its address is lower than arg
// - 0 if the SockAddr arg is equal to the receiving IPv4Addr or the argument is
// of a different type.
// - 1 If the argument should sort first.
func (ipv4 IPv4Addr) CmpAddress(sa SockAddr) int {
ipv4b, ok := sa.(IPv4Addr)
if !ok {
Expand All @@ -187,10 +187,10 @@ func (ipv4 IPv4Addr) CmpAddress(sa SockAddr) int {

// CmpPort follows the Cmp() standard protocol and returns:
//
// - -1 If the receiver should sort first because its port is lower than arg
// - 0 if the SockAddr arg's port number is equal to the receiving IPv4Addr,
// regardless of type.
// - 1 If the argument should sort first.
// - -1 If the receiver should sort first because its port is lower than arg
// - 0 if the SockAddr arg's port number is equal to the receiving IPv4Addr,
// regardless of type.
// - 1 If the argument should sort first.
func (ipv4 IPv4Addr) CmpPort(sa SockAddr) int {
var saPort IPPort
switch v := sa.(type) {
Expand All @@ -214,10 +214,10 @@ func (ipv4 IPv4Addr) CmpPort(sa SockAddr) int {

// CmpRFC follows the Cmp() standard protocol and returns:
//
// - -1 If the receiver should sort first because it belongs to the RFC and its
// arg does not
// - 0 if the receiver and arg both belong to the same RFC or neither do.
// - 1 If the arg belongs to the RFC but receiver does not.
// - -1 If the receiver should sort first because it belongs to the RFC and its
// arg does not
// - 0 if the receiver and arg both belong to the same RFC or neither do.
// - 1 If the arg belongs to the RFC but receiver does not.
func (ipv4 IPv4Addr) CmpRFC(rfcNum uint, sa SockAddr) int {
recvInRFC := IsRFC(rfcNum, ipv4)
ipv4b, ok := sa.(IPv4Addr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ func (ipv6 IPv6Addr) AddressHexString() string {

// CmpAddress follows the Cmp() standard protocol and returns:
//
// - -1 If the receiver should sort first because its address is lower than arg
// - 0 if the SockAddr arg equal to the receiving IPv6Addr or the argument is of a
// different type.
// - 1 If the argument should sort first.
// - -1 If the receiver should sort first because its address is lower than arg
// - 0 if the SockAddr arg equal to the receiving IPv6Addr or the argument is of a
// different type.
// - 1 If the argument should sort first.
func (ipv6 IPv6Addr) CmpAddress(sa SockAddr) int {
ipv6b, ok := sa.(IPv6Addr)
if !ok {
Expand All @@ -193,10 +193,10 @@ func (ipv6 IPv6Addr) CmpAddress(sa SockAddr) int {

// CmpPort follows the Cmp() standard protocol and returns:
//
// - -1 If the receiver should sort first because its port is lower than arg
// - 0 if the SockAddr arg's port number is equal to the receiving IPv6Addr,
// regardless of type.
// - 1 If the argument should sort first.
// - -1 If the receiver should sort first because its port is lower than arg
// - 0 if the SockAddr arg's port number is equal to the receiving IPv6Addr,
// regardless of type.
// - 1 If the argument should sort first.
func (ipv6 IPv6Addr) CmpPort(sa SockAddr) int {
var saPort IPPort
switch v := sa.(type) {
Expand All @@ -220,10 +220,10 @@ func (ipv6 IPv6Addr) CmpPort(sa SockAddr) int {

// CmpRFC follows the Cmp() standard protocol and returns:
//
// - -1 If the receiver should sort first because it belongs to the RFC and its
// arg does not
// - 0 if the receiver and arg both belong to the same RFC or neither do.
// - 1 If the arg belongs to the RFC but receiver does not.
// - -1 If the receiver should sort first because it belongs to the RFC and its
// arg does not
// - 0 if the receiver and arg both belong to the same RFC or neither do.
// - 1 If the arg belongs to the RFC but receiver does not.
func (ipv6 IPv6Addr) CmpRFC(rfcNum uint, sa SockAddr) int {
recvInRFC := IsRFC(rfcNum, ipv6)
ipv6b, ok := sa.(IPv6Addr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -721,10 +721,9 @@ func (p *printer) heredocIndent(buf []byte) []byte {
//
// A single line object:
//
// * has no lead comments (hence multi-line)
// * has no assignment
// * has no values in the stanza (within {})
//
// - has no lead comments (hence multi-line)
// - has no assignment
// - has no values in the stanza (within {})
func (p *printer) isSingleLineObject(val *ast.ObjectItem) bool {
// If there is a lead comment, can't be one line
if val.LeadComment != nil {
Expand Down

0 comments on commit 8723902

Please sign in to comment.