Skip to content

Commit

Permalink
Pass name to shp for create build and create buildrun
Browse files Browse the repository at this point in the history
  • Loading branch information
akram committed Sep 28, 2021
1 parent 4d81503 commit e3e8297
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 3 deletions.
7 changes: 6 additions & 1 deletion pkg/shp/cmd/build/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,12 @@ func (c *CreateCommand) Validate() error {

// Run executes the creation of a new Build instance using flags to fill up the details.
func (c *CreateCommand) Run(params *params.Params, io *genericclioptions.IOStreams) error {
b := &buildv1alpha1.Build{Spec: *c.buildSpec}
b := &buildv1alpha1.Build{
ObjectMeta: metav1.ObjectMeta{
Name: c.name,
},
Spec: *c.buildSpec,
}
flags.SanitizeBuildSpec(&b.Spec)

clientset, err := params.ShipwrightClientSet()
Expand Down
7 changes: 6 additions & 1 deletion pkg/shp/cmd/buildrun/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ func (c *CreateCommand) Validate() error {

// Run executes the creation of BuildRun object.
func (c *CreateCommand) Run(params *params.Params, ioStreams *genericclioptions.IOStreams) error {
br := &buildv1alpha1.BuildRun{Spec: *c.buildRunSpec}
br := &buildv1alpha1.BuildRun{
ObjectMeta: metav1.ObjectMeta{
Name: c.name,
},
Spec: *c.buildRunSpec,
}
flags.SanitizeBuildRunSpec(&br.Spec)

clientset, err := params.ShipwrightClientSet()
Expand Down
18 changes: 18 additions & 0 deletions test/e2e/e2e.bats
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,21 @@ source test/e2e/helpers.sh
result="$(shp --help)"
[ ! -z "$result" ]
}

@test "shp build create succesfully run with 1 argument" {
build_name=$(random_name)
result="$(shp build create ${build_name} --source-url=url --output-image=image)"
[ ! -z "$result" ]
result=$(kubectl get build.shipwright.io ${build_name})
[ ! -z "$result" ]
}

@test "shp buildrun create succesfully run with 1 argument" {
build_name=$(random_name)
result="$(shp build create ${build_name} --source-url=url --output-image=image)"
[ ! -z "$result" ]
buildrun_name=$(random_name)
result="$(shp buildrun create ${buildrun_name} --buildref-name={$build_name})"
result=$(kubectl get buildrun.shipwright.io ${buildrun_name})
[ ! -z "$result" ]
}
7 changes: 6 additions & 1 deletion test/e2e/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ function shp () {
fi

${BIN} ${*}
}
}

function random_name () {
tr -dc a-z </dev/urandom | head -c64
}

0 comments on commit e3e8297

Please sign in to comment.