forked from ko-build/ko
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sketch a rough shape for ko-build#356
- Loading branch information
Showing
311 changed files
with
153,695 additions
and
10 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
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
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,47 @@ | ||
/* | ||
Copyright 2023 Google LLC All Rights Reserved. | ||
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 policy | ||
|
||
type Verification struct { | ||
// NoMatchPolicy specifies the behavior when a base image doesn't match any | ||
// of the listed policies. It allows the values: allow, deny, and warn. | ||
// Currently the default is "warn". | ||
NoMatchPolicy string `yaml:"no-match-policy,omitempty"` | ||
|
||
// Policies specifies a collection of policies to use to cover the base | ||
// images used as part of evaluation. See "policy" below for usage. | ||
// | ||
// TODO(mattmoor): Sort out how we distinguish between an explicit empty | ||
// list and when this field is unspecified. Perhaps we need *[]policy? | ||
// Once that's sorted, document the current default here. | ||
Policies []PolicyData `yaml:"policies,omitempty"` | ||
} | ||
|
||
// PolicyData contains a set of options for specifying a PolicyData. Exactly | ||
// one of the fields may be specified for each PolicyData entry. | ||
type PolicyData struct { | ||
// Data is a collection of one or more ClusterImagePolicy resources. | ||
Data string `yaml:"data,omitempty"` | ||
|
||
// URL links to a file containing one or more ClusterImagePolicy resources. | ||
URL string `yaml:"url,omitempty"` | ||
|
||
// Path is a path to a file or directory containing ClusterImagePolicy resources. | ||
// TODO(mattmoor): How do we want to handle something like -R? Perhaps we | ||
// don't and encourage folks to list each directory individually? | ||
Path string `yaml:"path,omitempty"` | ||
} |
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,56 @@ | ||
/* | ||
Copyright 2023 Google LLC All Rights Reserved. | ||
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 policy | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/google/go-containerregistry/pkg/name" | ||
"knative.dev/pkg/apis" | ||
) | ||
|
||
// Verifier is the interface for checking that a given image digest satisfies | ||
// the policies backing this interface. | ||
type Verifier interface { | ||
// Verify checks that the provided digest satisfies the backing policies. | ||
Verify(name.Digest) error | ||
} | ||
|
||
// Compile turns a Verification into an executable Verifier. | ||
// Any compilation errors are returned here. | ||
func Compile(v Verification) (Verifier, error) { | ||
return &impl{ | ||
verification: v, | ||
}, nil | ||
} | ||
|
||
type impl struct { | ||
verification Verification | ||
} | ||
|
||
// Check that impl implements Verifier | ||
var _ Verifier = (*impl)(nil) | ||
|
||
// Verify implements Verifier | ||
func (i *impl) Verify(d name.Digest) error { | ||
err := &apis.FieldError{ | ||
Message: "NYI", | ||
Details: fmt.Sprintf("got policies: %v", i.verification), | ||
} | ||
|
||
return err // .At(apis.WarningLevel) | ||
} |
Oops, something went wrong.