Skip to content

Commit

Permalink
Merge pull request #17 from onmetal/refactoring
Browse files Browse the repository at this point in the history
Refactored repo name and added crd puller
  • Loading branch information
afritzler authored May 24, 2021
2 parents 58a32b3 + 3286155 commit 2ab7c1c
Show file tree
Hide file tree
Showing 26 changed files with 742 additions and 65 deletions.
32 changes: 16 additions & 16 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ layout:
- go.kubebuilder.io/v3
multigroup: true
projectName: onmetal
repo: github.com/onmetal-api
repo: github.com/onmetal/onmetal-api
resources:
- api:
crdVersion: v1
Expand All @@ -12,7 +12,7 @@ resources:
domain: onmetal.de
group: storage
kind: Volume
path: github.com/onmetal-api/apis/storage/v1alpha1
path: github.com/onmetal/onmetal-api/apis/storage/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -21,7 +21,7 @@ resources:
domain: onmetal.de
group: storage
kind: VolumeAttachment
path: github.com/onmetal-api/apis/storage/v1alpha1
path: github.com/onmetal/onmetal-api/apis/storage/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -30,7 +30,7 @@ resources:
domain: onmetal.de
group: compute
kind: Machine
path: github.com/onmetal-api/apis/compute/v1alpha1
path: github.com/onmetal/onmetal-api/apis/compute/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -39,7 +39,7 @@ resources:
domain: onmetal.de
group: network
kind: Network
path: github.com/onmetal-api/apis/network/v1alpha1
path: github.com/onmetal/onmetal-api/apis/network/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -48,7 +48,7 @@ resources:
domain: onmetal.de
group: network
kind: Subnet
path: github.com/onmetal-api/apis/network/v1alpha1
path: github.com/onmetal/onmetal-api/apis/network/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -57,7 +57,7 @@ resources:
domain: onmetal.de
group: network
kind: SecurityGroup
path: github.com/onmetal-api/apis/network/v1alpha1
path: github.com/onmetal/onmetal-api/apis/network/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -66,7 +66,7 @@ resources:
domain: onmetal.de
group: network
kind: Gateway
path: github.com/onmetal-api/apis/network/v1alpha1
path: github.com/onmetal/onmetal-api/apis/network/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -75,7 +75,7 @@ resources:
domain: onmetal.de
group: network
kind: NetworkInterface
path: github.com/onmetal-api/apis/network/v1alpha1
path: github.com/onmetal/onmetal-api/apis/network/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -84,7 +84,7 @@ resources:
domain: onmetal.de
group: network
kind: RouteTable
path: github.com/onmetal-api/apis/network/v1alpha1
path: github.com/onmetal/onmetal-api/apis/network/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -93,7 +93,7 @@ resources:
domain: onmetal.de
group: compute
kind: KeyPair
path: github.com/onmetal-api/apis/compute/v1alpha1
path: github.com/onmetal/onmetal-api/apis/compute/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -102,7 +102,7 @@ resources:
domain: onmetal.de
group: storage
kind: StorageClass
path: github.com/onmetal-api/apis/storage/v1alpha1
path: github.com/onmetal/onmetal-api/apis/storage/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -111,7 +111,7 @@ resources:
domain: onmetal.de
group: compute
kind: ComputePool
path: github.com/onmetal-api/apis/compute/v1alpha1
path: github.com/onmetal/onmetal-api/apis/compute/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -120,7 +120,7 @@ resources:
domain: onmetal.de
group: storage
kind: Snapshot
path: github.com/onmetal-api/apis/storage/v1alpha1
path: github.com/onmetal/onmetal-api/apis/storage/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -129,7 +129,7 @@ resources:
domain: onmetal.de
group: compute
kind: Image
path: github.com/onmetal-api/apis/compute/v1alpha1
path: github.com/onmetal/onmetal-api/apis/compute/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -138,6 +138,6 @@ resources:
domain: onmetal.de
group: compute
kind: Flavor
path: github.com/onmetal-api/apis/compute/v1alpha1
path: github.com/onmetal/onmetal-api/apis/compute/v1alpha1
version: v1alpha1
version: "3"
59 changes: 59 additions & 0 deletions cmd/crd-puller/pull-crds.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package main

