Skip to content

Commit

Permalink
Merge branch 'main' of github.com:DataDog/datadog-operator into lenai…
Browse files Browse the repository at this point in the history
…c/CONTINT-4412
  • Loading branch information
L3n41c committed Oct 23, 2024
2 parents 1ccaf76 + eb50a22 commit 7770e29
Show file tree
Hide file tree
Showing 32 changed files with 2,450 additions and 2,002 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Build

env:
GO_VERSION: 1.22.7
on:
push:

jobs:
build-linux-binary:
runs-on: ubuntu-latest
Expand All @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
go-version: ${{ env.GO_VERSION }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
Expand All @@ -37,7 +37,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
go-version: ${{ env.GO_VERSION }}
- name: Build
uses: goreleaser/goreleaser-action@v3
with:
Expand All @@ -54,7 +54,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
go-version: ${{ env.GO_VERSION }}
- name: Build
uses: goreleaser/goreleaser-action@v3
with:
Expand Down
51 changes: 26 additions & 25 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,33 @@ name: validation
on: [push, pull_request]
env:
PROJECTNAME: "datadog-operator"
GO_VERSION: 1.22.7
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.22
id: go
- name: install required packages
uses: mstksg/get-package@v1
with:
apt-get: mercurial jq build-essential
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: install tools
run: |
make install-tools
- name: run build
run: |
make manager
- name: run unit tests and E2E tests (fake cluster)
run: |
make test
- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: cover.out,cover_integration_v1.out,cover_integration_v2.out
flags: unittests
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: ${{ env.GO_VERSION }}
id: go
- name: install required packages
uses: mstksg/get-package@v1
with:
apt-get: mercurial jq build-essential
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: install tools
run: |
make install-tools
- name: run build
run: |
make manager
- name: run unit tests and E2E tests (fake cluster)
run: |
make test
- uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: cover.out,cover_integration_v1.out,cover_integration_v2.out
flags: unittests
28 changes: 14 additions & 14 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Release

on:
push:
branches:
- "v[0-9]+.[0-9]+"
tags:
- "v[0-9]+.[0-9]+.[0-9]+"
- "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"

env:
GO_VERSION: 1.22.7
jobs:
build-linux-binary:
if: startsWith(github.ref, 'refs/tags/v')
Expand All @@ -25,14 +25,14 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
go-version: ${{ env.GO_VERSION }}
- name: Get Latest Release
id: latest_version
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: ${{ github.repository_owner }}
repo: datadog-operator
excludes: prerelease, draft
owner: ${{ github.repository_owner }}
repo: datadog-operator
excludes: prerelease, draft
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
Expand Down Expand Up @@ -61,14 +61,14 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
go-version: ${{ env.GO_VERSION }}
- name: Get Latest Release
id: latest_version
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: ${{ github.repository_owner }}
repo: datadog-operator
excludes: prerelease, draft
owner: ${{ github.repository_owner }}
repo: datadog-operator
excludes: prerelease, draft
- name: Build
uses: goreleaser/goreleaser-action@v3
with:
Expand All @@ -95,14 +95,14 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22
go-version: ${{ env.GO_VERSION }}
- name: Get Latest Release
id: latest_version
uses: pozetroninc/github-action-get-latest-release@master
with:
owner: ${{ github.repository_owner }}
repo: datadog-operator
excludes: prerelease, draft
owner: ${{ github.repository_owner }}
repo: datadog-operator
excludes: prerelease, draft
- name: Build
uses: goreleaser/goreleaser-action@v3
with:
Expand Down
24 changes: 18 additions & 6 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ stages:

build:
stage: build
tags: ["runner:main", "size:large"]
tags: ["arch:amd64"]
before_script:
- mkdir -p .cache
- make install-tools
Expand All @@ -87,7 +87,7 @@ build:

unit_tests:
stage: test
tags: ["runner:main", "size:large"]
tags: ["arch:amd64"]
rules:
- if: '$DDR == "true"'
when: never
Expand All @@ -98,9 +98,19 @@ unit_tests:
script:
- make test

check-golang-version:
stage: test
tags: ["arch:amd64"]
before_script:
- mkdir -p .cache
- make install-tools
script:
- make update-golang
- git diff --exit-code

generate_code:
stage: test
tags: ["runner:main", "size:large"]
tags: ["arch:amd64"]
rules:
- if: '$DDR == "true"'
when: never
Expand Down Expand Up @@ -462,9 +472,10 @@ publish_community_operators:
# Note: skopeo apt package is only available in for ubuntu 20.10+
# https://github.com/containers/skopeo/blob/main/install.md#ubuntu
# TODO: use apt-get when gitlab runner image base is updated to use ubuntu 20.10+
- git clone https://github.com/containers/skopeo $GOPATH/src/github.com/containers/skopeo
- cd $GOPATH/src/github.com/containers/skopeo && DISABLE_DOCS=1 make bin/skopeo
- git clone --single-branch -b $SKOPEO_VERSION https://github.com/containers/skopeo /tmp/skopeo
- cd /tmp/skopeo && DISABLE_DOCS=1 make bin/skopeo
- DISABLE_DOCS=1 make install
- skopeo --version
# Set up redhat registry access to generate bundle-redhat
- mkdir ~/.redhat
- aws ssm get-parameter --region us-east-1 --name
Expand All @@ -479,7 +490,8 @@ publish_community_operators:
- gh auth setup-git
# create pull request for each marketplace repo
- make publish-community-bundles

variables:
SKOPEO_VERSION: release-1.16

# On success, this will cause Conductor to trigger a Deployment to nightly clusters in SDP
publish_nightly_workflow:
Expand Down
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ catalog-push: ## Push a catalog image.

##@ Datadog Custom part
.PHONY: install-tools
install-tools: bin/$(PLATFORM)/golangci-lint bin/$(PLATFORM)/operator-sdk bin/$(PLATFORM)/yq bin/$(PLATFORM)/kubebuilder bin/$(PLATFORM)/kubebuilder-tools bin/$(PLATFORM)/go-licenses bin/$(PLATFORM)/openapi-gen
install-tools: bin/$(PLATFORM)/golangci-lint bin/$(PLATFORM)/operator-sdk bin/$(PLATFORM)/yq bin/$(PLATFORM)/jq bin/$(PLATFORM)/kubebuilder bin/$(PLATFORM)/kubebuilder-tools bin/$(PLATFORM)/go-licenses bin/$(PLATFORM)/openapi-gen

.PHONY: generate-openapi
generate-openapi: bin/$(PLATFORM)/openapi-gen
Expand Down Expand Up @@ -314,6 +314,11 @@ licenses: bin/$(PLATFORM)/go-licenses
verify-licenses: bin/$(PLATFORM)/go-licenses ## Verify licenses
hack/verify-licenses.sh

# Update the golang version in different repository files from the version present in go.mod file
.PHONY: update-golang
update-golang:
hack/update-golang.sh

.PHONY: tidy
tidy: ## Run go tidy
go mod tidy -v
Expand All @@ -332,6 +337,9 @@ publish-community-bundles: ## Publish bundles to community repositories
bin/$(PLATFORM)/yq: Makefile
hack/install-yq.sh v4.31.2

bin/$(PLATFORM)/jq: Makefile
hack/install-jq.sh 1.7.1

bin/$(PLATFORM)/golangci-lint: Makefile
hack/golangci-lint.sh -b "bin/$(PLATFORM)" v1.61.0

Expand Down
6 changes: 6 additions & 0 deletions api/datadoghq/v2alpha1/test/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type DatadogAgentBuilder struct {
// NewDatadogAgentBuilder creates DatadogAgent and initializes Global, Features, Override properties
func NewDatadogAgentBuilder() *DatadogAgentBuilder {
dda := &v2alpha1.DatadogAgent{
ObjectMeta: metav1.ObjectMeta{},
Spec: v2alpha1.DatadogAgentSpec{
Global: &v2alpha1.GlobalConfig{},
Features: &v2alpha1.DatadogFeatures{},
Expand Down Expand Up @@ -71,6 +72,11 @@ func (builder *DatadogAgentBuilder) WithName(name string) *DatadogAgentBuilder {
return builder
}

func (builder *DatadogAgentBuilder) WithAnnotations(annotations map[string]string) *DatadogAgentBuilder {
builder.datadogAgent.ObjectMeta.Annotations = annotations
return builder
}

// Global environment variable
func (builder *DatadogAgentBuilder) WithEnvVars(envs []corev1.EnvVar) *DatadogAgentBuilder {
builder.datadogAgent.Spec.Global.Env = envs
Expand Down
4 changes: 2 additions & 2 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resources:
- manager.yaml
images:
- name: controller
newName: fannyatdd/operator
newTag: saa
newName: gcr.io/datadoghq/operator
newTag: 1.9.0
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
10 changes: 9 additions & 1 deletion docs/how-to-contribute.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# How to contribute

# Testing the Operator for development
## Testing the Operator for development

The recommended way to test the Operator is by creating a [kind](https://kind.sigs.k8s.io/) cluster.

Expand Down Expand Up @@ -76,6 +76,14 @@ kubectl -n $KUBE_NAMESPACE apply -f examples/datadogagent/datadog-agent-minimum

The Operator should start deploying the `agent` and `cluster-agent`.

## Golang version update

The Go version is defined in several files. To ensure all relevant files are updated, it is recommended to use the script `make update-golang`:

1. Update the Go version in the `go.work` file.
2. Run the command `make update-golang`, which patches all files that contain the Go version.

If the golang version is used in a new file (for example in a new `Dockefile`) the script `hack/update-golang.sh` needs to be updated to handle this new file in the golang version update process.

## Tests

Expand Down
Loading

0 comments on commit 7770e29

Please sign in to comment.