@@ -9,8 +9,30 @@ The Devfile Parser library is a Golang module that:
9
9
4 . defines util functions for the devfile.
10
10
11
11
The function documentation can be accessed via [ pkg.go.dev] ( https://pkg.go.dev/github.com/devfile/library ) .
12
- 1 . To parse a devfile, visit pkg/devfile/parse.go
13
- 2 . To get the Kubernetes structs from the devfile, visit pkg/devfile/generator/generators.go
12
+ 1 . To parse a devfile, visit pkg/devfile/parse.go
13
+ ```
14
+ // Parses the devfile and validates the devfile data
15
+ devfile, err := devfilePkg.ParseAndValidate(devfileLocation)
16
+
17
+ // To get all the components from the devfile
18
+ components, err := devfile.Data.GetComponents(DevfileOptions{})
19
+ ```
20
+ 2. To get the Kubernetes objects from the devfile, visit pkg/devfile/generator/generators.go
21
+ ```
22
+ // To get a slice of Kubernetes containers of type corev1.Container from the devfile component containers
23
+ containers, err := generator.GetContainers(devfile)
24
+
25
+ // To generate a Kubernetes deployment of type v1.Deployment
26
+ deployParams := generator.DeploymentParams{
27
+ TypeMeta: generator.GetTypeMeta(deploymentKind, deploymentAPIVersion),
28
+ ObjectMeta: generator.GetObjectMeta(name, namespace, labels, annotations),
29
+ InitContainers: initContainers,
30
+ Containers: containers,
31
+ Volumes: volumes,
32
+ PodSelectorLabels: labels,
33
+ }
34
+ deployment := generator.GetDeployment(deployParams)
35
+ ```
14
36
15
37
## Usage
16
38
0 commit comments