Skip to content

Commit c202dab

Browse files
committed
add deployment name change based on flag, fix minor makefile issues
1 parent 8b32e95 commit c202dab

File tree

5 files changed

+15
-11
lines changed

5 files changed

+15
-11
lines changed

components/buildless-serverless/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,18 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
139139
rm Dockerfile.cross
140140

141141
build-image: ## Build buildless serverless backend image
142-
docker build -t $(APP_NAME) -f Dockerfile .
142+
docker build -t $(APP_NAME) -f Dockerfile ../..
143143

144144
######## disable operator to prevent undo of local image update to k3d
145145
disable-operator:
146-
$(KUBECTL) scale deployment serverless-operator -n kyma-system --replicas=0
146+
$(KUBECTL) scale deployment serverless-operator -n kyma-system --replicas=0 || true
147147

148148
.PHONY: install-buildless
149-
install-buildless: build-image disable-operator## Build buildless serverless image and install it on local k3d cluster
149+
install-buildless: build-image disable-operator ## Build buildless serverless image and install it on local k3d cluster
150150
$(eval HASH_TAG=$(shell docker images $(APP_NAME):latest --quiet))
151151
docker tag $(APP_NAME) $(APP_NAME):$(HASH_TAG)
152152

153-
k3d image import $(APP_NAME):$(HASH_TAG) -c kyma
153+
k3d image import $(APP_NAME):$(HASH_TAG)
154154
$(KUBECTL) set image deployment -n kyma-system serverless-ctrl-mngr manager=$(APP_NAME):$(HASH_TAG)
155155
##@ Deployment
156156

components/buildless-serverless/internal/endpoint/function.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
func (s *Server) handleFunctionRequest(w http.ResponseWriter, r *http.Request) {
1313
ns := r.URL.Query().Get("namespace")
1414
name := r.URL.Query().Get("name")
15-
appName := r.URL.Query().Get("appName")
15+
appName := r.URL.Query().Get("targetAppName")
1616

1717
s.log.Infof("handling function request for function '%s/%s'", ns, name)
1818

components/buildless-serverless/internal/endpoint/runtime/resources.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func BuildResources(functionConfig *config.FunctionConfig, f *v1alpha2.Function,
1919
return nil, errors.Wrapf(err, "failed to build service")
2020
}
2121

22-
deployment, err := buildDeploymentFileData(functionConfig, f)
22+
deployment, err := buildDeploymentFileData(functionConfig, f, appName)
2323
if err != nil {
2424
return nil, errors.Wrapf(err, "failed to build deployment")
2525
}
@@ -53,13 +53,17 @@ func buildServiceFileData(function *v1alpha2.Function, appName string) ([]byte,
5353
return data, nil
5454
}
5555

56-
func buildDeploymentFileData(functionConfig *config.FunctionConfig, function *v1alpha2.Function) ([]byte, error) {
56+
func buildDeploymentFileData(functionConfig *config.FunctionConfig, function *v1alpha2.Function, appName string) ([]byte, error) {
5757
if function.HasGitSources() {
5858
// TODO: support git source
5959
return nil, errors.New("ejecting functions with git source is not supported")
6060
}
6161

62-
deployName := fmt.Sprintf("%s-ejected", function.Name)
62+
deployName := appName
63+
if deployName == "" {
64+
deployName = fmt.Sprintf("%s-ejected", function.Name)
65+
}
66+
6367
deploy := resources.NewDeployment(
6468
function,
6569
functionConfig,

components/buildless-serverless/internal/endpoint/runtime/resources_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestBuildResources(t *testing.T) {
2626
Name: "test-function",
2727
Namespace: "test-namespace",
2828
},
29-
})
29+
}, "")
3030

3131
require.NoError(t, err)
3232
require.Len(t, files, 2)
@@ -48,7 +48,7 @@ func TestBuildResources(t *testing.T) {
4848
Name: "test-function",
4949
Namespace: "test-namespace",
5050
},
51-
})
51+
}, "")
5252

5353
require.ErrorContains(t, err, "ejecting functions with git source is not supported")
5454
require.Nil(t, files)

config/buildless-serverless/files/kyma-commands.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ subCommands:
7474
parameters:
7575
name: ${{ .args.value }}
7676
namespace: ${{ .flags.namespace.value }}
77-
app-name: ${{ .flags.targetappname.value}}
77+
targetAppName: ${{ .flags.targetappname.value}}
7878
targetPod:
7979
path: "/internal/function/eject/"
8080
port: "12137"

0 commit comments

Comments
 (0)