Skip to content

Commit

Permalink
Add networking group
Browse files Browse the repository at this point in the history
  • Loading branch information
adracus committed Apr 22, 2022
1 parent 6a1408b commit 282162e
Show file tree
Hide file tree
Showing 41 changed files with 861 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ check: manifests generate addlicense lint test # Generate manifests, code, lint,
docs: ## Run go generate to generate API reference documentation.
go run github.com/ahmetb/gen-crd-api-reference-docs -api-dir ./apis/common/v1alpha1 -config ./hack/api-reference/common-config.json -template-dir ./hack/api-reference/template -out-file ./docs/api-reference/common.md
go run github.com/ahmetb/gen-crd-api-reference-docs -api-dir ./apis/compute/v1alpha1 -config ./hack/api-reference/compute-config.json -template-dir ./hack/api-reference/template -out-file ./docs/api-reference/compute.md
go run github.com/ahmetb/gen-crd-api-reference-docs -api-dir ./apis/ipam/v1alpha1 -config ./hack/api-reference/ipam-config.json -template-dir ./hack/api-reference/template -out-file ./docs/api-reference/ipam.md
go run github.com/ahmetb/gen-crd-api-reference-docs -api-dir ./apis/storage/v1alpha1 -config ./hack/api-reference/storage-config.json -template-dir ./hack/api-reference/template -out-file ./docs/api-reference/storage.md
# TODO: Enable once first types are there # go run github.com/ahmetb/gen-crd-api-reference-docs -api-dir ./apis/networking/v1alpha1 -config ./hack/api-reference/networking-config.json -template-dir ./hack/api-reference/template -out-file ./docs/api-reference/networking.md
go run github.com/ahmetb/gen-crd-api-reference-docs -api-dir ./apis/ipam/v1alpha1 -config ./hack/api-reference/ipam-config.json -template-dir ./hack/api-reference/template -out-file ./docs/api-reference/ipam.md

.PHONY: start-docs
start-docs: ## Start the local mkdocs based development environment.
Expand Down
24 changes: 24 additions & 0 deletions apis/networking/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2021 by the OnMetal authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// +k8s:deepcopy-gen=package,register
// +k8s:openapi-gen=true
// +k8s:defaulter-gen=TypeMeta
// +k8s:protobuf-gen=package
// +groupName=networking.api.onmetal.de

// Package networking is the internal version of the API.
package networking // import "github.com/onmetal/onmetal-api/apis/networking"
28 changes: 28 additions & 0 deletions apis/networking/install/install.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2022 OnMetal authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package install

import (
"github.com/onmetal/onmetal-api/apis/networking"
"github.com/onmetal/onmetal-api/apis/networking/v1alpha1"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
)

func Install(scheme *runtime.Scheme) {
utilruntime.Must(networking.AddToScheme(scheme))
utilruntime.Must(v1alpha1.AddToScheme(scheme))
utilruntime.Must(scheme.SetVersionPriority(v1alpha1.SchemeGroupVersion))
}
48 changes: 48 additions & 0 deletions apis/networking/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2021 by the OnMetal authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Package networking contains API Schema definitions for the networking internal API group
//+kubebuilder:object:generate=true
//+groupName=networking.api.onmetal.de
package networking

import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "networking.api.onmetal.de", Version: runtime.APIVersionInternal}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

func Resource(name string) schema.GroupResource {
return schema.GroupResource{
Group: SchemeGroupVersion.Group,
Resource: name,
}
}

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion)
return nil
}
25 changes: 25 additions & 0 deletions apis/networking/v1alpha1/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2021 by the OnMetal authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// +k8s:deepcopy-gen=package
// +k8s:conversion-gen=github.com/onmetal/onmetal-api/apis/networking
// +k8s:openapi-gen=true
// +k8s:defaulter-gen=TypeMeta
// +k8s:protobuf-gen=package
// +groupName=networking.api.onmetal.de

// Package v1alpha1 is the v1alpha1 version of the API.
package v1alpha1 // import "github.com/onmetal/onmetal-api/apis/networking/v1alpha1"
51 changes: 51 additions & 0 deletions apis/networking/v1alpha1/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2021 by the OnMetal authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the networking v1alpha1 API group
//+kubebuilder:object:generate=true
//+groupName=networking.api.onmetal.de
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
)

