Skip to content

Commit 662aca5

Browse files
committedNov 14, 2019
Add directory check to ensure the directory exists
Signed-off-by: Vu Dinh <[email protected]>
1 parent 2a23c3b commit 662aca5

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed
 

‎docs/design/operator-bundle.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ The `--package` or `-p` is the name of package fo the operator such as `etcd` wh
159159

160160
All information in `annotations.yaml` is also existed in `LABEL` section of `Dockerfile`.
161161

162-
The `Dockerfile` can used to manually build bundle image using container image tools such as Docker, Podman or Buildah. For example, the Docker build command would be:
162+
The `Dockerfile` can be used manually to build the bundle image using container image tools such as Docker, Podman or Buildah. For example, the Docker build command would be:
163163

164164
```bash
165165
$ docker build -f /path/to/Dockerfile -t quay.io/test/test-operator:latest /path/to/manifests/

‎pkg/lib/bundle/build.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,13 @@ func ExecuteCommand(cmd *exec.Cmd) error {
5454
// @channelDefault: The default channel for the bundle image
5555
// @overwrite: Boolean flag to enable overwriting annotations.yaml locally if existed
5656
func BuildFunc(directory, imageTag, imageBuilder, packageName, channels, channelDefault string, overwrite bool) error {
57+
_, err := os.Stat(directory)
58+
if os.IsNotExist(err) {
59+
return err
60+
}
61+
5762
// Generate annotations.yaml and Dockerfile
58-
err := GenerateFunc(directory, packageName, channels, channelDefault, overwrite)
63+
err = GenerateFunc(directory, packageName, channels, channelDefault, overwrite)
5964
if err != nil {
6065
return err
6166
}

‎pkg/lib/bundle/generate.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,10 @@ type AnnotationMetadata struct {
4343
// @channelDefault: The default channel for the bundle image
4444
// @overwrite: Boolean flag to enable overwriting annotations.yaml locally if existed
4545
func GenerateFunc(directory, packageName, channels, channelDefault string, overwrite bool) error {
46-
var mediaType string
46+
_, err := os.Stat(directory)
47+
if os.IsNotExist(err) {
48+
return err
49+
}
4750

4851
// Determine mediaType
4952
mediaType, err := GetMediaType(directory)

0 commit comments

Comments
 (0)
Please sign in to comment.