Skip to content

Commit

Permalink
Merge branch 'master' of github.com:codeready-toolchain/member-operat…
Browse files Browse the repository at this point in the history
…or into vmWebhookLimits
  • Loading branch information
rajivnathan committed Oct 12, 2023
2 parents 2d2d889 + a026dbe commit ea221b3
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 20 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: 1.19.x

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Generate Assets
run: |
Expand Down Expand Up @@ -49,7 +49,7 @@ jobs:
go-version: 1.19.x

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Generate Assets
run: |
Expand All @@ -68,10 +68,10 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Generate SBOM
uses: CycloneDX/gh-gomod-generate-sbom@v1
uses: CycloneDX/gh-gomod-generate-sbom@v2
with:
version: v1
args: mod -licenses -json -output -
args: mod -licenses -json -output -
2 changes: 1 addition & 1 deletion .github/workflows/ci-check-gomod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: check
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/operator-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles ('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/publish-operators-for-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
# Checkout from PR event - in that case the comment field is empty
- name: Checkout code from PR event
uses: actions/checkout@v2
uses: actions/checkout@v4
if: ${{ github.event.comment == '' }}
with:
ref: ${{github.event.pull_request.head.ref}}
Expand All @@ -39,27 +39,27 @@ jobs:
# Checkout the code based on the data retrieved from the previous step
# Is executed only for comment events - in that case the pull_request field is empty
- name: Checkout code from PR
uses: actions/checkout@v2
uses: actions/checkout@v4
if: ${{ github.event.pull_request == '' }}
with:
repository: ${{ fromJson(steps.request.outputs.data).head.repo.full_name }}
ref: ${{ fromJson(steps.request.outputs.data).head.ref }}
fetch-depth: 0

- name: Install Go
uses: actions/setup-go@v2
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles ('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.x'

Expand Down
20 changes: 19 additions & 1 deletion config/crd/bases/toolchain.dev.openshift.com_workspaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,31 @@ spec:
when the role in the current binding can be changed - "delete"
when the current binding can be deleted - "override" when
the current binding is inherited from a parent workspace,
it cannot be updated but it can be overridden by creating
it cannot be updated, but it can be overridden by creating
a new binding containing the same MasterUserRecord but different
role in the subworkspace.'
items:
type: string
type: array
x-kubernetes-list-type: atomic
bindingRequest:
description: BindingRequest provides the name and namespace
of the SpaceBindingRequest that generated the SpaceBinding
resource. It's available only if the binding was generated
using the SpaceBindingRequest mechanism.
properties:
name:
description: Name of the SpaceBindingRequest that generated
the SpaceBinding resource.
type: string
namespace:
description: Namespace of the SpaceBindingRequest that generated
the SpaceBinding resource.
type: string
required:
- name
- namespace
type: object
masterUserRecord:
description: MasterUserRecord is the name of the user that has
access to the workspace. This field is immutable via a validating
Expand Down
7 changes: 6 additions & 1 deletion deploy/webhook/member-operator-webhook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ objects:
namespaceSelector:
matchLabels:
toolchain.dev.openshift.com/provider: codeready-toolchain
# The users.spacebindingrequests.webhook.sandbox webhook validates SpaceBindingRequest CRs,
# Specifically it makes sure that once a SBR resource is created, the SpaceBindingRequest.Spec.MasterUserRecord field is not changed by the user.
# The reason for making SpaceBindingRequest.Spec.MasterUserRecord field immutable is that as of now the SpaceBinding resource name is composed as follows: <Space.Name>-checksum(<Space.Name>-<MasterUserRecord.Name>),
# thus changing it will trigger an updated of the SpaceBinding content but the name will still be based on the old MUR name.
# The webhook code is available at member-operator/pkg/webhook/validatingwebhook/validate_spacebindingrequest.go
- name: users.spacebindingrequests.webhook.sandbox
admissionReviewVersions:
- v1
Expand All @@ -248,7 +253,7 @@ objects:
sideEffects: None
timeoutSeconds: 5
reinvocationPolicy: Never
failurePolicy: Ignore
failurePolicy: Fail
namespaceSelector:
matchLabels:
toolchain.dev.openshift.com/provider: codeready-toolchain
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/codeready-toolchain/member-operator

require (
github.com/codeready-toolchain/api v0.0.0-20230918195153-739e8fb09a33
github.com/codeready-toolchain/api v0.0.0-20231010090546-098b27b43b3a
github.com/codeready-toolchain/toolchain-common v0.0.0-20230920120310-0f59f17bca92
github.com/go-logr/logr v1.2.3
github.com/google/go-cmp v0.5.9
Expand Down
2 changes: 1 addition & 1 deletion pkg/webhook/deploy/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func mutatingWebhookConfig(namespace, caBundle string) string {
}

func validatingWebhookConfig(namespace, caBundle string) string {
return fmt.Sprintf(`{"apiVersion":"admissionregistration.k8s.io/v1","kind":"ValidatingWebhookConfiguration","metadata":{"labels":{"app":"member-operator-webhook","toolchain.dev.openshift.com/provider":"codeready-toolchain"},"name":"member-operator-validating-webhook"},"webhooks":[{"admissionReviewVersions":["v1"],"clientConfig":{"caBundle":"%[1]s","service":{"name":"member-operator-webhook","namespace":"%[2]s","path":"/validate-users-rolebindings","port":443}},"failurePolicy":"Ignore","matchPolicy":"Equivalent","name":"users.rolebindings.webhook.sandbox","namespaceSelector":{"matchLabels":{"toolchain.dev.openshift.com/provider":"codeready-toolchain"}},"reinvocationPolicy":"Never","rules":[{"apiGroups":["rbac.authorization.k8s.io","authorization.openshift.io"],"apiVersions":["v1"],"operations":["CREATE","UPDATE"],"resources":["rolebindings"],"scope":"Namespaced"}],"sideEffects":"None","timeoutSeconds":5},{"admissionReviewVersions":["v1"],"clientConfig":{"caBundle":"%[1]s","service":{"name":"member-operator-webhook","namespace":"%[2]s","path":"/validate-users-checlusters","port":443}},"failurePolicy":"Fail","matchPolicy":"Equivalent","name":"users.checlusters.webhook.sandbox","namespaceSelector":{"matchLabels":{"toolchain.dev.openshift.com/provider":"codeready-toolchain"}},"reinvocationPolicy":"Never","rules":[{"apiGroups":["org.eclipse.che"],"apiVersions":["v2"],"operations":["CREATE"],"resources":["checlusters"],"scope":"Namespaced"}],"sideEffects":"None","timeoutSeconds":5},{"admissionReviewVersions":["v1"],"clientConfig":{"caBundle":"%[1]s","service":{"name":"member-operator-webhook","namespace":"%[2]s","path":"/validate-spacebindingrequests","port":443}},"failurePolicy":"Ignore","matchPolicy":"Equivalent","name":"users.spacebindingrequests.webhook.sandbox","namespaceSelector":{"matchLabels":{"toolchain.dev.openshift.com/provider":"codeready-toolchain"}},"reinvocationPolicy":"Never","rules":[{"apiGroups":["toolchain.dev.openshift.com"],"apiVersions":["v1alpha1"],"operations":["CREATE", "UPDATE"],"resources":["spacebindingrequests"],"scope":"Namespaced"}],"sideEffects":"None","timeoutSeconds":5}]}`, caBundle, namespace)
return fmt.Sprintf(`{"apiVersion":"admissionregistration.k8s.io/v1","kind":"ValidatingWebhookConfiguration","metadata":{"labels":{"app":"member-operator-webhook","toolchain.dev.openshift.com/provider":"codeready-toolchain"},"name":"member-operator-validating-webhook"},"webhooks":[{"admissionReviewVersions":["v1"],"clientConfig":{"caBundle":"%[1]s","service":{"name":"member-operator-webhook","namespace":"%[2]s","path":"/validate-users-rolebindings","port":443}},"failurePolicy":"Ignore","matchPolicy":"Equivalent","name":"users.rolebindings.webhook.sandbox","namespaceSelector":{"matchLabels":{"toolchain.dev.openshift.com/provider":"codeready-toolchain"}},"reinvocationPolicy":"Never","rules":[{"apiGroups":["rbac.authorization.k8s.io","authorization.openshift.io"],"apiVersions":["v1"],"operations":["CREATE","UPDATE"],"resources":["rolebindings"],"scope":"Namespaced"}],"sideEffects":"None","timeoutSeconds":5},{"admissionReviewVersions":["v1"],"clientConfig":{"caBundle":"%[1]s","service":{"name":"member-operator-webhook","namespace":"%[2]s","path":"/validate-users-checlusters","port":443}},"failurePolicy":"Fail","matchPolicy":"Equivalent","name":"users.checlusters.webhook.sandbox","namespaceSelector":{"matchLabels":{"toolchain.dev.openshift.com/provider":"codeready-toolchain"}},"reinvocationPolicy":"Never","rules":[{"apiGroups":["org.eclipse.che"],"apiVersions":["v2"],"operations":["CREATE"],"resources":["checlusters"],"scope":"Namespaced"}],"sideEffects":"None","timeoutSeconds":5},{"admissionReviewVersions":["v1"],"clientConfig":{"caBundle":"%[1]s","service":{"name":"member-operator-webhook","namespace":"%[2]s","path":"/validate-spacebindingrequests","port":443}},"failurePolicy":"Fail","matchPolicy":"Equivalent","name":"users.spacebindingrequests.webhook.sandbox","namespaceSelector":{"matchLabels":{"toolchain.dev.openshift.com/provider":"codeready-toolchain"}},"reinvocationPolicy":"Never","rules":[{"apiGroups":["toolchain.dev.openshift.com"],"apiVersions":["v1alpha1"],"operations":["CREATE", "UPDATE"],"resources":["spacebindingrequests"],"scope":"Namespaced"}],"sideEffects":"None","timeoutSeconds":5}]}`, caBundle, namespace)
}

func serviceAccount(namespace string) string {
Expand Down
5 changes: 5 additions & 0 deletions pkg/webhook/validatingwebhook/validate_spacebindingrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import (
runtimeClient "sigs.k8s.io/controller-runtime/pkg/client"
)

// SpaceBindingRequestValidator webhook validates SpaceBindingRequest CRs,
// Specifically it makes sure that once an SBR resource is created, the SpaceBindingRequest.Spec.MasterUserRecord field is not changed by the user.
// The reason for making SpaceBindingRequest.Spec.MasterUserRecord field immutable is that as of now the SpaceBinding resource name is composed as follows: <Space.Name>-checksum(<Space.Name>-<MasterUserRecord.Name>),
// thus changing it will trigger an updated of the SpaceBinding content but the name will still be based on the old MUR name.
// All the webhook configuration is available at member-operator/deploy/webhook/member-operator-webhook.yaml
type SpaceBindingRequestValidator struct {
Client runtimeClient.Client
}
Expand Down

0 comments on commit ea221b3

Please sign in to comment.