Skip to content

Modify govulncheck to only check cwagent components and fix lint issues #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ Fixes
<!--Describe the documentation added.-->
#### Documentation

<!--Ensure checks are successful -->
#### Checks
- Did you run `make fmt`? Y/N
- Did you verify that all checks pass? Y/N

<!--Please delete paragraphs that you did not use before submitting.-->
35 changes: 18 additions & 17 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,25 +141,24 @@ jobs:
fail-fast: false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Don't need the matrix if it's only one item.

matrix:
group:
- receiver-0
- receiver-1
- receiver-2
- receiver-3
- processor-0
- processor-1
- exporter-0
- exporter-1
- exporter-2
- exporter-3
- extension
- connector
- internal
- pkg
- cmd-0
- cmd-1
- cwagent
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout CloudWatch Agent Repo
uses: actions/checkout@v4
with:
repository: aws/amazon-cloudwatch-agent
path: 'amazon-cloudwatch-agent'
sparse-checkout: go.mod
- name: Get Components
id: get-components
run: |
CWAGENT_COMPONENTS=$(grep -o 'amazon-contributing/opentelemetry-collector-contrib/[^[:space:]/]*/[^[:space:]]*' amazon-cloudwatch-agent/go.mod | \
grep -v 'pull' | \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guessing this is to ignore the comments with PR links.

sed -n 's|amazon-contributing/opentelemetry-collector-contrib/\([^/]*/[^/]*\)$|./\1|p' | \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this will only work for packages that have only two levels (e.g. internal/coreutils) and not anything nested further. The list in the description is missing all the internal/aws/* packages and the pkg/translator/prometheus package.

sort -u | tr '\n' ' ' | sed 's/ $//')
echo "CWAGENT_COMPONENTS=$CWAGENT_COMPONENTS" >> $GITHUB_ENV
- name: Checkout Repo
uses: actions/checkout@v4
- name: Setup Go
Expand All @@ -181,7 +180,9 @@ jobs:
if: steps.go-cache.outputs.cache-hit != 'true'
run: make install-tools
- name: Run `govulncheck`
run: make -j2 gogovulncheck GROUP=${{ matrix.group }}
run: make -j2 gogovulncheck GROUP=cwagent

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you have it print out the components it's checking?

env:
CWAGENT_COMPONENTS: ${{ env.CWAGENT_COMPONENTS }}
checks:
runs-on: ubuntu-latest
needs: [setup-environment]
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ OVERRIDE_MODS := $(shell find ./override/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR)
OTHER_MODS := $(shell find . $(EX_COMPONENTS) $(EX_INTERNAL) $(EX_PKG) $(EX_CMD) $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) $(PWD)
ALL_MODS := $(RECEIVER_MODS) $(PROCESSOR_MODS) $(EXPORTER_MODS) $(EXTENSION_MODS) $(CONNECTOR_MODS) $(INTERNAL_MODS) $(PKG_MODS) $(CMD_MODS) $(OTHER_MODS)
CGO_MODS := ./receiver/hostmetricsreceiver
CWAGENT_MODS := $(CWAGENT_COMPONENTS) | xargs -n1 -I{} find {} -name "go.mod" -type f # CWAGENT_COMPONENTS is populated from build-and-test action

FIND_INTEGRATION_TEST_MODS={ find . -type f -name "*integration_test.go" & find . -type f -name "*e2e_test.go" -not -path "./testbed/*"; }
INTEGRATION_MODS := $(shell $(FIND_INTEGRATION_TEST_MODS) | xargs $(TO_MOD_DIR) | uniq)
Expand Down Expand Up @@ -89,6 +90,7 @@ all-groups:
@echo "\ncmd: $(CMD_MODS)"
@echo "\noverride: $(OVERRIDE_MODS)"
@echo "\nother: $(OTHER_MODS)"
@echo "\ncwagent: $(CWAGENT_MODS)"

.PHONY: all
all: install-tools all-common goporto multimod-verify gotest otelcontribcol
Expand Down Expand Up @@ -279,6 +281,9 @@ for-integration-target: $(INTEGRATION_MODS)
.PHONY: for-cgo-target
for-cgo-target: $(CGO_MODS)

.PHONY: for-cwagent-target
for-cwagent-target: $(CWAGENT_MODS)

# Debugging target, which helps to quickly determine whether for-all-target is working or not.
.PHONY: all-pwd
all-pwd:
Expand Down
3 changes: 2 additions & 1 deletion internal/aws/k8s/k8sclient/endpoint_slices_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ var endpointSlicesArray = []runtime.Object{
},
Labels: map[string]string{
"kubernetes.io/service-name": "kube-controller-manager",
}},
},
},
},
&discoveryv1.EndpointSlice{
ObjectMeta: metav1.ObjectMeta{
Expand Down
1 change: 0 additions & 1 deletion internal/kubelet/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ func (p *kubeConfigClientProvider) BuildClient() (Client, error) {
}

joinPath, err := url.JoinPath(authConf.Host, "/api/v1/nodes/", p.endpoint, "/proxy/")

if err != nil {
return nil, err
}
Expand Down
Loading