-
Notifications
You must be signed in to change notification settings - Fork 62
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
Provider api #183
Provider api #183
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ apiVersion: apiextensions.k8s.io/v1 | |
kind: CustomResourceDefinition | ||
metadata: | ||
annotations: | ||
controller-gen.kubebuilder.io/version: v0.14.0 | ||
controller-gen.kubebuilder.io/version: v0.12.0 | ||
name: custompackages.idpbuilder.cnoe.io | ||
spec: | ||
group: idpbuilder.cnoe.io | ||
|
@@ -19,19 +19,14 @@ spec: | |
openAPIV3Schema: | ||
properties: | ||
apiVersion: | ||
description: |- | ||
APIVersion defines the versioned schema of this representation of an object. | ||
Servers should convert recognized schemas to the latest internal value, and | ||
may reject unrecognized values. | ||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources | ||
description: 'APIVersion defines the versioned schema of this representation | ||
of an object. Servers should convert recognized schemas to the latest | ||
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' | ||
Comment on lines
-22
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these diffs will go away if a newer version of controller gen is used |
||
type: string | ||
kind: | ||
description: |- | ||
Kind is a string value representing the REST resource this object represents. | ||
Servers may infer this from the endpoint the client submits requests to. | ||
Cannot be updated. | ||
In CamelCase. | ||
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds | ||
description: 'Kind is a string value representing the REST resource this | ||
object represents. Servers may infer this from the endpoint the client | ||
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' | ||
type: string | ||
metadata: | ||
type: object | ||
|
@@ -65,14 +60,12 @@ spec: | |
- namespace | ||
type: object | ||
gitServerURL: | ||
description: |- | ||
GitServerURL specifies the base URL for the git server for API calls. | ||
for example, https://gitea.cnoe.localtest.me:8443 | ||
description: GitServerURL specifies the base URL for the git server | ||
for API calls. for example, https://gitea.cnoe.localtest.me:8443 | ||
type: string | ||
internalGitServeURL: | ||
description: |- | ||
InternalGitServeURL specifies the base URL for the git server accessible within the cluster. | ||
for example, http://my-gitea-http.gitea.svc.cluster.local:3000 | ||
description: InternalGitServeURL specifies the base URL for the git | ||
server accessible within the cluster. for example, http://my-gitea-http.gitea.svc.cluster.local:3000 | ||
type: string | ||
replicate: | ||
default: false | ||
|
@@ -103,9 +96,9 @@ spec: | |
type: object | ||
type: array | ||
synced: | ||
description: |- | ||
A Custom package is considered synced when the in-cluster repository url is set as the repository URL | ||
This only applies for a package that references local directories | ||
description: A Custom package is considered synced when the in-cluster | ||
repository url is set as the repository URL This only applies for | ||
a package that references local directories | ||
type: boolean | ||
type: object | ||
type: object | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package k8s | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/cnoe-io/idpbuilder/pkg/k8s/provider" | ||
"github.com/cnoe-io/idpbuilder/pkg/k8s/providers/kind" | ||
) | ||
|
||
func GetProvider(providerType provider.ProviderType, config *provider.Config) (provider.Provider, error) { | ||
switch providerType { | ||
case provider.KindProvider: | ||
return kind.NewProvider() | ||
} | ||
return nil, fmt.Errorf("invalid provider type") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
|
||
"sigs.k8s.io/kind/pkg/cluster/nodes" | ||
) | ||
|
||
type PortMapping struct { | ||
HostPort string | ||
ContainerPort string | ||
} | ||
|
||
type KindConfig struct { | ||
KindConfigPath string | ||
} | ||
Comment on lines
+14
to
+16
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better to move the KindConfig definition under |
||
|
||
// Configuration for providers | ||
type Config struct { | ||
KubernetesVersion string | ||
ExtraPortsMapping []PortMapping | ||
Port string | ||
IngressProtocol string | ||
Host string | ||
|
||
Kind KindConfig | ||
} | ||
|
||
// This was mostly derived from sigs.k8s.io/kind/pkg/cluster/internal/providers | ||
// We cannot import it directly as its an internal module | ||
|
||
// Provider represents a provider of cluster / node infrastructure | ||
type Provider interface { | ||
// Provision should create the Kubernetes cluster | ||
Provision(ctx context.Context, clusterName string, config *Config) error | ||
// ListClusters discovers the clusters that currently have resources | ||
// under this providers | ||
ListClusters() ([]string, error) | ||
// ListNodes returns the nodes under this provider for the given | ||
// cluster name, they may or may not be running correctly | ||
Delete(clusterName string) error | ||
ListNodes(clusterName string) ([]nodes.Node, error) | ||
// GetAPIServerEndpoint returns the host endpoint for the cluster's API server | ||
GetAPIServerEndpoint(clusterName string) (string, error) | ||
// GetAPIServerInternalEndpoint returns the internal network endpoint for the cluster's API server | ||
GetAPIServerInternalEndpoint(clusterName string) (string, error) | ||
// ExportKubeConfig writes out kube config under name to path | ||
ExportKubeConfig(clusterName string, path string, internal bool) error | ||
} | ||
|
||
type ProviderType string | ||
|
||
const ( | ||
KindProvider ProviderType = "Kind" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like you need to bump the version of your controller gen. are you using an older version of idpbuilder or is there any other reason to have this older version used?