Skip to content

Commit

Permalink
Merge branch 'nephio-project:main' into fix-ownerReferences
Browse files Browse the repository at this point in the history
  • Loading branch information
kushnaidu authored Aug 16, 2024
2 parents b84923e + 12b79b2 commit d19fec4
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
6 changes: 2 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
"program": "${workspaceFolder}/cmd/porch/main.go",
"args": [
"--secure-port=4443",
// "--v=7",
// "--standalone-debug-mode",
"--kubeconfig=${env:KUBECONFIG}",
"--cache-directory=${workspaceFolder}/.cache",
"--function-runner=172.18.255.201:9445",
"--function-runner=${env:FUNCTION_RUNNER_IP}:9445",
"--repo-sync-frequency=60s"
],
"cwd": "${workspaceFolder}",
"env": {
"CERT_STORAGE_DIR": "${workspaceFolder}/.build/pki/tmp",
"WEBHOOK_HOST": "localhost"
"WEBHOOK_HOST": "localhost"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ load-images-to-kind: ## Build porch images and load them into a kind cluster
.PHONY: deploy-current-config
deploy-current-config: ## Deploy the configuration that is currently in $(DEPLOYPORCHCONFIGDIR)
kpt fn render $(DEPLOYPORCHCONFIGDIR)
kpt live init $(DEPLOYPORCHCONFIGDIR) --name porch --namespace porch-system --inventory-id porch-test || true
kpt live init $(DEPLOYPORCHCONFIGDIR) --name porch --namespace porch-system --inventory-id nephio || true
kpt live apply --inventory-policy=adopt --server-side --force-conflicts $(DEPLOYPORCHCONFIGDIR)
@kubectl rollout status deployment function-runner --namespace porch-system 2>/dev/null || true
@kubectl rollout status deployment porch-controllers --namespace porch-system 2>/dev/null || true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ spec:
Ignored if `type` is not `git`.
properties:
branch:
default: main
description: Name of the branch containing the packages. Finalized
packages will be committed to this branch (if the repository
allows write access). If unspecified, defaults to "main".
minLength: 1
type: string
createBranch:
description: CreateBranch specifies if Porch should create the
Expand Down Expand Up @@ -176,9 +178,11 @@ spec:
Must be unspecified if `type` is not `git`.
properties:
branch:
default: main
description: Name of the branch containing the packages. Finalized
packages will be committed to this branch (if the repository
allows write access). If unspecified, defaults to "main".
minLength: 1
type: string
createBranch:
description: CreateBranch specifies if Porch should create
Expand Down
2 changes: 2 additions & 0 deletions api/porchconfig/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ type GitRepository struct {
// Address of the Git repository, for example:
// `https://github.com/GoogleCloudPlatform/blueprints.git`
Repo string `json:"repo"`
// +kubebuilder:default=main
// +kubebuilder:validation:MinLength=1
// Name of the branch containing the packages. Finalized packages will be committed to this branch (if the repository allows write access). If unspecified, defaults to "main".
Branch string `json:"branch,omitempty"`
// CreateBranch specifies if Porch should create the package branch if it doesn't exist.
Expand Down
11 changes: 7 additions & 4 deletions pkg/git/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ func OpenRepository(ctx context.Context, name, namespace string, spec *configapi
return nil, fmt.Errorf("error cloning git repository %q, cannot create remote: %v", spec.Repo, err)
}

// NOTE: the spec.git.branch field in the Repository CRD (OpenAPI schema) is defined with
// MinLength=1 validation and its default value is set to "main". This means that
// it should never be empty at this point. The following code is left here as a last resort failsafe.
branch := MainBranch
if spec.Branch != "" {
branch = BranchName(spec.Branch)
Expand All @@ -140,8 +143,8 @@ func OpenRepository(ctx context.Context, name, namespace string, spec *configapi
}

if opts.UseGitCaBundle {
if caBundle, err := opts.CredentialResolver.ResolveCredential(ctx, namespace, namespace + "-ca-bundle"); err != nil {
klog.Errorf("failed to obtain caBundle from secret %s/%s: %v", namespace, namespace + "-ca-bundle", err)
if caBundle, err := opts.CredentialResolver.ResolveCredential(ctx, namespace, namespace+"-ca-bundle"); err != nil {
klog.Errorf("failed to obtain caBundle from secret %s/%s: %v", namespace, namespace+"-ca-bundle", err)
} else {
repository.caBundle = []byte(caBundle.ToString())
}
Expand Down Expand Up @@ -1095,8 +1098,8 @@ func (r *gitRepository) pushAndCleanup(ctx context.Context, ph *pushRefSpecBuild
Auth: auth,
RequireRemoteRefs: require,
// TODO(justinsb): Need to ensure this is a compare-and-swap
Force: true,
CABundle: r.caBundle,
Force: true,
CABundle: r.caBundle,
})
}); err != nil {
return err
Expand Down

0 comments on commit d19fec4

Please sign in to comment.