Skip to content

Commit

Permalink
fix(build): fixes broken apply for builds
Browse files Browse the repository at this point in the history
  • Loading branch information
shiv-mohith authored and ankitrgadiya committed Dec 14, 2022
1 parent e89a1b4 commit a68f7d0
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 24 deletions.
3 changes: 1 addition & 2 deletions jsonschema/build-schema.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
$schema: https://json-schema.org/draft-07/schema
title: Build
$ref: "#/definitions/buildSpec"
$ref: "#/definitions/build"
definitions:
build:
type: object
Expand Down Expand Up @@ -72,7 +72,6 @@ definitions:
required:
- buildMethod
- repository
- image
dependencies:
buildMethod:
oneOf:
Expand Down
6 changes: 3 additions & 3 deletions riocli/apply/manifests/04-build-catkin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ kind: "Build"
metadata:
name: "catkin-build"
spec:
recipe: "Source"
buildMethod: "Source"
architecture: "amd64"
git:
repository: "https://github.com/rapyuta-robotics/io_tutorials"
repository:
url: "https://github.com/rapyuta-robotics/io_tutorials"
# gitRef: "master"
# secret: "secret-guid"
# contextDir: "talker/talker"
Expand Down
6 changes: 3 additions & 3 deletions riocli/apply/manifests/05-build-docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ kind: "Build"
metadata:
name: "docker-build"
spec:
recipe: "Docker"
buildMethod: "Docker"
architecture: "amd64"
git:
repository: "https://github.com/rapyuta-robotics/io_tutorial.git"
repository:
url: "https://github.com/rapyuta-robotics/io_tutorial.git"
# gitRef: "master"
# secret: "secret-guid"
# dockerfile: "Dockerfile"
Expand Down
7 changes: 5 additions & 2 deletions riocli/apply/manifests/06-build-docker-ros.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ metadata:
spec:
recipe: "Docker"
architecture: "amd64"
git:
repository: "https://github.com/rapyuta-robotics/io_tutorial.git"

# gitRef: "master"
# secret: "secret-guid"
# contextDir: "talker/talker"
rosDistro: "melodic"
repository:
url: "https://github.com/rapyuta-robotics/io_tutorials.git"
buildMethod: "Source"

2 changes: 1 addition & 1 deletion riocli/apply/resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _find_functors(self, kind):
"project": self._generate_find_guid_functor(),
"package": lambda name, obj_list, version: filter(lambda x: name == x.name and version == x['packageVersion'], obj_list),
"staticroute": lambda name, obj_list: filter(lambda x: name == '-'.join(x.urlPrefix.split('-')[:-1]), obj_list),
"build": self._generate_find_guid_functor(),
"build": self._generate_find_guid_functor(name_field='buildName'),
"deployment": self._generate_find_guid_functor(),
"network": self._generate_find_guid_functor(),
"disk": self._generate_find_guid_functor(),
Expand Down
18 changes: 10 additions & 8 deletions riocli/build/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def delete_object(self, client: Client, obj: typing.Any) -> typing.Any:

def to_v1(self) -> v1Build:
build_opts = None
if self.spec.recipe == 'Source' and self.spec.get('catkinParameters', None):
if self.spec.buildMethod == 'Source' and self.spec.get('catkinParameters', None):
catkin_opts = []
for each in self.spec.catkinParameters:
catkin_opt = CatkinOption(rosPkgs=each.get('rosPackages', None),
Expand All @@ -56,13 +56,15 @@ def to_v1(self) -> v1Build:
catkin_opts.append(catkin_opt)
build_opts = BuildOptions(catkin_opts)

return v1Build(buildName=self.metadata.name, strategyType=self.spec.recipe, repository=self.spec.git.repository,
architecture=self.spec.architecture, rosDistro=self.spec.get('rosDistro', ''),
isRos=self.spec.get('rosDistro', '') != '', dockerPullSecret=self.spec.get('pullSecret', ''),
contextDir=self.spec.get('contextDir', ''), dockerFilePath=self.spec.get('dockerfile', ''),
dockerPushRepository=self.spec.get('pushSecret', ''), branch=self.spec.git.get('gitRef', ''),
triggerName=self.spec.get('triggerName', ''), tagName=self.spec.get('tagName', ''),
buildOptions=build_opts)
return v1Build(
buildName=self.metadata.name, strategyType=self.spec.buildMethod, repository=self.spec.repository.url,
architecture=self.spec.architecture, rosDistro=self.spec.get('rosDistro', ''),
isRos=self.spec.get('rosDistro', '') != '', dockerPullSecret=self.spec.get('pullSecret', ''),
contextDir=self.spec.get('contextDir', ''), dockerFilePath=self.spec.get('dockerfile', ''),
dockerPushRepository=self.spec.get('pushSecret', ''), branch=self.spec.repository.get('ref', ''),
triggerName=self.spec.get('triggerName', ''), tagName=self.spec.get('tagName', ''),
buildOptions=build_opts
)

@classmethod
def pre_process(cls, client: Client, d: typing.Dict) -> None:
Expand Down
Loading

0 comments on commit a68f7d0

Please sign in to comment.