Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure a Deploy command is present in the Devfile before auto-applying components #7093

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ func (o *DeployClient) Deploy(ctx context.Context) error {
path = filepath.Dir(devfilePath)
)

_, err := libdevfile.ValidateAndGetCommand(*devfileObj, "", v1alpha2.DeployCommandGroupKind)
if err != nil {
return err
}

handler := component.NewRunHandler(
ctx,
o.kubeClient,
Expand All @@ -52,7 +57,7 @@ func (o *DeployClient) Deploy(ctx context.Context) error {
},
)

err := o.buildPushAutoImageComponents(handler, *devfileObj)
err = o.buildPushAutoImageComponents(handler, *devfileObj)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
commands:
- exec:
commandLine: npm install
component: runtime
group:
isDefault: true
kind: build
workingDir: ${PROJECT_SOURCE}
id: build
- exec:
commandLine: npm run start
component: runtime
group:
isDefault: true
kind: run
workingDir: ${PROJECT_SOURCE}
id: start-app
- exec:
commandLine: npm run debug
component: runtime
group:
isDefault: true
kind: debug
workingDir: ${PROJECT_SOURCE}
id: start-app-debug

components:
- container:
command: [ 'tail' ]
args: [ '-f', '/dev/null' ]
endpoints:
- name: "3000-tcp"
targetPort: 3000
- name: "debug"
targetPort: 5858
exposure: none
env:
- name: DEBUG_PORT_PROJECT
value: "5858"
image: registry.access.redhat.com/ubi8/nodejs-12:1-36
memoryLimit: 1024Mi
mountSources: true
name: runtime

#######################
# Kubernetes components
#######################

# deployByDefault true, not referenced in apply command => automatically created on startup
- kubernetes:
deployByDefault: true
inlined: |
apiVersion: v1
kind: Pod
metadata:
name: k8s-deploybydefault-true-and-not-referenced
spec:
containers:
- name: main
image: busybox
command: ["/bin/sh", "-ec", "while :; do echo '.'; sleep 5 ; done"]
name: k8s-deploybydefault-true-and-not-referenced

# deployByDefault not set, not referenced in apply command => automatically created on startup
- kubernetes:
inlined: |
apiVersion: v1
kind: Pod
metadata:
name: k8s-deploybydefault-not-set-and-not-referenced
spec:
containers:
- name: main
image: busybox
command: ["/bin/sh", "-ec", "while :; do echo '.'; sleep 5 ; done"]
name: k8s-deploybydefault-not-set-and-not-referenced

#######################
# OpenShift components
#######################

# deployByDefault true, not referenced in apply command => automatically created on startup
- openshift:
deployByDefault: true
inlined: |
apiVersion: v1
kind: Pod
metadata:
name: ocp-deploybydefault-true-and-not-referenced
spec:
containers:
- name: main
image: busybox
command: ["/bin/sh", "-ec", "while :; do echo '.'; sleep 5 ; done"]
name: ocp-deploybydefault-true-and-not-referenced

# deployByDefault not set, not referenced in apply command => automatically created on startup
- openshift:
inlined: |
apiVersion: v1
kind: Pod
metadata:
name: ocp-deploybydefault-not-set-and-not-referenced
spec:
containers:
- name: main
image: busybox
command: ["/bin/sh", "-ec", "while :; do echo '.'; sleep 5 ; done"]
name: ocp-deploybydefault-not-set-and-not-referenced

#######################
# Image components
#######################

# autoBuild true, not referenced in apply command => automatically created on startup
- image:
autoBuild: true
dockerfile:
buildContext: .
uri: Dockerfile
imageName: "{{ CONTAINER_IMAGE_REPO }}:autobuild-true-and-not-referenced"
name: autobuild-true-and-not-referenced

# autoBuild not set, not referenced in apply command => automatically created on startup
- image:
dockerfile:
buildContext: .
uri: Dockerfile
imageName: "{{ CONTAINER_IMAGE_REPO }}:autobuild-not-set-and-not-referenced"
name: autobuild-not-set-and-not-referenced

metadata:
description: Stack with Node.js 14
displayName: Node.js Runtime
icon: https://nodejs.org/static/images/logos/nodejs-new-pantone-black.svg
language: javascript
name: my-node-app
projectType: nodejs
tags:
- NodeJS
- Express
- ubi8
version: 1.0.0
schemaVersion: 2.2.0
starterProjects:
- git:
remotes:
origin: https://github.com/odo-devfiles/nodejs-ex.git
name: nodejs-starter
variables:
CONTAINER_IMAGE_REPO: localhost:5000/odo-dev/node
Loading