Skip to content

Commit

Permalink
Adding deprecation warning for git based registries
Browse files Browse the repository at this point in the history
Signed-off-by: Mohammed Zeeshan Ahmed <mohammed.zee1000@gmail.com>
  • Loading branch information
mohammedzee1000 committed May 10, 2021
1 parent 1af1a1a commit d0aaa10
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 4 deletions.
9 changes: 9 additions & 0 deletions docs/public/git-registry-deprecation.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
= Deprecation of git based Registries

As we now have OCI based registries for devfiles, git based registries are being #deprecated#.

You are hereby advised to move to OCI based registry at the earliest as support for git based will be dropped in future releases.

OCI based registries can be setup on any kubernetes cluster using https://github.com/devfile/registry-operator[devfile registry operator].

An example of a devfile registry can be seen in the new https://registry.devfile.io[default devfile registry].
1 change: 1 addition & 0 deletions pkg/catalog/catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -643,3 +643,4 @@ func getAllNonHiddenTags(allTags []string, hiddenTags []string) []string {
}
return result
}

8 changes: 8 additions & 0 deletions pkg/log/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,14 @@ func Swarningf(format string, a ...interface{}) string {
return fmt.Sprintf(" %s%s%s", yellow(getWarningString()), suffixSpacing, fmt.Sprintf(format, a...))
}

func Deprecate(what, nextAction string) {
yellow := color.New(color.FgYellow).SprintFunc()
if !IsJSON() {
msg1 := fmt.Sprintf("%s%s%s%s%s", yellow(getWarningString()), suffixSpacing, yellow(fmt.Sprintf("%s Deprecated", what)), suffixSpacing, nextAction)
fmt.Fprintf(GetStderr(), " %s\n", msg1)
}
}

// Experimental will output in an appropriate "progress" manner
func Experimental(a ...interface{}) {
yellow := color.New(color.FgYellow).SprintFunc()
Expand Down
5 changes: 4 additions & 1 deletion pkg/odo/cli/component/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,10 @@ func (co *CreateOptions) Complete(name string, cmd *cobra.Command, args []string

if co.devfileMetadata.devfileSupport && !co.forceS2i {
registrySpinner := log.Spinnerf("Creating a devfile component from registry: %s", co.devfileMetadata.devfileRegistry.Name)

// warn user of deprecation if registry is git based
if registryUtil.IsGitBasedRegistry(co.devfileMetadata.devfileRegistry.URL) {
registryUtil.PrintGitRegistryDeprecationWarning()
}
// Initialize envinfo
err = co.InitEnvInfoFromContext()
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion pkg/odo/cli/registry/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package registry
import (
// Built-in packages
"fmt"
util2 "github.com/openshift/odo/pkg/odo/cli/registry/util"

// Third-party packages
"github.com/pkg/errors"
Expand Down Expand Up @@ -60,7 +61,9 @@ func (o *AddOptions) Validate() (err error) {
if err != nil {
return err
}

if util2.IsGitBasedRegistry(o.registryURL) {
util2.PrintGitRegistryDeprecationWarning()
}
return
}

Expand Down
12 changes: 11 additions & 1 deletion pkg/odo/cli/registry/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package registry
import (
// Built-in packages
"fmt"
util2 "github.com/openshift/odo/pkg/odo/cli/registry/util"
"io"
"os"
"text/tabwriter"
Expand Down Expand Up @@ -32,11 +33,14 @@ var (

// ListOptions encapsulates the options for "odo registry list" command
type ListOptions struct {
printGitRegistryDeprecationWarning bool
}

// NewListOptions creates a new ListOptions instance
func NewListOptions() *ListOptions {
return &ListOptions{}
return &ListOptions{
printGitRegistryDeprecationWarning: false,
}
}

// Complete completes ListOptions after they've been created
Expand Down Expand Up @@ -70,6 +74,9 @@ func (o *ListOptions) Run() (err error) {
fmt.Fprintln(w, "NAME", "\t", "URL", "\t", "SECURE")
o.printRegistryList(w, registryList)
w.Flush()
if o.printGitRegistryDeprecationWarning {
util2.PrintGitRegistryDeprecationWarning()
}
return
}

Expand All @@ -87,6 +94,9 @@ func (o *ListOptions) printRegistryList(w io.Writer, registryList *[]preference.
secure = "Yes"
}
fmt.Fprintln(w, registry.Name, "\t", registry.URL, "\t", secure)
if util2.IsGitBasedRegistry(registry.URL) {
o.printGitRegistryDeprecationWarning = true
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion pkg/odo/cli/registry/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ func (o *UpdateOptions) Validate() (err error) {
if err != nil {
return err
}

if registryUtil.IsGitBasedRegistry(o.registryURL) {
registryUtil.PrintGitRegistryDeprecationWarning()
}
return
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/odo/cli/registry/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
// odo packages

"os"
"strings"

"github.com/openshift/odo/pkg/log"
"github.com/openshift/odo/pkg/preference"
Expand Down Expand Up @@ -34,3 +35,11 @@ func IsSecure(registryName string) bool {

return isSecure
}

func IsGitBasedRegistry(url string) bool {
return strings.Contains(url, "github")
}

func PrintGitRegistryDeprecationWarning() {
log.Deprecate("Git based registries", "Please see https://github.com/openshift/odo/tree/main/docs/public/git-registry-deprecation.adoc")
}

0 comments on commit d0aaa10

Please sign in to comment.