import (
"context"
"fmt"
"io/ioutil"
"os"

"github.com/onmetal/onmetal-api/pkg/cmd/help"
crdpuller "github.com/onmetal/onmetal-api/pkg/crdpuller"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/clientcmd"
"sigs.k8s.io/yaml"
)

func main() {
help.FitTerminal()
cmd := &cobra.Command{
Use: "pull-crds",
Aliases: []string{},
SuggestFor: []string{},
Short: "Pull CRDs from a Kubernetes cluster",
Long: help.Doc(`
Pull CRDs from a Kubernetes cluster
Based on a kubeconfig file, it uses discovery API and the OpenAPI v2
model on the cluster to build CRDs for a list of api resource names.
`),
Example: "",
RunE: func(cmd *cobra.Command, args []string) error {
kubeconfigPath := cmd.Flag("kubeconfig").Value.String()
config, err := clientcmd.BuildConfigFromFlags("", kubeconfigPath)
if err != nil {
return err
}
puller, err := crdpuller.NewSchemaPuller(config)
if err != nil {
return err
}
crds, err := puller.PullCRDs(context.TODO(), args...)
if err != nil {
return err
}
for name, crd := range crds {
yamlBytes, err := yaml.Marshal(crd)
if err != nil {
return err
}

ioutil.WriteFile(name+".yaml", []byte(yamlBytes), os.ModePerm)
}
return nil
},
}
cmd.Flags().String("kubeconfig", ".kubeconfig", "kubeconfig file used to contact the cluster.")

if err := cmd.Execute(); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
}
}
2 changes: 1 addition & 1 deletion controllers/compute/computepool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

computev1alpha1 "github.com/onmetal-api/apis/compute/v1alpha1"
computev1alpha1 "github.com/onmetal/onmetal-api/apis/compute/v1alpha1"
)

// ComputePoolReconciler reconciles a ComputePool object
Expand Down
2 changes: 1 addition & 1 deletion controllers/compute/flavor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

computev1alpha1 "github.com/onmetal-api/apis/compute/v1alpha1"
computev1alpha1 "github.com/onmetal/onmetal-api/apis/compute/v1alpha1"
)

// FlavorReconciler reconciles a Flavor object
Expand Down
2 changes: 1 addition & 1 deletion controllers/compute/image_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

computev1alpha1 "github.com/onmetal-api/apis/compute/v1alpha1"
computev1alpha1 "github.com/onmetal/onmetal-api/apis/compute/v1alpha1"
)

// ImageReconciler reconciles a Image object
Expand Down
2 changes: 1 addition & 1 deletion controllers/compute/keypair_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

computev1alpha1 "github.com/onmetal-api/apis/compute/v1alpha1"
computev1alpha1 "github.com/onmetal/onmetal-api/apis/compute/v1alpha1"
)

// KeyPairReconciler reconciles a KeyPair object
Expand Down
2 changes: 1 addition & 1 deletion controllers/compute/machine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

computev1alpha1 "github.com/onmetal-api/apis/compute/v1alpha1"
computev1alpha1 "github.com/onmetal/onmetal-api/apis/compute/v1alpha1"
)

// MachineReconciler reconciles a Machine object
Expand Down
2 changes: 1 addition & 1 deletion controllers/compute/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

computev1alpha1 "github.com/onmetal-api/apis/compute/v1alpha1"
computev1alpha1 "github.com/onmetal/onmetal-api/apis/compute/v1alpha1"
//+kubebuilder:scaffold:imports
)

Expand Down
2 changes: 1 addition & 1 deletion controllers/network/gateway_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

networkv1alpha1 "github.com/onmetal-api/apis/network/v1alpha1"
networkv1alpha1 "github.com/onmetal/onmetal-api/apis/network/v1alpha1"
)

// GatewayReconciler reconciles a Gateway object
Expand Down
2 changes: 1 addition & 1 deletion controllers/network/network_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

networkv1alpha1 "github.com/onmetal-api/apis/network/v1alpha1"
networkv1alpha1 "github.com/onmetal/onmetal-api/apis/network/v1alpha1"
)

// NetworkReconciler reconciles a Network object
Expand Down
2 changes: 1 addition & 1 deletion controllers/network/networkinterface_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