var (
// SchemeGroupVersion is group version used to register these objects
SchemeGroupVersion = schema.GroupVersion{Group: "networking.api.onmetal.de", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
localSchemeBuilder = &SchemeBuilder

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)

func Resource(name string) schema.GroupResource {
return schema.GroupResource{
Group: SchemeGroupVersion.Group,
Resource: name,
}
}

func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
35 changes: 35 additions & 0 deletions apis/networking/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions apis/networking/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions apis/networking/v1alpha1/zz_generated.defaults.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions apis/networking/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (

computerest "github.com/onmetal/onmetal-api/registry/compute/rest"
ipamrest "github.com/onmetal/onmetal-api/registry/ipam/rest"
networkingrest "github.com/onmetal/onmetal-api/registry/networking/rest"
storagerest "github.com/onmetal/onmetal-api/registry/storage/rest"
"k8s.io/apimachinery/pkg/version"
"k8s.io/apiserver/pkg/registry/generic"
Expand Down Expand Up @@ -92,6 +93,7 @@ func (c completedConfig) New() (*OnmetalAPIServer, error) {
restStorageProviders := []RESTStorageProvider{
ipamrest.StorageProvider{},
computerest.StorageProvider{},
networkingrest.StorageProvider{},
storagerest.StorageProvider{},
}

Expand Down
4 changes: 4 additions & 0 deletions app/apiserver/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/onmetal/onmetal-api/api"
computev1alpha1 "github.com/onmetal/onmetal-api/apis/compute/v1alpha1"
ipamv1alpha1 "github.com/onmetal/onmetal-api/apis/ipam/v1alpha1"
networkingv1alpha1 "github.com/onmetal/onmetal-api/apis/networking/v1alpha1"
storagev1alpha1 "github.com/onmetal/onmetal-api/apis/storage/v1alpha1"
"github.com/onmetal/onmetal-api/apiserver"
clientset "github.com/onmetal/onmetal-api/generated/clientset/versioned"
Expand All @@ -48,6 +49,7 @@ func NewResourceConfig() *serverstorage.ResourceConfig {
cfg.EnableVersions(
computev1alpha1.SchemeGroupVersion,
storagev1alpha1.SchemeGroupVersion,
networkingv1alpha1.SchemeGroupVersion,
ipamv1alpha1.SchemeGroupVersion,
)
return cfg
Expand All @@ -66,6 +68,7 @@ func NewOnmetalAPIServerOptions() *OnmetalAPIServerOptions {
api.Codecs.LegacyCodec(
computev1alpha1.SchemeGroupVersion,
storagev1alpha1.SchemeGroupVersion,
networkingv1alpha1.SchemeGroupVersion,
ipamv1alpha1.SchemeGroupVersion,
),
),
Expand All @@ -74,6 +77,7 @@ func NewOnmetalAPIServerOptions() *OnmetalAPIServerOptions {
computev1alpha1.SchemeGroupVersion,
schema.GroupKind{Group: computev1alpha1.SchemeGroupVersion.Group},
schema.GroupKind{Group: storagev1alpha1.SchemeGroupVersion.Group},
schema.GroupKind{Group: networkingv1alpha1.SchemeGroupVersion.Group},
schema.GroupKind{Group: ipamv1alpha1.SchemeGroupVersion.Group},
)
return o
Expand Down
1 change: 1 addition & 0 deletions config/apiserver/apiservice/bases/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ kind: Kustomization
resources:
- v1alpha1.compute.api.onmetal.de.yaml
- v1alpha1.storage.api.onmetal.de.yaml
- v1alpha1.networking.api.onmetal.de.yaml
- v1alpha1.ipam.api.onmetal.de.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
name: v1alpha1.networking.api.onmetal.de
spec:
group: networking.api.onmetal.de
version: v1alpha1
service:
namespace: system
name: apiserver-service
groupPriorityMinimum: 2000
versionPriority: 100
2 changes: 1 addition & 1 deletion controllers/compute/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,6 @@ func SetupTest(ctx context.Context) *corev1.Namespace {
var _ = AfterSuite(func() {
cancel()
By("tearing down the test environment")
err := testEnv.Stop()
err := envtestutils.StopWithExtensions(testEnv, testEnvExt)
Expect(err).NotTo(HaveOccurred())
})
2 changes: 1 addition & 1 deletion controllers/storage/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,6 @@ var _ = AfterSuite(func() {
cancel()

By("tearing down the test environment")
err := testEnv.Stop()
err := envtestutils.StopWithExtensions(testEnv, testEnvExt)
Expect(err).NotTo(HaveOccurred())
})
2 changes: 1 addition & 1 deletion docs/api-reference/common.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,5 +366,5 @@ When specified, allowed values are NoSchedule.</p>
<hr/>
<p><em>
Generated with <code>gen-crd-api-reference-docs</code>
on git commit <code>bbff837</code>.
on git commit <code>6a1408b</code>.
</em></p>
Loading

0 comments on commit 282162e

Please sign in to comment.