Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Implement POST /v3/organizations (#119)
Browse files Browse the repository at this point in the history
Introduce the `/v3/spaces` endpoint


Co-authored-by: Kieron Browne <kbrowne@vmware.com>
Co-authored-by: Giuseppe Capizzi <gcapizzi@pivotal.io>
Co-authored-by: Danail Branekov <danailster@gmail.com>
Co-authored-by: Mario Nitchev <marionitchev@gmail.com>
  • Loading branch information
5 people authored Oct 9, 2021
1 parent 198bb2a commit 06156af
Show file tree
Hide file tree
Showing 34 changed files with 1,827 additions and 511 deletions.
28 changes: 24 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ test: fmt vet ## Run tests.
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.8.3/hack/setup-envtest.sh
source ${ENVTEST_ASSETS_DIR}/setup-envtest.sh; fetch_envtest_tools $(ENVTEST_ASSETS_DIR); setup_envtest_env $(ENVTEST_ASSETS_DIR); go test ./... -coverprofile cover.out -shuffle on

test-e2e:
test-e2e: ginkgo
ifndef SKIP_DEPLOY
./scripts/deploy-on-kind.sh e2e
KUBECONFIG="${HOME}/.kube/e2e.yml" API_SERVER_ROOT=http://localhost ROOT_NAMESPACE=cf-k8s-api-system go test -tags e2e -count 1 ./tests/e2e
endif
KUBECONFIG="${HOME}/.kube/e2e.yml" API_SERVER_ROOT=http://localhost ROOT_NAMESPACE=cf-k8s-api-system $(GINKGO) -p -randomizeAllSpecs -randomizeSuites -keepGoing -slowSpecThreshold 30 -tags e2e tests/e2e

run: fmt vet ## Run a controller from your host.
go run ./main.go
Expand Down Expand Up @@ -69,15 +71,33 @@ KUSTOMIZE = $(shell pwd)/bin/kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v4@v4.2.0)

GINKGO = $(shell pwd)/bin/ginkgo
ginkgo:
$(call go-get-tool,$(GINKGO),github.com/onsi/ginkgo/ginkgo@latest)

HNC_VERSION ?= v0.8.0
HNC_PLATFORM=$(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
HNC_BIN=$(shell pwd)/bin
export PATH := $(HNC_BIN):$(PATH)
hnc-install:
mkdir -p "$(HNC_BIN)"
curl -L https://github.com/kubernetes-sigs/multi-tenancy/releases/download/hnc-$(HNC_VERSION)/kubectl-hns_$(HNC_PLATFORM) -o "$(HNC_BIN)/kubectl-hns"
chmod +x "$(HNC_BIN)/kubectl-hns"

kubectl label ns kube-system hnc.x-k8s.io/excluded-namespace=true --overwrite
kubectl label ns kube-public hnc.x-k8s.io/excluded-namespace=true --overwrite
kubectl label ns kube-node-lease hnc.x-k8s.io/excluded-namespace=true --overwrite
kubectl apply -f https://github.com/kubernetes-sigs/multi-tenancy/releases/download/hnc-$(HNC_VERSION)/hnc-manager.yaml
kubectl rollout status deployment/hnc-controller-manager -w -n hnc-system
echo -n waiting for manager to be ready and servicing validating webhooks
until kubectl logs -n hnc-system deployment/hnc-controller-manager manager | grep -q "setup complete"; do echo -n .; sleep 0.5; done
# Hierarchical namespace controller is quite asynchronous. There is no
# guarantee that the operations below would succeed on first invocation,
# so retry until they do.
echo -n waiting for hns controller to be ready and servicing validating webhooks
until kubectl create namespace ping-hnc; do echo -n .; sleep 0.5; done
until kubectl hns create -n ping-hnc ping-hnc-child; do echo -n .; sleep 0.5; done
until kubectl get namespace ping-hnc-child; do echo -n .; sleep 0.5; done
until kubectl hns set --allowCascadingDeletion ping-hnc; do echo -n .; sleep 0.5; done
until kubectl delete namespace ping-hnc --wait=false; do echo -n .; sleep 0.5; done
echo

# go-get-tool will 'go get' any package $2 and install it to $1.
Expand Down
11 changes: 9 additions & 2 deletions apis/app_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"net/http"
"net/url"

"code.cloudfoundry.org/cf-k8s-controllers/webhooks/workloads"

Expand Down Expand Up @@ -42,14 +43,20 @@ type CFAppRepository interface {

type AppHandler struct {
logger logr.Logger
serverURL string
serverURL url.URL
appRepo CFAppRepository
dropletRepo CFDropletRepository
buildClient ClientBuilder
k8sConfig *rest.Config // TODO: this would be global for all requests, not what we want
}

func NewAppHandler(logger logr.Logger, serverURL string, appRepo CFAppRepository, dropletRepo CFDropletRepository, buildClient ClientBuilder, k8sConfig *rest.Config) *AppHandler {
func NewAppHandler(
logger logr.Logger,
serverURL url.URL,
appRepo CFAppRepository,
dropletRepo CFDropletRepository,
buildClient ClientBuilder,
k8sConfig *rest.Config) *AppHandler {
return &AppHandler{
logger: logger,
serverURL: serverURL,
Expand Down
Loading

0 comments on commit 06156af

Please sign in to comment.