networkv1alpha1 "github.com/onmetal-api/apis/network/v1alpha1"
networkv1alpha1 "github.com/onmetal/onmetal-api/apis/network/v1alpha1"
)

// NetworkInterfaceReconciler reconciles a NetworkInterface object
Expand Down
2 changes: 1 addition & 1 deletion controllers/network/routetable_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

networkv1alpha1 "github.com/onmetal-api/apis/network/v1alpha1"
networkv1alpha1 "github.com/onmetal/onmetal-api/apis/network/v1alpha1"
)

// RouteTableReconciler reconciles a RouteTable object
Expand Down
2 changes: 1 addition & 1 deletion controllers/network/securitygroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

networkv1alpha1 "github.com/onmetal-api/apis/network/v1alpha1"
networkv1alpha1 "github.com/onmetal/onmetal-api/apis/network/v1alpha1"
)

// SecurityGroupReconciler reconciles a SecurityGroup object
Expand Down
2 changes: 1 addition & 1 deletion controllers/network/subnet_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

networkv1alpha1 "github.com/onmetal-api/apis/network/v1alpha1"
networkv1alpha1 "github.com/onmetal/onmetal-api/apis/network/v1alpha1"
)

// SubnetReconciler reconciles a Subnet object
Expand Down
2 changes: 1 addition & 1 deletion controllers/network/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

networkv1alpha1 "github.com/onmetal-api/apis/network/v1alpha1"
networkv1alpha1 "github.com/onmetal/onmetal-api/apis/network/v1alpha1"
//+kubebuilder:scaffold:imports
)

Expand Down
2 changes: 1 addition & 1 deletion controllers/storage/snapshot_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

storagev1alpha1 "github.com/onmetal-api/apis/storage/v1alpha1"
storagev1alpha1 "github.com/onmetal/onmetal-api/apis/storage/v1alpha1"
)

// SnapshotReconciler reconciles a Snapshot object
Expand Down
2 changes: 1 addition & 1 deletion controllers/storage/storageclass_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

storagev1alpha1 "github.com/onmetal-api/apis/storage/v1alpha1"
storagev1alpha1 "github.com/onmetal/onmetal-api/apis/storage/v1alpha1"
)

// StorageClassReconciler reconciles a StorageClass object
Expand Down
2 changes: 1 addition & 1 deletion controllers/storage/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

storagev1alpha1 "github.com/onmetal-api/apis/storage/v1alpha1"
storagev1alpha1 "github.com/onmetal/onmetal-api/apis/storage/v1alpha1"
//+kubebuilder:scaffold:imports
)

Expand Down
2 changes: 1 addition & 1 deletion controllers/storage/volume_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

storagev1alpha1 "github.com/onmetal-api/apis/storage/v1alpha1"
storagev1alpha1 "github.com/onmetal/onmetal-api/apis/storage/v1alpha1"
)

// VolumeReconciler reconciles a Volume object
Expand Down
2 changes: 1 addition & 1 deletion controllers/storage/volumeattachment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

storagev1alpha1 "github.com/onmetal-api/apis/storage/v1alpha1"
storagev1alpha1 "github.com/onmetal/onmetal-api/apis/storage/v1alpha1"
)

// VolumeAttachmentReconciler reconciles a VolumeAttachment object
Expand Down
14 changes: 11 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
module github.com/onmetal-api
module github.com/onmetal/onmetal-api

go 1.15
go 1.16

require (
github.com/MakeNowJust/heredoc v1.0.0
github.com/go-logr/logr v0.4.0
github.com/muesli/reflow v0.1.0
github.com/onsi/ginkgo v1.16.2
github.com/onsi/gomega v1.12.0
k8s.io/apimachinery v0.21.1
github.com/spf13/cobra v1.1.1
github.com/wayneashleyberry/terminal-dimensions v1.0.0
k8s.io/apiextensions-apiserver v0.20.1
k8s.io/apimachinery v0.20.2
k8s.io/client-go v0.20.2
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92
k8s.io/kube-openapi v0.0.0-20210305001622-591a79e4bda7
sigs.k8s.io/controller-runtime v0.8.3
sigs.k8s.io/yaml v1.2.0
)
Loading

0 comments on commit 2ab7c1c

Please sign in to comment.