Add MIT Licence copyright notice

Signed-off-by: Soule BA <soule@weave.works>
This commit is contained in:
Soule BA 2022-03-22 09:15:55 +01:00
parent 366f5cfde8
commit 0f9302827c
No known key found for this signature in database
GPG Key ID: 4D40965192802994
4 changed files with 55 additions and 42 deletions

View File

@ -97,6 +97,7 @@ const (
// ArtifactUpToDateReason signals that an existing Artifact is up-to-date
// with the Source.
ArtifactUpToDateReason string = "ArtifactUpToDate"
// CacheOperationFailedReason signals a failure in cache operation.
CacheOperationFailedReason string = "CacheOperationFailed"
)

19
internal/cache/LICENSE vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2012-2019 Patrick Mylund Nielsen and the go-cache contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@ -1,18 +1,14 @@
/*
Copyright 2022 The Flux authors
// Copyright (c) 2012-2019 Patrick Mylund Nielsen and the go-cache contributors
// Use of this source code is governed by a MIT-style
// license that can be found 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.
*/
// Copyright 2022 The FluxCD contributors. All rights reserved.
// This package provides an in-memory cache
// derived from the https://github.com/patrickmn/go-cache
// package
// It has been modified in order to keep a small set of functions
// and to add a maxItems parameter in order to limit the number of,
// and thus the size of, items in the cache.
package cache
@ -23,9 +19,6 @@ import (
"time"
)
// NOTE: this is heavily based on patrickmn/go-cache:
// https://github.com/patrickmn/go-cache
// Cache is a thread-safe in-memory key/value store.
type Cache struct {
*cache

50
main.go
View File

@ -72,24 +72,24 @@ func init() {
func main() {
var (
metricsAddr string
eventsAddr string
healthAddr string
storagePath string
storageAddr string
storageAdvAddr string
concurrent int
requeueDependency time.Duration
watchAllNamespaces bool
helmIndexLimit int64
helmChartLimit int64
helmChartFileLimit int64
clientOptions client.Options
logOptions logger.Options
leaderElectionOptions leaderelection.Options
cacheMaxSize int
cacheTTL string
cachePurgeInterval string
metricsAddr string
eventsAddr string
healthAddr string
storagePath string
storageAddr string
storageAdvAddr string
concurrent int
requeueDependency time.Duration
watchAllNamespaces bool
helmIndexLimit int64
helmChartLimit int64
helmChartFileLimit int64
clientOptions client.Options
logOptions logger.Options
leaderElectionOptions leaderelection.Options
helmCacheMaxSize int
helmCacheTTL string
helmCachePurgeInterval string
)
flag.StringVar(&metricsAddr, "metrics-addr", envOrDefault("METRICS_ADDR", ":8080"),
@ -114,11 +114,11 @@ func main() {
"The max allowed size in bytes of a file in a Helm chart.")
flag.DurationVar(&requeueDependency, "requeue-dependency", 30*time.Second,
"The interval at which failing dependencies are reevaluated.")
flag.IntVar(&cacheMaxSize, "cache-max-size", 0,
flag.IntVar(&helmCacheMaxSize, "helm-cache-max-size", 0,
"The maximum size of the cache in number of items.")
flag.StringVar(&cacheTTL, "cache-ttl", "15m",
flag.StringVar(&helmCacheTTL, "helm-cache-ttl", "15m",
"The TTL of an item in the cache. Valid time units are ns, us (or µs), ms, s, m, h.")
flag.StringVar(&cachePurgeInterval, "cache-purge-interval", "1m",
flag.StringVar(&helmCachePurgeInterval, "helm-cache-purge-interval", "1m",
"The interval at which the cache is purged. Valid time units are ns, us (or µs), ms, s, m, h.")
clientOptions.BindFlags(flag.CommandLine)
@ -204,20 +204,20 @@ func main() {
var c *cache.Cache
var ttl time.Duration
if cacheMaxSize > 0 {
interval, err := time.ParseDuration(cachePurgeInterval)
if helmCacheMaxSize > 0 {
interval, err := time.ParseDuration(helmCachePurgeInterval)
if err != nil {
setupLog.Error(err, "unable to parse cache purge interval")
os.Exit(1)
}
ttl, err = time.ParseDuration(cacheTTL)
ttl, err = time.ParseDuration(helmCacheTTL)
if err != nil {
setupLog.Error(err, "unable to parse cache TTL")
os.Exit(1)
}
c = cache.New(cacheMaxSize, interval)
c = cache.New(helmCacheMaxSize, interval)
}
if err = (&controllers.HelmChartReconciler{
Client: mgr.GetClient(),