forked from sigstore/scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SECURESIGN 12 | Enable Podman build for TUF server image
Signed-off-by: greg pereira <[email protected]>
- Loading branch information
1 parent
1372537
commit 41e4cdf
Showing
3 changed files
with
169 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package build | ||
|
||
import ( | ||
"os" | ||
) | ||
|
||
func GetBuildMethod() string { | ||
kubernetesServiceHost := os.Getenv("KUBERNETES_SERVICE_HOST") | ||
kubernetesServicePort := os.Getenv("KUBERNETES_SERVICE_PORT") | ||
if kubernetesServiceHost == "" && kubernetesServicePort == "" { | ||
return "container" | ||
} else { | ||
return "kubernetes" | ||
} | ||
} |
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,50 @@ | ||
package tuf | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"io/fs" | ||
"os" | ||
"strings" | ||
|
||
"github.com/sigstore/scaffolding/pkg/certs" | ||
"knative.dev/pkg/logging" | ||
) | ||
|
||
func ProcessTufFiles(ctx context.Context, tufFiles []fs.DirEntry, dir string) map[string][]byte { | ||
trimDir := strings.TrimSuffix(dir, "/") | ||
files := map[string][]byte{} | ||
for _, file := range tufFiles { | ||
if !file.IsDir() { | ||
logging.FromContext(ctx).Infof("Got file %s", file.Name()) | ||
// Kubernetes adds some extra files here that are prefixed with | ||
// .., for example '..data' so skip those. | ||
if strings.HasPrefix(file.Name(), "..") { | ||
logging.FromContext(ctx).Infof("Skipping .. file %s", file.Name()) | ||
continue | ||
} | ||
fileName := fmt.Sprintf("%s/%s", trimDir, file.Name()) | ||
fileBytes, err := os.ReadFile(fileName) | ||
if err != nil { | ||
logging.FromContext(ctx).Fatalf("failed to read file %s/%s: %v", fileName, err) | ||
} | ||
// If it's a TSA file, we need to split it into multiple TUF | ||
// targets. | ||
if strings.Contains(file.Name(), "tsa") { | ||
logging.FromContext(ctx).Infof("Splitting TSA certchain into individual certs") | ||
|
||
certFiles, err := certs.SplitCertChain(fileBytes, "tsa") | ||
if err != nil { | ||
logging.FromContext(ctx).Fatalf("failed to parse %s/%s: %v", fileName, err) | ||
} | ||
for k, v := range certFiles { | ||
logging.FromContext(ctx).Infof("Got tsa cert file %s", k) | ||
files[k] = v | ||
} | ||
} else { | ||
files[file.Name()] = fileBytes | ||
} | ||
} | ||
} | ||
return files | ||
} |