Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix-epp-secret
Browse files Browse the repository at this point in the history
  • Loading branch information
k15r committed Apr 8, 2024
2 parents 4f9ddbc + c542473 commit 139fb9b
Show file tree
Hide file tree
Showing 24 changed files with 592 additions and 43 deletions.
106 changes: 106 additions & 0 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,109 @@ jobs:
KUSTOMIZE_VERSION: "v4.5.6"
run: |
./hack/ci/render_and_upload_manifests.sh
bump-sec-scanners-config-main:
name: Bump sec-scanners-config.yaml on main branch
needs: create-draft
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.generate-version.outputs.VERSION }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main

- uses: actions/setup-go@v5
with:
go-version: "stable"

- name: "Setup yq" # Required for rendering the files.
shell: bash
run: |
go install github.com/mikefarah/yq/v4@latest
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Render sec-scanners-config.yaml
shell: bash
run: |
yq --version
./hack/ci/render-sec-scanners-config.sh "${VERSION}"
FILE="sec-scanners-config.yaml"
echo "******* ${FILE} *******"
[ -f "${FILE}" ] && cat "${FILE}" || echo "${FILE} not found."
# Check if there are changes, so we can determine if all following steps can be skipped.
- name: Check for changes
shell: bash
run: |
if [ -z "$(git status --porcelain)" ]; then
echo "No changes found. No need to create a PR"
else
echo "Changes found. Creating a PR and waiting for it to be merged."
echo "CREATE_PR=true" >> $GITHUB_ENV
fi
- name: Set up git
if: ${{ env.CREATE_PR == 'true' }}
env:
GH_TOKEN: ${{ secrets.BOT_PAT }}
REPO: ${{ github.repository }}
shell: bash
run: |
# set git username
ghusername=$(curl -s -H "Authorization: token ${GH_TOKEN}" https://api.github.com/user | jq '.login')
git config user.name "${ghusername}"
# set git mail address
ghemailaddress="${ghusername}@users.noreply.github.com"
git config user.email "${ghemailaddress}"
# set remote url
git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/${REPO}.git"
- name: Set all variables
if: ${{ env.CREATE_PR == 'true' }}
shell: bash
run: |
PR_DATE="$(date '+%Y-%m-%d-%H-%M-%S')"
echo "pr date: ${PR_DATE}"
echo "PR_DATE=${PR_DATE}" >> $GITHUB_ENV
BRANCH_NAME="sec-scanners-bump-main-${PR_DATE}"
echo "name of the new branch: ${BRANCH_NAME}"
echo "BRANCH_NAME=${BRANCH_NAME}" >> $GITHUB_ENV
- name: Create a pull request
if: ${{ env.CREATE_PR == 'true' }}
env:
REPO: ${{ github.repository }}
PR_DATE: ${{ env.PR_DATE }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
GH_TOKEN: ${{ secrets.BOT_PAT }}
shell: bash
run: |
# Create a new branch for our changes.
git checkout -b "${BRANCH_NAME}"
# Stage the changes to sec-scanner-config.yaml and create a commit.
git add sec-scanners-config.yaml
git commit -m "auto-bump sec-scanners-config: ${PR_DATE}"
# Push the changes to origin, as defined earlier.
git push origin "$BRANCH_NAME"
# Create a PR.
BODY="This is an auto-generated PR to bump the sec-scanners-config.yml on ${REPO}."
PR_URL=$(gh pr create --base "main" --head "${BRANCH_NAME}" --title "chore: bump sec-scanners-config on main" --body "${BODY}")
echo "PR_URL=${PR_URL}" >> $GITHUB_ENV
- name: USER INTERACTION REQUIRED
if: ${{ env.CREATE_PR == 'true' }}
shell: bash
timeout-minutes: 60
env:
PR_URL: ${{ env.PR_URL }}
GH_TOKEN: ${{ secrets.BOT_PAT }}
run: |
echo "please review: ${PR_URL}"
./hack/ci/await-pr-merge.sh
28 changes: 28 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This is a configuration file for the markdownlint. You can use this file to overwrite the default settings.
# MD013 is set to false by default because many files include lines longer than the conventional 80 character limit
MD013: false
# Disable the Multiple headings with the same content rule
MD024: false
# MD029 is set to false because it generated some issues with longer lists
MD029: false
# Checks if there some inline HTML-elements
MD033: false
# MD044 is used to set capitalization for the particular words. You can determine whether it should be used also for code blocks and html elements
MD044:
code_blocks: false
html_elements: false
names:
- Kyma
- Kubernetes
- ConfigMap
- CronJob
- CustomResourceDefinition
- Ingress
- Node
- PodPreset
- Pod
- ProwJob
- Secret
- ServiceBinding
- ServiceClass
- ServiceInstance
1 change: 1 addition & 0 deletions .markdownlintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_sidebar.md
12 changes: 8 additions & 4 deletions api/operator/v1alpha1/eventing_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ limitations under the License.
package v1alpha1

import (
"strings"

kcorev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -39,12 +41,10 @@ const (
ConditionSubscriptionManagerReady ConditionType = "SubscriptionManagerReady"
ConditionDeleted ConditionType = "Deleted"

// common reasons.
ConditionReasonProcessing ConditionReason = "Processing"
ConditionReasonDeleted ConditionReason = "Deleted"
ConditionReasonStopped ConditionReason = "Stopped"

// publisher proxy reasons.
ConditionReasonDeployed ConditionReason = "Deployed"
ConditionReasonDeployedFailed ConditionReason = "DeployFailed"
ConditionReasonDeploymentStatusSyncFailed ConditionReason = "DeploymentStatusSyncFailed"
Expand All @@ -55,8 +55,8 @@ const (
ConditionReasonWebhookFailed ConditionReason = "WebhookFailed"
ConditionReasonWebhookReady ConditionReason = "Ready"
ConditionReasonDeletionError ConditionReason = "DeletionError"
ConditionReasonEventMeshConfigAvailable ConditionReason = "EventMeshConfigAvailable"

// message for conditions.
ConditionPublisherProxyReadyMessage = "Publisher proxy is deployed"
ConditionPublisherProxyDeletedMessage = "Publisher proxy is deleted"
ConditionNATSAvailableMessage = "NATS is available"
Expand All @@ -65,8 +65,8 @@ const (
ConditionSubscriptionManagerReadyMessage = "Subscription manager is ready"
ConditionSubscriptionManagerStoppedMessage = "Subscription manager is stopped"
ConditionBackendNotSpecifiedMessage = "Backend config is not provided. Please specify a backend."
ConditionEventMeshConfigAvailableMessage = "EventMesh config is available"

// subscription manager reasons.
ConditionReasonEventMeshSubManagerReady ConditionReason = "EventMeshSubscriptionManagerReady"
ConditionReasonEventMeshSubManagerFailed ConditionReason = "EventMeshSubscriptionManagerFailed"
ConditionReasonEventMeshSubManagerStopFailed ConditionReason = "EventMeshSubscriptionManagerStopFailed"
Expand Down Expand Up @@ -243,3 +243,7 @@ func (e *Eventing) IsPreviousBackendEmpty() bool {
func (e *Eventing) IsSpecBackendTypeChanged() bool {
return e.Status.ActiveBackend != e.Spec.Backend.Type
}

func (es EventingSpec) HasEmptyBackend() bool {
return es.Backend == nil || len(strings.TrimSpace(string(es.Backend.Type))) == 0
}
50 changes: 50 additions & 0 deletions api/operator/v1alpha1/eventing_types_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package v1alpha1

import (
"github.com/stretchr/testify/assert"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -109,3 +110,52 @@ func Test_getSupportedConditionsTypes(t *testing.T) {
got := getSupportedConditionsTypes()
require.Equal(t, want, got)
}

func TestHasEmptyBackend(t *testing.T) {
tests := []struct {
name string
givenEventingSpec EventingSpec
wantHasEmptyBackend bool
}{
{
name: "with nil backend",
givenEventingSpec: EventingSpec{
Backend: nil,
},
wantHasEmptyBackend: true,
},
{
name: "with empty backend type",
givenEventingSpec: EventingSpec{
Backend: &Backend{
Type: "",
},
},
wantHasEmptyBackend: true,
},
{
name: "with non-empty backend type all whitespaces",
givenEventingSpec: EventingSpec{
Backend: &Backend{
Type: " ",
},
},
wantHasEmptyBackend: true,
},
{
name: "with non-empty backend type",
givenEventingSpec: EventingSpec{
Backend: &Backend{
Type: "any",
},
},
wantHasEmptyBackend: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got := tt.givenEventingSpec.HasEmptyBackend()
assert.Equal(t, tt.wantHasEmptyBackend, got)
})
}
}
6 changes: 6 additions & 0 deletions api/operator/v1alpha1/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ func (es *EventingStatus) SetNATSAvailableConditionToTrue() {
es.UpdateConditionBackendAvailable(kmetav1.ConditionTrue, ConditionReasonNATSAvailable, ConditionNATSAvailableMessage)
}

func (es *EventingStatus) SetEventMeshAvailableConditionToTrue() {
es.UpdateConditionBackendAvailable(
kmetav1.ConditionTrue, ConditionReasonEventMeshConfigAvailable, ConditionEventMeshConfigAvailableMessage,
)
}

func (es *EventingStatus) SetSubscriptionManagerReadyConditionToFalse(reason ConditionReason, message string) {
es.UpdateConditionSubscriptionManagerReady(kmetav1.ConditionFalse, reason,
message)
Expand Down
Loading

0 comments on commit 139fb9b

Please sign in to comment.