IMAGE_NAME ?= quay.io/pfeifferj/neoche
IMAGE_TAG ?= insiders
DOCKERFILE := build/dockerfiles/assembly.Dockerfile
CHE_NAMESPACE ?= openshift-devspaces

.PHONY: build push deploy-editor test-standalone test-che clean test

build:
	podman build -f $(DOCKERFILE) -t $(IMAGE_NAME):$(IMAGE_TAG) .

push:
	podman push $(IMAGE_NAME):$(IMAGE_TAG)

deploy-editor:
	-oc delete configmap neovim-editor-definition -n $(CHE_NAMESPACE) 2>/dev/null
	oc create configmap neovim-editor-definition \
		--from-file=editor-definition.yaml \
		-n $(CHE_NAMESPACE)
	oc label configmap neovim-editor-definition \
		app.kubernetes.io/part-of=che.eclipse.org \
		app.kubernetes.io/component=editor-definition \
		-n $(CHE_NAMESPACE)

test-standalone:
	podman run --rm -p 7681:7681 $(IMAGE_NAME):$(IMAGE_TAG)

test-che:
	@echo "Launch a workspace with this editor by appending to your Dev Spaces URL:"
	@echo "  ?che-editor=neoche/neovim/insiders"

clean:
	-podman rmi $(IMAGE_NAME):$(IMAGE_TAG)

test:
	bats tests/
