-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into EVEREST-1210-edit-advanced-configuration-ove…
…rview-page
- Loading branch information
Showing
17 changed files
with
342 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package kubernetes | ||
|
||
import "context" | ||
|
||
// DeleteCatalogSource deletes a catalog source. | ||
func (k *Kubernetes) DeleteCatalogSource(ctx context.Context, namespace, name string) error { | ||
return k.client.DeleteCatalogSource(ctx, namespace, name) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
|
||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
// DeleteCatalogSource deletes a catalog source. | ||
func (c *Client) DeleteCatalogSource(ctx context.Context, namespace string, name string) error { | ||
return c.olmClientset.OperatorsV1alpha1().CatalogSources(namespace).Delete(ctx, name, metav1.DeleteOptions{}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package kubernetes | ||
|
||
import ( | ||
"context" | ||
|
||
k8serrors "k8s.io/apimachinery/pkg/api/errors" | ||
) | ||
|
||
// K8sEnv represents type of Kubernetes environment. | ||
type K8sEnv string | ||
|
||
const ( | ||
// EnvStandard is a standard k8s environment. | ||
EnvStandard K8sEnv = "Standard" | ||
// EnvOpenShift is an OpenShift k8s environment. | ||
EnvOpenShift K8sEnv = "OpenShift" | ||
|
||
// OpenShiftCatalogNamespace is a namespace where catalogs in an OpenShift cluster are stored. | ||
OpenShiftCatalogNamespace = "openshift-marketplace" | ||
) | ||
|
||
//nolint:gochecknoglobals | ||
var ( | ||
openShiftEnv = &Environment{ | ||
Env: EnvOpenShift, | ||
CatalogNamespace: OpenShiftCatalogNamespace, | ||
SkipOLM: true, | ||
} | ||
standardEnv = &Environment{ | ||
Env: EnvStandard, | ||
CatalogNamespace: OLMNamespace, | ||
SkipOLM: false, | ||
} | ||
) | ||
|
||
// Environment represents a Kubernetes environment. | ||
type Environment struct { | ||
Env K8sEnv | ||
CatalogNamespace string | ||
SkipOLM bool | ||
} | ||
|
||
// DetectEnvironment detects Kubernetes environment. | ||
func (k *Kubernetes) DetectEnvironment(ctx context.Context) (*Environment, error) { | ||
env, ok, err := k.detectOpenShift(ctx) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if ok { | ||
return env, nil | ||
} | ||
return standardEnv, nil | ||
} | ||
|
||
func (k *Kubernetes) detectOpenShift(ctx context.Context) (*Environment, bool, error) { | ||
k.l.Debug("Detecting OpenShift") | ||
_, err := k.GetNamespace(ctx, OpenShiftCatalogNamespace) | ||
if err != nil { | ||
if k8serrors.IsNotFound(err) { | ||
k.l.Info("Detected standard Kubernetes environment") | ||
return nil, false, nil | ||
} | ||
k.l.Info("Failed to detect Kubernetes environment") | ||
return nil, false, err | ||
} | ||
|
||
// If the OpenShift Marketplace namespace exists, we consider this an OpenShift cluster. | ||
k.l.Debug("Detected OpenShift Kubernetes environment") | ||
return openShiftEnv, true, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.