-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from marklogic/release/ea1
Release Kubernetes Operator EA1
- Loading branch information
Showing
98 changed files
with
32,643 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# More info: https://docs.docker.com/engine/reference/builder/#dockerignore-file | ||
# Ignore build and test binaries. | ||
bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
bin/* | ||
Dockerfile.cross | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Go workspace file | ||
go.work | ||
|
||
# Kubernetes Generated files - skip generated files, except for vendored files | ||
!vendor/**/zz_generated.* | ||
|
||
# editor and IDE paraphernalia | ||
.idea | ||
.vscode | ||
*.swp | ||
*.swo | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
run: | ||
deadline: 5m | ||
allow-parallel-runners: true | ||
|
||
issues: | ||
# don't skip warning about doc comments | ||
# don't exclude the default set of lint | ||
exclude-use-default: false | ||
# restore some of the defaults | ||
# (fill in the rest as needed) | ||
exclude-rules: | ||
- path: "api/*" | ||
linters: | ||
- lll | ||
- path: "internal/*" | ||
linters: | ||
- dupl | ||
- lll | ||
linters: | ||
disable-all: true | ||
enable: | ||
- dupl | ||
- errcheck | ||
- exportloopref | ||
- goconst | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- lll | ||
- misspell | ||
- nakedret | ||
- prealloc | ||
- staticcheck | ||
- typecheck | ||
- unconvert | ||
- unparam | ||
- unused |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Contributing to MarkLogic-kubernetes-operator | ||
|
||
Thank you for your interest in contributing to this project! We welcome contributions from the community to make this project better. | ||
|
||
- [Found an Issue](#found-an-issue) | ||
- [Want a Feature](#want-a-feature) | ||
- [Getting Started](#getting-started) | ||
- [PR management](#pr-management) | ||
|
||
## Found an Issue? | ||
|
||
If you find a bug in the source code or a mistake in the documentation, you can help us by submitting an issue | ||
to our [GitHub Issue Tracker][Issue Tracker]. If you'd like to submit a feature enhancement, please first create an | ||
issue with your proposed idea so that we can start a discussion about the problem you want to solve and what the best | ||
solution would be. | ||
|
||
## Want a Feature? | ||
|
||
You can request a new feature by submitting an issue to our [GitHub Issue Tracker][Issue Tracker]. If you | ||
would like to implement a new feature then first create a new issue and discuss it with one of our | ||
project maintainers. | ||
|
||
## Getting Started | ||
|
||
To get started with contributing, please follow these steps: | ||
|
||
1. Fork the repository and clone it to your local machine. | ||
2. Install the necessary dependencies. | ||
3. Create a new branch for your changes. | ||
4. Make your desired changes to the codebase. | ||
5. Test your changes thoroughly. | ||
6. Tests can be done using the test framework. See [test folder](./test/) and [Makefile](makefile) | ||
|
||
## PR management | ||
|
||
Created PR will not be merge as is. | ||
The MarkLogic kubernetes operator team will use the PRs for "inspiration" but not merge the changes in directly. They may rewrite the code as they like, incorporating the submitted changes into their own code. | ||
|
||
**Important:** Please open an issue in the [Issue Tracker][] and get your proposed changes pre-approved by at least one of the project maintainers before you start coding. Nothing is more frustrating than seeing your hard work go to waste because your vision does not align with that of the project maintainers. | ||
|
||
[Issue Tracker]: https://github.com/marklogic/marklogic-kubernetes-operator/issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Build the manager binary | ||
FROM golang:1.22 AS builder | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
|
||
WORKDIR /workspace | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
|
||
# Copy the go source | ||
COPY cmd/main.go cmd/main.go | ||
COPY api/ api/ | ||
COPY internal/controller/ internal/controller/ | ||
COPY pkg/ pkg/ | ||
|
||
# Build | ||
# the GOARCH has not a default value to allow the binary be built according to the host where the command | ||
# was called. For example, if we call make docker-build in a local env which has the Apple Silicon M1 SO | ||
# the docker BUILDPLATFORM arg will be linux/arm64 when for Apple x86 it will be linux/amd64. Therefore, | ||
# by leaving it empty we can ensure that the container and binary shipped on it will have the same platform. | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o manager cmd/main.go | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/static:nonroot | ||
WORKDIR / | ||
COPY --from=builder /workspace/manager . | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/manager"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
/* groovylint-disable CompileStatic, LineLength, VariableTypeRequired */ | ||
// This Jenkinsfile defines internal MarkLogic build pipeline. | ||
|
||
//Shared library definitions: https://github.com/marklogic/MarkLogic-Build-Libs/tree/1.0-declarative/vars | ||
@Library('shared-libraries@1.0-declarative') | ||
import groovy.json.JsonSlurperClassic | ||
|
||
emailList = 'vitaly.korolev@progress.com, sumanth.ravipati@progress.com, peng.zhou@progress.com, barkha.choithani@progress.com, romain.winieski@progress.com' | ||
emailSecList = 'Rangan.Doreswamy@progress.com, Mahalakshmi.Srinivasan@progress.com' | ||
gitCredID = 'marklogic-builder-github' | ||
JIRA_ID = '' | ||
JIRA_ID_PATTERN = /(?i)(MLE)-\d{3,6}/ | ||
|
||
// Define local funtions | ||
void preBuildCheck() { | ||
// Initialize parameters as env variables as workaround for https://issues.jenkins-ci.org/browse/JENKINS-41929 | ||
evaluate """${ def script = ''; params.each { k, v -> script += "env.${k } = '''${v}'''\n" }; return script}""" | ||
|
||
JIRA_ID = extractJiraID() | ||
echo 'Jira ticket number: ' + JIRA_ID | ||
|
||
if (env.GIT_URL) { | ||
githubAPIUrl = GIT_URL.replace('.git', '').replace('github.com', 'api.github.com/repos') | ||
echo 'githubAPIUrl: ' + githubAPIUrl | ||
} else { | ||
echo 'Warning: GIT_URL is not defined' | ||
} | ||
|
||
if (env.CHANGE_ID) { | ||
if (prDraftCheck()) { sh 'exit 1' } | ||
if (getReviewState().equalsIgnoreCase('CHANGES_REQUESTED')) { | ||
echo 'PR changes requested. (' + reviewState + ') Aborting.' | ||
sh 'exit 1' | ||
} | ||
} | ||
|
||
// our VMs sometimes disable bridge traffic. this should help to restore it. | ||
sh 'sudo sh -c "echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables"' | ||
} | ||
|
||
@NonCPS | ||
def extractJiraID() { | ||
// Extract Jira ID from one of the environment variables | ||
def match | ||
if (env.CHANGE_TITLE) { | ||
match = env.CHANGE_TITLE =~ JIRA_ID_PATTERN | ||
} | ||
else if (env.BRANCH_NAME) { | ||
match = env.BRANCH_NAME =~ JIRA_ID_PATTERN | ||
} | ||
else if (env.GIT_BRANCH) { | ||
match = env.GIT_BRANCH =~ JIRA_ID_PATTERN | ||
} | ||
else { | ||
echo 'Warning: No Git title or branch available.' | ||
return '' | ||
} | ||
try { | ||
return match[0][0] | ||
} catch (any) { | ||
echo 'Warning: Jira ticket number not detected.' | ||
return '' | ||
} | ||
} | ||
|
||
def prDraftCheck() { | ||
withCredentials([usernameColonPassword(credentialsId: gitCredID, variable: 'Credentials')]) { | ||
PrObj = sh(returnStdout: true, script:''' | ||
curl -s -u $Credentials -X GET ''' + githubAPIUrl + '''/pulls/$CHANGE_ID | ||
''') | ||
} | ||
def jsonObj = new JsonSlurperClassic().parseText(PrObj.toString().trim()) | ||
return jsonObj.draft | ||
} | ||
|
||
def getReviewState() { | ||
def reviewResponse | ||
def commitHash | ||
withCredentials([usernameColonPassword(credentialsId: gitCredID, variable: 'Credentials')]) { | ||
reviewResponse = sh(returnStdout: true, script:''' | ||
curl -s -u $Credentials -X GET ''' + githubAPIUrl + '''/pulls/$CHANGE_ID/reviews | ||
''') | ||
commitHash = sh(returnStdout: true, script:''' | ||
curl -s -u $Credentials -X GET ''' + githubAPIUrl + '''/pulls/$CHANGE_ID | ||
''') | ||
} | ||
def jsonObj = new JsonSlurperClassic().parseText(commitHash.toString().trim()) | ||
def commitId = jsonObj.head.sha | ||
println(commitId) | ||
def reviewState = getReviewStateOfPR reviewResponse, 2, commitId | ||
echo reviewState | ||
return reviewState | ||
} | ||
|
||
void resultNotification(message) { | ||
def author, authorEmail, emailList | ||
//add author of a PR to email list if available | ||
if (env.CHANGE_AUTHOR) { | ||
author = env.CHANGE_AUTHOR.toString().trim().toLowerCase() | ||
authorEmail = getEmailFromGITUser author | ||
emailList = params.emailList + ',' + authorEmail | ||
} else { | ||
emailList = params.emailList | ||
} | ||
jira_link = "https://progresssoftware.atlassian.net/browse/${JIRA_ID}" | ||
email_body = "<b>Jenkins pipeline for</b> ${env.JOB_NAME} <br><b>Build Number: </b>${env.BUILD_NUMBER} <br><br><b>Build URL: </b><br><a href='${env.BUILD_URL}'>${env.BUILD_URL}</a>" | ||
jira_email_body = "${email_body} <br><br><b>Jira URL: </b><br><a href='${jira_link}'>${jira_link}</a>" | ||
|
||
if (JIRA_ID) { | ||
def comment = [ body: "Jenkins pipeline build result: ${message}" ] | ||
jiraAddComment site: 'JIRA', idOrKey: JIRA_ID, failOnError: false, input: comment | ||
mail charset: 'UTF-8', mimeType: 'text/html', to: "${emailList}", body: "${jira_email_body}", subject: "${message}: ${env.JOB_NAME} #${env.BUILD_NUMBER} - ${JIRA_ID}" | ||
} else { | ||
mail charset: 'UTF-8', mimeType: 'text/html', to: "${emailList}", body: "${email_body}", subject: "${message}: ${env.JOB_NAME} #${env.BUILD_NUMBER}" | ||
} | ||
} | ||
|
||
void publishTestResults() { | ||
junit allowEmptyResults:true, testResults: '**/test/test_results/*.xml' | ||
archiveArtifacts artifacts: '**/test/test_results/*.xml', allowEmptyArchive: true | ||
} | ||
|
||
void runTests() { | ||
sh "make test" | ||
} | ||
|
||
void runE2eTests() { | ||
//TODO: this is just a place holder as kuttl needs a proper environment | ||
sh "echo make e2e-tests dockerImage=${params.dockerImage}" | ||
} | ||
|
||
pipeline { | ||
agent { | ||
label { | ||
label 'cld-kubernetes' | ||
} | ||
} | ||
options { | ||
checkoutToSubdirectory '.' | ||
buildDiscarder logRotator(artifactDaysToKeepStr: '20', artifactNumToKeepStr: '', daysToKeepStr: '30', numToKeepStr: '') | ||
skipStagesAfterUnstable() | ||
} | ||
// triggers { | ||
// //TODO: add scheduled runs | ||
// } | ||
// environment { | ||
// //TODO | ||
// } | ||
|
||
parameters { | ||
string(name: 'dockerImage', defaultValue: 'ml-docker-db-dev-tierpoint.bed-artifactory.bedford.progress.com/marklogic/marklogic-server-ubi:latest-11', description: 'Docker image to use for tests.', trim: true) | ||
string(name: 'emailList', defaultValue: emailList, description: 'List of email for build notification', trim: true) | ||
} | ||
|
||
stages { | ||
stage('Pre-Build-Check') { | ||
steps { | ||
preBuildCheck() | ||
} | ||
} | ||
|
||
stage('Run-tests') { | ||
steps { | ||
runTests() | ||
} | ||
} | ||
|
||
stage('Run-e2e-tests') { | ||
steps { | ||
runE2eTests() | ||
} | ||
} | ||
|
||
} | ||
|
||
post { | ||
always { | ||
publishTestResults() | ||
} | ||
success { | ||
resultNotification('BUILD SUCCESS ✅') | ||
} | ||
failure { | ||
resultNotification('BUILD ERROR ❌') | ||
} | ||
unstable { | ||
resultNotification('BUILD UNSTABLE 🉑') | ||
} | ||
} | ||
} |
Oops, something went wrong.