Skip to content

Commit

Permalink
cleanup unnecessary code and addresses comments
Browse files Browse the repository at this point in the history
Signed-off-by: Shivam Mukhade <smukhade@redhat.com>
  • Loading branch information
Shivam Mukhade committed Jun 9, 2022
1 parent 1675b81 commit 9e3d776
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Pipelines as Code -- An opinionated CI based on OpenShift Pipelines / Tekton.

Full documentation for the stable version is available from <https://pipelinesascode.com>
Documentation for the developement branch is available [here](https://nightly.pipelines-as-code.pages.dev/)
Documentation for the developement branch is available [here](https://nightly.pipelines-as-code.pages.dev/)

## Introduction

Expand Down
12 changes: 5 additions & 7 deletions pkg/cli/webhook/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/openshift-pipelines/pipelines-as-code/pkg/cli"
"github.com/openshift-pipelines/pipelines-as-code/pkg/cli/prompt"
"github.com/openshift-pipelines/pipelines-as-code/pkg/formatting"
"github.com/openshift-pipelines/pipelines-as-code/pkg/provider"
"golang.org/x/oauth2"
)

Expand All @@ -29,10 +28,6 @@ type gitHubConfig struct {
APIURL string
}

func (gh *gitHubConfig) GetName() string {
return provider.ProviderGitHubWebhook
}

func (gh *gitHubConfig) Run(ctx context.Context, opts *Options) (*response, error) {
err := gh.askGHWebhookConfig(opts.RepositoryURL, opts.ControllerURL, opts.ProviderAPIURL)
if err != nil {
Expand All @@ -58,7 +53,10 @@ func (gh *gitHubConfig) askGHWebhookConfig(repoURL, controllerURL, apiURL string
fmt.Fprintf(gh.IOStream.Out, "✓ Setting up GitHub Webhook for Repository %s\n", repoURL)
}

defaultRepo, _ := formatting.GetRepoOwnerFromURL(repoURL)
defaultRepo, err := formatting.GetRepoOwnerFromURL(repoURL)
if err != nil {
return err
}

repoArr := strings.Split(defaultRepo, "/")
if len(repoArr) != 2 {
Expand Down Expand Up @@ -108,7 +106,7 @@ func (gh *gitHubConfig) askGHWebhookConfig(repoURL, controllerURL, apiURL string
return err
}

if apiURL == "" && !strings.Contains(repoURL, "https://github.com") {
if apiURL == "" && !strings.HasPrefix(repoURL, "https://github.com") {
if err := prompt.SurveyAskOne(&survey.Input{
Message: "Please enter your GitHub enterprise API URL:: ",
}, &gh.APIURL, survey.WithValidator(survey.Required)); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/cli/webhook/github_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func TestAskGHWebhookConfig(t *testing.T) {
askStubs: func(as *prompt.AskStubber) {
as.StubOne("invalid-repo")
},
wantErrStr: "invalid repository, needs to be of format 'org-name/repo-name'",
wantErrStr: "invalid repo url at least a organization/project and a repo needs to be specified: invalid-repo",
},
{
name: "ask all details no defaults",
Expand Down
5 changes: 2 additions & 3 deletions pkg/cli/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type ProviderType string
const ProviderTypeGitHub ProviderType = "GitHub"

type Interface interface {
GetName() string
Run(context.Context, *Options) (*response, error)
}

Expand Down Expand Up @@ -88,8 +87,8 @@ func (w *Options) Install(ctx context.Context, providerType ProviderType) error
return err
}
if !createRepo {
fmt.Fprintln(w.IOStreams.Out, "✓ Skips creating Repository CR")
fmt.Fprintln(w.IOStreams.Out, "💡 Don't forget to create a secret with webhook secret and provider token & attaching in Repository CR.")
fmt.Fprintln(w.IOStreams.Out, "✓ Skipping Repository creation")
fmt.Fprintln(w.IOStreams.Out, "💡 Don't forget to create a secret with webhook secret and provider token & attaching in Repository.")
return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/tknpac/create/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func repositoryCommand(run *params.Run, ioStreams *cli.IOStreams) *cobra.Command
return err
}

fmt.Fprintln(ioStreams.Out, "🚀 You can use \"tkn pac setup\" command to setup a webhook with your repository")
fmt.Fprintln(ioStreams.Out, "🚀 You can use the command \"tkn pac setup\" to setup a repository with webhook")
return nil
},
Annotations: map[string]string{
Expand Down

0 comments on commit 9e3d776

Please sign in to comment.