-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
143 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,7 +89,7 @@ jobs: | |
actions: read # To read the workflow path. | ||
id-token: write # To sign the provenance. | ||
contents: write # To add assets to a release. | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@07e64b653f10a80b6510f4568f685f8b7b9ea830 # v1.9.0 | ||
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected] | ||
with: | ||
base64-subjects: "${{ needs.release.outputs.hashes }}" | ||
upload-assets: true # upload to a new release | ||
|
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,82 @@ | ||
// | ||
// Copyright 2023 Stacklok, Inc. | ||
// | ||
// 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 config provides the frizbee configuration. | ||
package config | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"gopkg.in/yaml.v3" | ||
) | ||
|
||
type contextConfigKey struct{} | ||
|
||
// ContextConfigKey is the context key for the configuration. | ||
// nolint:gochecknoglobals // this is a context key | ||
var ContextConfigKey = contextConfigKey{} | ||
|
||
// FromContext returns the configuration from the context. | ||
func FromContext(ctx context.Context) (*Config, error) { | ||
cfg, ok := ctx.Value(ContextConfigKey).(*Config) | ||
if !ok { | ||
return nil, fmt.Errorf("failed to get config from context") | ||
} | ||
|
||
return cfg, nil | ||
} | ||
|
||
// Config is the frizbee configuration. | ||
type Config struct { | ||
GHActions GHActions `yaml:"ghactions" mapstructure:"ghactions"` | ||
} | ||
|
||
// GHActions is the GitHub Actions configuration. | ||
type GHActions struct { | ||
Filter `yaml:",inline" mapstructure:",inline"` | ||
} | ||
|
||
// Filter is a common configuration for filtering out patterns. | ||
type Filter struct { | ||
// Exclude is a list of patterns to exclude. | ||
Exclude []string `yaml:"exclude" mapstructure:"exclude"` | ||
} | ||
|
||
// ParseConfigFile parses a configuration file. | ||
func ParseConfigFile(configfile string) (*Config, error) { | ||
cfg := &Config{} | ||
cleancfgfile := filepath.Clean(configfile) | ||
cfgF, err := os.Open(cleancfgfile) | ||
if err != nil { | ||
if os.IsNotExist(err) { | ||
return cfg, nil | ||
} | ||
|
||
return nil, fmt.Errorf("failed to open config file: %w", err) | ||
} | ||
// nolint:errcheck // we don't care about the error here | ||
defer cfgF.Close() | ||
|
||
dec := yaml.NewDecoder(cfgF) | ||
|
||
if err := dec.Decode(cfg); err != nil { | ||
return nil, fmt.Errorf("failed to decode config file: %w", err) | ||
} | ||
|
||
return cfg, nil | ||
} |
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