Revert changes to get_image and get_sources

Signed-off-by: Somtochi Onyekwere <somtochionyekwere@gmail.com>
pull/1351/head
Somtochi Onyekwere 4 years ago
parent bd34870334
commit c08953be9d

@ -17,8 +17,6 @@ limitations under the License.
package main package main
import ( import (
"strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha2" autov1 "github.com/fluxcd/image-automation-controller/api/v1alpha2"
@ -35,34 +33,28 @@ var getImageAllCmd = &cobra.Command{
# List all image objects in all namespaces # List all image objects in all namespaces
flux get images all --all-namespaces`, flux get images all --all-namespaces`,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
var allImageCmd = []getCommand{
{
apiType: imageRepositoryType,
list: imageRepositoryListAdapter{&imagev1.ImageRepositoryList{}},
},
{
apiType: imagePolicyType,
list: &imagePolicyListAdapter{&imagev1.ImagePolicyList{}},
},
{
apiType: imageUpdateAutomationType,
list: &imageUpdateAutomationListAdapter{&autov1.ImageUpdateAutomationList{}},
},
}
c := getCommand{ c := getCommand{
apiType: imageRepositoryType, apiType: imageRepositoryType,
list: imageRepositoryListAdapter{&imagev1.ImageRepositoryList{}}, list: imageRepositoryListAdapter{&imagev1.ImageRepositoryList{}},
} }
if err := c.run(cmd, args); err != nil { if err := c.run(cmd, args); err != nil {
logger.Failuref(err.Error()) logError(err)
}
c = getCommand{
apiType: imagePolicyType,
list: &imagePolicyListAdapter{&imagev1.ImagePolicyList{}},
}
if err := c.run(cmd, args); err != nil {
logError(err)
} }
for _, c := range allImageCmd { c = getCommand{
if err := c.run(cmd, args); err != nil { apiType: imageUpdateAutomationType,
if !strings.Contains(err.Error(), "no matches for kind") { list: &imageUpdateAutomationListAdapter{&autov1.ImageUpdateAutomationList{}},
logger.Failuref(err.Error()) }
} if err := c.run(cmd, args); err != nil {
} logError(err)
} }
return nil return nil

@ -17,8 +17,6 @@ limitations under the License.
package main package main
import ( import (
"strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
sourcev1 "github.com/fluxcd/source-controller/api/v1beta1" sourcev1 "github.com/fluxcd/source-controller/api/v1beta1"
@ -34,31 +32,36 @@ var getSourceAllCmd = &cobra.Command{
# List all sources in all namespaces # List all sources in all namespaces
flux get sources all --all-namespaces`, flux get sources all --all-namespaces`,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
var allSourceCmd = []getCommand{ c := getCommand{
{ apiType: bucketType,
apiType: bucketType, list: &bucketListAdapter{&sourcev1.BucketList{}},
list: &bucketListAdapter{&sourcev1.BucketList{}}, }
}, if err := c.run(cmd, args); err != nil {
{ logger.Failuref(err.Error())
apiType: gitRepositoryType, }
list: &gitRepositoryListAdapter{&sourcev1.GitRepositoryList{}},
}, c = getCommand{
{ apiType: gitRepositoryType,
apiType: helmRepositoryType, list: &gitRepositoryListAdapter{&sourcev1.GitRepositoryList{}},
list: &helmRepositoryListAdapter{&sourcev1.HelmRepositoryList{}}, }
}, if err := c.run(cmd, args); err != nil {
{ logger.Failuref(err.Error())
apiType: helmChartType,
list: &helmChartListAdapter{&sourcev1.HelmChartList{}},
},
} }
for _, c := range allSourceCmd { c = getCommand{
if err := c.run(cmd, args); err != nil { apiType: helmRepositoryType,
if !strings.Contains(err.Error(), "no matches for kind") { list: &helmRepositoryListAdapter{&sourcev1.HelmRepositoryList{}},
logger.Failuref(err.Error()) }
} if err := c.run(cmd, args); err != nil {
} logger.Failuref(err.Error())
}
c = getCommand{
apiType: helmChartType,
list: &helmChartListAdapter{&sourcev1.HelmChartList{}},
}
if err := c.run(cmd, args); err != nil {
logger.Failuref(err.Error())
} }
return nil return nil

Loading…
Cancel
Save