Repository: openshift-pipelines/pipelines-as-code
Pull request #164 (2021-06-29 12:17:24)

Rename cronjobs to beta1 type to be compatible with openshift 4.7
Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>



Patch:
diff --git a/cmd/tkn-pac/main.go b/cmd/tkn-pac/main.go
index 028e9d08..1c93039b 100644
--- a/cmd/tkn-pac/main.go
+++ b/cmd/tkn-pac/main.go
@@ -4,7 +4,7 @@ import (
 	"os"
 
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/cli"
-	"github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/completion"
+	"github.com/openshift-pipelines/pipelines-as-code/pkg/cli/completion"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/repository"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/resolve"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/flags"
diff --git a/config/305-cleanup-cron.yaml b/config/305-cleanup-cron.yaml
index 47012918..38633bd1 100644
--- a/config/305-cleanup-cron.yaml
+++ b/config/305-cleanup-cron.yaml
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-apiVersion: batch/v1
+apiVersion: batch/v1beta1
 kind: CronJob
 metadata:
   name: pipelines-as-code-pr-cleanup
diff --git a/pkg/cmd/completion/cmd.go b/pkg/cli/completion/cmd.go
similarity index 90%
rename from pkg/cmd/completion/cmd.go
rename to pkg/cli/completion/cmd.go
index a5c207b8..98c2aa7c 100644
--- a/pkg/cmd/completion/cmd.go
+++ b/pkg/cli/completion/cmd.go
@@ -15,6 +15,8 @@
 package completion
 
 import (
+	"os"
+
 	"github.com/spf13/cobra"
 )
 
@@ -76,13 +78,13 @@ func Command() *cobra.Command {
 		RunE: func(cmd *cobra.Command, args []string) error {
 			switch args[0] {
 			case "bash":
-				_ = cmd.Root().GenBashCompletion(cmd.OutOrStdout())
+				_ = cmd.Root().GenBashCompletion(os.Stdout)
 			case "zsh":
-				_ = cmd.Root().GenZshCompletion(cmd.OutOrStdout())
+				_ = cmd.Root().GenZshCompletion(os.Stdout)
 			case "fish":
-				_ = cmd.Root().GenFishCompletion(cmd.OutOrStdout(), true)
+				_ = cmd.Root().GenFishCompletion(os.Stdout, true)
 			case "powershell":
-				_ = cmd.Root().GenPowerShellCompletion(cmd.OutOrStdout())
+				_ = cmd.Root().GenPowerShellCompletion(os.Stdout)
 			}
 
 			return nil
diff --git a/pkg/cmd/repository/describe.go b/pkg/cmd/repository/describe.go
index cd37e881..88b69028 100644
--- a/pkg/cmd/repository/describe.go
+++ b/pkg/cmd/repository/describe.go
@@ -11,8 +11,8 @@ import (
 	"github.com/jonboulle/clockwork"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/apis/pipelinesascode/v1alpha1"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/cli"
+	"github.com/openshift-pipelines/pipelines-as-code/pkg/cli/completion"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/cli/ui"
-	"github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/completion"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/flags"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/pipelineascode"
 	"github.com/spf13/cobra"
diff --git a/pkg/cmd/repository/list.go b/pkg/cmd/repository/list.go
index 8c4cbe7e..e0beda58 100644
--- a/pkg/cmd/repository/list.go
+++ b/pkg/cmd/repository/list.go
@@ -6,8 +6,8 @@ import (
 	"text/tabwriter"
 
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/cli"
+	"github.com/openshift-pipelines/pipelines-as-code/pkg/cli/completion"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/cli/ui"
-	"github.com/openshift-pipelines/pipelines-as-code/pkg/cmd/completion"
 	"github.com/openshift-pipelines/pipelines-as-code/pkg/flags"
 	"github.com/spf13/cobra"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"


Test patch:
diff --git a/pkg/cmd/completion/completion.go b/pkg/cli/completion/completion.go
similarity index 100%
rename from pkg/cmd/completion/completion.go
rename to pkg/cli/completion/completion.go
diff --git a/pkg/cmd/completion/cmd_test.go b/pkg/cmd/completion/cmd_test.go
deleted file mode 100644
index dd27e149..00000000
--- a/pkg/cmd/completion/cmd_test.go
+++ /dev/null
@@ -1,36 +0,0 @@
-package completion
-
-import (
-	"strings"
-	"testing"
-
-	"github.com/openshift-pipelines/pipelines-as-code/pkg/test/cli"
-	"gotest.tools/v3/assert"
-)
-
-func TestCommand(t *testing.T) {
-	tests := []struct {
-		name string
-	}{
-		{
-			name: "zsh",
-		},
-		{
-			name: "bash",
-		},
-		{
-			name: "fish",
-		},
-		{
-			name: "powershell",
-		},
-	}
-	for _, tt := range tests {
-		t.Run(tt.name+" completion", func(t *testing.T) {
-			got, err := cli.ExecuteCommand(Command(), tt.name)
-			assert.NilError(t, err)
-
-			assert.Assert(t, strings.Contains(got, tt.name+" completion"))
-		})
-	}
-}
diff --git a/pkg/test/cli/cobra.go b/pkg/test/cli/cobra.go
deleted file mode 100644
index c176f3b9..00000000
--- a/pkg/test/cli/cobra.go
+++ /dev/null
@@ -1,27 +0,0 @@
-package cli
-
-import (
-	"bytes"
-
-	"github.com/spf13/cobra"
-)
-
-// ExecuteCommand executes the root command passing the args and returns
-// the output as a string and error
-func ExecuteCommand(root *cobra.Command, args ...string) (string, error) {
-	_, output, err := ExecuteCommandC(root, args...)
-	return output, err
-}
-
-// ExecuteCommandC executes the root command passing the args and returns
-// the root command, output as a string and error if any
-func ExecuteCommandC(c *cobra.Command, args ...string) (*cobra.Command, string, error) {
-	buf := new(bytes.Buffer)
-	c.SetOutput(buf)
-	c.SetArgs(args)
-	c.SilenceUsage = true
-
-	root, err := c.ExecuteC()
-
-	return root, buf.String(), err
-}