-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the cache size field immutable (#42)
* Make the cache size field immutable Currently we are using StatefulSet volumeClaimTemplate to provision the PVC. However the corresponding StatefulSet field that controls the PVC size is immutable. It is not possible to resize/enlarge the underlying PVC through the StatefulSet spec. See kubernetes/enhancements#661 This commit makes the cache size field immutable until we decide how to implement the resize. * Address review comments
- Loading branch information
1 parent
272e5c2
commit 1c84298
Showing
9 changed files
with
393 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) 2023 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file | ||
// | ||
// 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 validator | ||
|
||
import ( | ||
"github.com/gardener/gardener/pkg/apis/core" | ||
|
||
"github.com/gardener/gardener-extension-registry-cache/pkg/constants" | ||
) | ||
|
||
// FindRegistryCacheExtension finds the registry-cache extension. | ||
// The first return argument is index of the extension in the list. -1 is returned if the extension is not found. | ||
// The second return argument is the extension itself. An empty extension is returned if the extension is not found. | ||
func FindRegistryCacheExtension(extensions []core.Extension) (int, core.Extension) { | ||
for i, ext := range extensions { | ||
if ext.Type == constants.ExtensionType { | ||
return i, ext | ||
} | ||
} | ||
|
||
return -1, core.Extension{} | ||
} |
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,61 @@ | ||
// Copyright (c) 2023 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file | ||
// | ||
// 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 validator_test | ||
|
||
import ( | ||
"github.com/gardener/gardener/pkg/apis/core" | ||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
|
||
"github.com/gardener/gardener-extension-registry-cache/pkg/admission/validator" | ||
) | ||
|
||
var _ = Describe("Helpers", func() { | ||
|
||
DescribeTable("#FindRegistryCacheExtension", | ||
func(extensions []core.Extension, expectedI int, expectedExt core.Extension) { | ||
i, ext := validator.FindRegistryCacheExtension(extensions) | ||
Expect(i).To(Equal(expectedI)) | ||
Expect(ext).To(Equal(expectedExt)) | ||
}, | ||
|
||
Entry("extensions is nil", | ||
nil, | ||
-1, core.Extension{}, | ||
), | ||
Entry("extensions is empty", | ||
[]core.Extension{}, | ||
-1, core.Extension{}, | ||
), | ||
Entry("no registry-cache extension", | ||
[]core.Extension{ | ||
{Type: "foo"}, | ||
{Type: "bar"}, | ||
{Type: "baz"}, | ||
}, | ||
-1, core.Extension{}, | ||
), | ||
Entry("with registry-cache extension", | ||
[]core.Extension{ | ||
{Type: "foo"}, | ||
{Type: "bar"}, | ||
{Type: "registry-cache", ProviderConfig: &runtime.RawExtension{Raw: []byte(`{"one": "two"}`)}}, | ||
{Type: "baz"}, | ||
}, | ||
2, core.Extension{Type: "registry-cache", ProviderConfig: &runtime.RawExtension{Raw: []byte(`{"one": "two"}`)}}, | ||
), | ||
) | ||
}) |
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,32 @@ | ||
// Copyright (c) 2023 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, v. 2 except as noted otherwise in the LICENSE file | ||
// | ||
// 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 helper | ||
|
||
import ( | ||
"github.com/gardener/gardener-extension-registry-cache/pkg/apis/registry" | ||
) | ||
|
||
// FindCacheByUpstream finds a cache by upstream. | ||
// The first return argument is whether the extension was found. | ||
// The second return argument is the cache itself. An empty cache is returned if the cache is not found. | ||
func FindCacheByUpstream(caches []registry.RegistryCache, upstream string) (bool, registry.RegistryCache) { | ||
for _, cache := range caches { | ||
if cache.Upstream == upstream { | ||
return true, cache | ||
} | ||
} | ||
|
||
return false, registry.RegistryCache{} | ||
} |
Oops, something went wrong.