Skip to content

Commit

Permalink
feat: add volume source config for build from PVC
Browse files Browse the repository at this point in the history
  • Loading branch information
wangeguo committed Jan 27, 2024
1 parent 843bfcd commit d3c1f87
Show file tree
Hide file tree
Showing 18 changed files with 324 additions and 16 deletions.
33 changes: 33 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -5721,6 +5721,9 @@
"x-kubernetes-patch-merge-key": "type",
"x-kubernetes-patch-strategy": "merge"
},
"latestAttestationImage": {
"type": "string"
},
"latestCacheImage": {
"type": "string"
},
Expand Down Expand Up @@ -7411,6 +7414,21 @@
},
"registry": {
"$ref": "#/definitions/kpack.core.v1alpha1.ResolvedRegistrySource"
},
"volume": {
"$ref": "#/definitions/kpack.core.v1alpha1.ResolvedVolumeSource"
}
}
},
"kpack.core.v1alpha1.ResolvedVolumeSource": {
"type": "object",
"required": [
"persistentVolumeClaimName"
],
"properties": {
"persistentVolumeClaimName": {
"type": "string",
"default": ""
}
}
},
Expand All @@ -7428,6 +7446,9 @@
},
"subPath": {
"type": "string"
},
"volume": {
"$ref": "#/definitions/kpack.core.v1alpha1.Volume"
}
}
},
Expand Down Expand Up @@ -7463,6 +7484,18 @@
"$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.Time"
}
}
},
"kpack.core.v1alpha1.Volume": {
"type": "object",
"required": [
"persistentVolumeClaimName"
],
"properties": {
"persistentVolumeClaimName": {
"type": "string",
"default": ""
}
}
}
}
}
Binary file added cmd/build-init/build/build-init
Binary file not shown.
7 changes: 7 additions & 0 deletions cmd/build-init/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/pivotal/kpack/pkg/flaghelpers"
"github.com/pivotal/kpack/pkg/git"
"github.com/pivotal/kpack/pkg/registry"
"github.com/pivotal/kpack/pkg/volume"
)

var (
Expand All @@ -38,6 +39,7 @@ var (
blobURL = flag.String("blob-url", os.Getenv("BLOB_URL"), "The url of the source code blob.")
stripComponents = flag.Int("strip-components", getenvInt("BLOB_STRIP_COMPONENTS", 0), "The number of directory components to strip from the blobs content when extracting.")
registryImage = flag.String("registry-image", os.Getenv("REGISTRY_IMAGE"), "The registry location of the source code image.")
volumePVCName = flag.String("volume-pvc-name", os.Getenv("VOLUME_PVC_NAME"), "The name of the persistent volume claim to use as the source code image.")
hostName = flag.String("dns-probe-hostname", os.Getenv("DNS_PROBE_HOSTNAME"), "hostname to dns poll")
sourceSubPath = flag.String("source-sub-path", os.Getenv("SOURCE_SUB_PATH"), "the subpath inside the source directory that will be the buildpack workspace")
buildChanges = flag.String("build-changes", os.Getenv("BUILD_CHANGES"), "JSON string of build changes and their reason")
Expand Down Expand Up @@ -236,6 +238,11 @@ func fetchSource(logger *log.Logger, keychain authn.Keychain) error {
Keychain: authn.NewMultiKeychain(registrySourcePullSecrets, keychain),
}
return fetcher.Fetch(appDir, *registryImage, projectMetadataDir)
case *volumePVCName != "":
fetcher := volume.Fetcher{
Logger: logger,
}
return fetcher.Fetch(appDir, *volumePVCName, projectMetadataDir)
default:
return errors.New("no git url, blob url, or registry image provided")
}
Expand Down
Loading

0 comments on commit d3c1f87

Please sign in to comment.