Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add comments and resolving lint errors #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/ci-firewall/cli/genericclioptions/runnable.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func GenericRun(o Runnable, cmd *cobra.Command, args []string) {
LogErrorAndExit(o.Run(), "")
}

//AddStripANSIColorFlag remove ANSI color form log
func AddStripANSIColorFlag(cmd *cobra.Command, v *bool) {
cmd.Flags().BoolVar(v, "stripansicolor", false, "If true, then ANSI color will be stripped before printing the logs")
}
9 changes: 6 additions & 3 deletions pkg/requestor/requestor.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func NewRequestor(amqpURI, sendqName, exchangeName, topic, repoURL, kind, target
return r
}

//initQueues initializes rabbitmq queues for PR, Branch or Tag. Returns error if fails
func (r *Requestor) initQueus() error {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a typo in the function name

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will address this typo in my next commit, Thanks for letting me know.

if r.kind != messages.RequestTypePR && r.kind != messages.RequestTypeBranch && r.kind != messages.RequestTypeTag {
return fmt.Errorf("kind should be %s, %s or %s", messages.RequestTypePR, messages.RequestTypeBranch, messages.RequestTypeTag)
Expand All @@ -57,15 +58,16 @@ func (r *Requestor) initQueus() error {
return nil
}

//sendBuildRequest creates build request. Returns error if fails
func (r *Requestor) sendBuildRequest() error {
var err error
err = r.sendq.Publish(messages.NewRemoteBuildRequestMessage(r.repoURL, r.kind, r.target, r.setupScript, r.runscript, r.recieveQueueName, r.runScriptURL, r.mainBranch))
var err error = r.sendq.Publish(messages.NewRemoteBuildRequestMessage(r.repoURL, r.kind, r.target, r.setupScript, r.runscript, r.recieveQueueName, r.runScriptURL, r.mainBranch))
if err != nil {
return fmt.Errorf("failed to send build request %w", err)
}
return nil
}

// consumeMessages send ack for finished work on a delivery(i.e. - successfull execution of request from rcvq), and returns error if fails
func (r *Requestor) consumeMessages() error {
err := r.rcvq.Consume(func(deliveries <-chan amqp.Delivery, done chan error) {
success := true
Expand Down Expand Up @@ -107,7 +109,7 @@ func (r *Requestor) consumeMessages() error {
if success {
done <- nil
} else {
done <- fmt.Errorf("Failed the test, see logs above ^")
done <- fmt.Errorf("failed the test, see logs above ^")
}
return
}
Expand Down Expand Up @@ -141,6 +143,7 @@ func (r *Requestor) Done() chan error {
return r.done
}

//Shutdown shuts down the requestor and worker , returns error if any
func (r *Requestor) ShutDown() error {
err := r.sendq.Shutdown()
if err != nil {
Expand Down