Skip to content

Commit

Permalink
fixup: remove unnecessary code per review request
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Vasek <[email protected]>
  • Loading branch information
matejvasek committed Aug 9, 2023
1 parent 755fa2e commit e1c9f49
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
6 changes: 1 addition & 5 deletions pkg/pipelines/tekton/pipelines_pac_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,10 @@ func (pp *PipelinesProvider) ConfigurePAC(ctx context.Context, f fn.Function, me
return fmt.Errorf("incorrect type of pipelines metadata: %T", metadata)
}

var warningMsg string
var err error
if warningMsg, err = validatePipeline(f); err != nil {
if err = validatePipeline(f); err != nil {
return err
}
if warningMsg != "" {
pp.progressListener.Increment(warningMsg)
}

if data.ConfigureLocalResources {
if err := pp.createLocalPACResources(ctx, f); err != nil {
Expand Down
6 changes: 1 addition & 5 deletions pkg/pipelines/tekton/pipelines_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,10 @@ func NewPipelinesProvider(opts ...Opt) *PipelinesProvider {
// After the PipelineRun is being initialized, the progress of the PipelineRun is being watched and printed to the output.
func (pp *PipelinesProvider) Run(ctx context.Context, f fn.Function) error {
pp.progressListener.Increment("Creating Pipeline resources")
var warningMsg string
var err error
if warningMsg, err = validatePipeline(f); err != nil {
if err = validatePipeline(f); err != nil {
return err
}
if warningMsg != "" {
pp.progressListener.Increment(warningMsg)
}

client, namespace, err := NewTektonClientAndResolvedNamespace(pp.namespace)
if err != nil {
Expand Down
13 changes: 6 additions & 7 deletions pkg/pipelines/tekton/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,21 @@ func (e ErrRuntimeNotSupported) Error() string {
return fmt.Sprintf("runtime %q is not supported for on cluster build with default builders", e.Runtime)
}

func validatePipeline(f fn.Function) (string, error) {
var warningMsg string
func validatePipeline(f fn.Function) error {
if f.Build.Builder == builders.Pack {
if f.Runtime == "" {
return "", ErrRuntimeRequired
return ErrRuntimeRequired
}

if len(f.Build.Buildpacks) > 0 {
return "", ErrBuilpacksNotSupported
return ErrBuilpacksNotSupported
}
} else if f.Build.Builder == builders.S2I {
_, err := s2i.BuilderImage(f, builders.S2I)
return "", err
return err
} else {
return "", builders.ErrUnknownBuilder{Name: f.Build.Builder}
return builders.ErrUnknownBuilder{Name: f.Build.Builder}
}

return warningMsg, nil
return nil
}

0 comments on commit e1c9f49

Please sign in to comment.