diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 3c9f697be..9334b6529 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -5946,6 +5946,13 @@ "os": { "type": "string" }, + "signaturePaths": { + "type": "array", + "items": { + "default": {}, + "$ref": "#/definitions/kpack.build.v1alpha2.CosignSignature" + } + }, "stack": { "default": {}, "$ref": "#/definitions/kpack.core.v1alpha1.BuildStack" @@ -6193,13 +6200,11 @@ "kpack.build.v1alpha2.ClusterBuildpackSpec": { "type": "object", "properties": { + "image": { + "type": "string" + }, "serviceAccountRef": { "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" - }, - "source": { - "default": {}, - "x-kubernetes-list-type": "", - "$ref": "#/definitions/kpack.core.v1alpha1.ImageSource" } } }, @@ -6498,6 +6503,23 @@ } } }, + "kpack.build.v1alpha2.CosignSignature": { + "type": "object", + "required": [ + "signingSecret", + "targetDigest" + ], + "properties": { + "signingSecret": { + "type": "string", + "default": "" + }, + "targetDigest": { + "type": "string", + "default": "" + } + } + }, "kpack.build.v1alpha2.Image": { "type": "object", "required": [ @@ -7193,6 +7215,9 @@ "revision" ], "properties": { + "initializeSubmodules": { + "type": "boolean" + }, "revision": { "type": "string", "default": "" @@ -7310,6 +7335,9 @@ "type" ], "properties": { + "initializeSubmodules": { + "type": "boolean" + }, "revision": { "type": "string", "default": "" diff --git a/cmd/build-init/main.go b/cmd/build-init/main.go index 30dc02722..c21864e54 100644 --- a/cmd/build-init/main.go +++ b/cmd/build-init/main.go @@ -32,15 +32,16 @@ var ( imageTag = flag.String("imageTag", os.Getenv("IMAGE_TAG"), "tag of image that will get created by the lifecycle") runImage = flag.String("runImage", os.Getenv("RUN_IMAGE"), "The base image from which application images are built.") - gitURL = flag.String("git-url", os.Getenv("GIT_URL"), "The url of the Git repository to initialize.") - gitRevision = flag.String("git-revision", os.Getenv("GIT_REVISION"), "The Git revision to make the repository HEAD.") - 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.") - 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") - descriptorPath = flag.String("project-descriptor-path", os.Getenv("PROJECT_DESCRIPTOR_PATH"), "path to project descriptor file") + gitURL = flag.String("git-url", os.Getenv("GIT_URL"), "The url of the Git repository to initialize.") + gitRevision = flag.String("git-revision", os.Getenv("GIT_REVISION"), "The Git revision to make the repository HEAD.") + gitInitializeSubmodules = flag.Bool("git-initialize-submodules", getenvBool("GIT_INITIALIZE_SUBMODULES"), "Initialize submodules during git clone") + 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.") + 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") + descriptorPath = flag.String("project-descriptor-path", os.Getenv("PROJECT_DESCRIPTOR_PATH"), "path to project descriptor file") builderImage = flag.String("builder-image", os.Getenv("BUILDER_IMAGE"), "The builder image used to build the application") builderName = flag.String("builder-name", os.Getenv("BUILDER_NAME"), "The builder name provided during creation") @@ -207,9 +208,15 @@ func fetchSource(logger *log.Logger, keychain authn.Keychain) error { return err } + var initializeSubmodules bool + if gitInitializeSubmodules != nil { + initializeSubmodules = *gitInitializeSubmodules + } + fetcher := git.Fetcher{ - Logger: logger, - Keychain: gitKeychain, + Logger: logger, + Keychain: gitKeychain, + InitializeSubmodules: initializeSubmodules, } return fetcher.Fetch(appDir, *gitURL, *gitRevision, projectMetadataDir) case *blobURL != "": @@ -297,3 +304,12 @@ func getenvInt(key string, defaultValue int) int { } return atoi } + +func getenvBool(key string) bool { + value := os.Getenv(key) + b, err := strconv.ParseBool(value) + if err != nil { + return false + } + return b +} diff --git a/docs/image.md b/docs/image.md index ab0870418..a4e9e78e0 100644 --- a/docs/image.md +++ b/docs/image.md @@ -83,11 +83,13 @@ The `source` field is a composition of a source code location and a `subpath`. I git: url: "" revision: "" + initializeSubmodules: false subPath: "" ``` - `git`: (Source Code is a git repository) - `url`: The git repository url. Both https and ssh formats are supported; with ssh format requiring a [ssh secret](secrets.md#git-secrets). - `revision`: The git revision to use. This value may be a commit sha, branch name, or tag. + - `initializeSubmodules`: Initialize submodules inside repo, recurses up to a max depth of 10 submodules. - `subPath`: A subdirectory within the source folder where application code resides. Can be ignored if the source code resides at the `root` level. * Blob diff --git a/pkg/apis/build/v1alpha2/build_pod_test.go b/pkg/apis/build/v1alpha2/build_pod_test.go index 6ec78d9fb..0e2c09b26 100644 --- a/pkg/apis/build/v1alpha2/build_pod_test.go +++ b/pkg/apis/build/v1alpha2/build_pod_test.go @@ -275,6 +275,7 @@ func testBuildPod(t *testing.T, when spec.G, it spec.S) { Git: &corev1alpha1.Git{ URL: "giturl.com/git.git", Revision: "gitrev1234", + InitializeSubmodules: true, }, }, Cache: &buildapi.BuildCacheConfig{ @@ -654,6 +655,11 @@ func testBuildPod(t *testing.T, when spec.G, it spec.S) { Value: build.Spec.Source.Git.Revision, }, ) + assert.Contains(t, pod.Spec.InitContainers[0].Env, + corev1.EnvVar{ + Name: "GIT_INITIALIZE_SUBMODULES", + Value: fmt.Sprintf("%v", build.Spec.Source.Git.InitializeSubmodules), + }) }) it("configures prepare with the blob source", func() { diff --git a/pkg/apis/build/v1alpha2/build_types.go b/pkg/apis/build/v1alpha2/build_types.go index 83b54e4cc..62816278a 100644 --- a/pkg/apis/build/v1alpha2/build_types.go +++ b/pkg/apis/build/v1alpha2/build_types.go @@ -71,13 +71,13 @@ type BuildSpec struct { Cosign *CosignConfig `json:"cosign,omitempty"` DefaultProcess string `json:"defaultProcess,omitempty"` // +listType - Tolerations []corev1.Toleration `json:"tolerations,omitempty"` - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - Affinity *corev1.Affinity `json:"affinity,omitempty"` - RuntimeClassName *string `json:"runtimeClassName,omitempty"` - SchedulerName string `json:"schedulerName,omitempty"` - PriorityClassName string `json:"priorityClassName,omitempty"` - CreationTime string `json:"creationTime,omitempty"` + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + Affinity *corev1.Affinity `json:"affinity,omitempty"` + RuntimeClassName *string `json:"runtimeClassName,omitempty"` + SchedulerName string `json:"schedulerName,omitempty"` + PriorityClassName string `json:"priorityClassName,omitempty"` + CreationTime string `json:"creationTime,omitempty"` } func (bs *BuildSpec) RegistryCacheTag() string { diff --git a/pkg/apis/build/v1alpha2/image_types.go b/pkg/apis/build/v1alpha2/image_types.go index f8553df62..623f8f006 100644 --- a/pkg/apis/build/v1alpha2/image_types.go +++ b/pkg/apis/build/v1alpha2/image_types.go @@ -72,13 +72,13 @@ type ImageBuild struct { Env []corev1.EnvVar `json:"env,omitempty"` Resources corev1.ResourceRequirements `json:"resources,omitempty"` // +listType - Tolerations []corev1.Toleration `json:"tolerations,omitempty"` - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - Affinity *corev1.Affinity `json:"affinity,omitempty"` - RuntimeClassName *string `json:"runtimeClassName,omitempty"` - SchedulerName string `json:"schedulerName,omitempty"` - BuildTimeout *int64 `json:"buildTimeout,omitempty"` - CreationTime string `json:"creationTime,omitempty"` + Tolerations []corev1.Toleration `json:"tolerations,omitempty"` + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + Affinity *corev1.Affinity `json:"affinity,omitempty"` + RuntimeClassName *string `json:"runtimeClassName,omitempty"` + SchedulerName string `json:"schedulerName,omitempty"` + BuildTimeout *int64 `json:"buildTimeout,omitempty"` + CreationTime string `json:"creationTime,omitempty"` } // +k8s:openapi-gen=true diff --git a/pkg/apis/build/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/build/v1alpha2/zz_generated.deepcopy.go index d619d7ded..1411d8cf9 100644 --- a/pkg/apis/build/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/apis/build/v1alpha2/zz_generated.deepcopy.go @@ -468,6 +468,11 @@ func (in *BuilderRecord) DeepCopyInto(out *BuilderRecord) { (*in)[i].DeepCopyInto(&(*out)[i]) } } + if in.SignaturePaths != nil { + in, out := &in.SignaturePaths, &out.SignaturePaths + *out = make([]CosignSignature, len(*in)) + copy(*out, *in) + } return } @@ -523,6 +528,11 @@ func (in *BuilderStatus) DeepCopyInto(out *BuilderStatus) { } } out.Stack = in.Stack + if in.SignaturePaths != nil { + in, out := &in.SignaturePaths, &out.SignaturePaths + *out = make([]CosignSignature, len(*in)) + copy(*out, *in) + } return } @@ -1146,6 +1156,22 @@ func (in *CosignConfig) DeepCopy() *CosignConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CosignSignature) DeepCopyInto(out *CosignSignature) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CosignSignature. +func (in *CosignSignature) DeepCopy() *CosignSignature { + if in == nil { + return nil + } + out := new(CosignSignature) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Image) DeepCopyInto(out *Image) { *out = *in diff --git a/pkg/apis/core/v1alpha1/source_types.go b/pkg/apis/core/v1alpha1/source_types.go index 6bcbef216..e62fbc588 100644 --- a/pkg/apis/core/v1alpha1/source_types.go +++ b/pkg/apis/core/v1alpha1/source_types.go @@ -34,8 +34,9 @@ type Source interface { // +k8s:openapi-gen=true // +k8s:deepcopy-gen=true type Git struct { - URL string `json:"url"` - Revision string `json:"revision"` + URL string `json:"url"` + Revision string `json:"revision"` + InitializeSubmodules bool `json:"initializeSubmodules,omitempty"` } func (g *Git) BuildEnvVars() []corev1.EnvVar { @@ -48,6 +49,10 @@ func (g *Git) BuildEnvVars() []corev1.EnvVar { Name: "GIT_REVISION", Value: g.Revision, }, + { + Name: "GIT_INITIALIZE_SUBMODULES", + Value: strconv.FormatBool(g.InitializeSubmodules), + }, } } @@ -165,17 +170,19 @@ const ( // +k8s:openapi-gen=true // +k8s:deepcopy-gen=true type ResolvedGitSource struct { - URL string `json:"url"` - Revision string `json:"revision"` - SubPath string `json:"subPath,omitempty"` - Type GitSourceKind `json:"type"` + URL string `json:"url"` + Revision string `json:"revision"` + SubPath string `json:"subPath,omitempty"` + Type GitSourceKind `json:"type"` + InitializeSubmodules bool `json:"initializeSubmodules,omitempty"` } func (gs *ResolvedGitSource) SourceConfig() SourceConfig { return SourceConfig{ Git: &Git{ - URL: gs.URL, - Revision: gs.Revision, + URL: gs.URL, + Revision: gs.Revision, + InitializeSubmodules: gs.InitializeSubmodules, }, SubPath: gs.SubPath, } diff --git a/pkg/client/clientset/versioned/clientset.go b/pkg/client/clientset/versioned/clientset.go index 1f9f821ba..5a3c862f1 100644 --- a/pkg/client/clientset/versioned/clientset.go +++ b/pkg/client/clientset/versioned/clientset.go @@ -35,8 +35,7 @@ type Interface interface { KpackV1alpha2() kpackv1alpha2.KpackV1alpha2Interface } -// Clientset contains the clients for groups. Each group has exactly one -// version included in a Clientset. +// Clientset contains the clients for groups. type Clientset struct { *discovery.DiscoveryClient kpackV1alpha1 *kpackv1alpha1.KpackV1alpha1Client diff --git a/pkg/client/informers/externalversions/factory.go b/pkg/client/informers/externalversions/factory.go index 3c52fd62f..efe0c7c1a 100644 --- a/pkg/client/informers/externalversions/factory.go +++ b/pkg/client/informers/externalversions/factory.go @@ -47,6 +47,11 @@ type sharedInformerFactory struct { // startedInformers is used for tracking which informers have been started. // This allows Start() to be called multiple times safely. startedInformers map[reflect.Type]bool + // wg tracks how many goroutines were started. + wg sync.WaitGroup + // shuttingDown is true when Shutdown has been called. It may still be running + // because it needs to wait for goroutines. + shuttingDown bool } // WithCustomResyncConfig sets a custom resync period for the specified informer types. @@ -107,20 +112,39 @@ func NewSharedInformerFactoryWithOptions(client versioned.Interface, defaultResy return factory } -// Start initializes all requested informers. func (f *sharedInformerFactory) Start(stopCh <-chan struct{}) { f.lock.Lock() defer f.lock.Unlock() + if f.shuttingDown { + return + } + for informerType, informer := range f.informers { if !f.startedInformers[informerType] { - go informer.Run(stopCh) + f.wg.Add(1) + // We need a new variable in each loop iteration, + // otherwise the goroutine would use the loop variable + // and that keeps changing. + informer := informer + go func() { + defer f.wg.Done() + informer.Run(stopCh) + }() f.startedInformers[informerType] = true } } } -// WaitForCacheSync waits for all started informers' cache were synced. +func (f *sharedInformerFactory) Shutdown() { + f.lock.Lock() + f.shuttingDown = true + f.lock.Unlock() + + // Will return immediately if there is nothing to wait for. + f.wg.Wait() +} + func (f *sharedInformerFactory) WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool { informers := func() map[reflect.Type]cache.SharedIndexInformer { f.lock.Lock() @@ -167,11 +191,58 @@ func (f *sharedInformerFactory) InformerFor(obj runtime.Object, newFunc internal // SharedInformerFactory provides shared informers for resources in all known // API group versions. +// +// It is typically used like this: +// +// ctx, cancel := context.Background() +// defer cancel() +// factory := NewSharedInformerFactory(client, resyncPeriod) +// defer factory.WaitForStop() // Returns immediately if nothing was started. +// genericInformer := factory.ForResource(resource) +// typedInformer := factory.SomeAPIGroup().V1().SomeType() +// factory.Start(ctx.Done()) // Start processing these informers. +// synced := factory.WaitForCacheSync(ctx.Done()) +// for v, ok := range synced { +// if !ok { +// fmt.Fprintf(os.Stderr, "caches failed to sync: %v", v) +// return +// } +// } +// +// // Creating informers can also be created after Start, but then +// // Start must be called again: +// anotherGenericInformer := factory.ForResource(resource) +// factory.Start(ctx.Done()) type SharedInformerFactory interface { internalinterfaces.SharedInformerFactory - ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + + // Start initializes all requested informers. They are handled in goroutines + // which run until the stop channel gets closed. + Start(stopCh <-chan struct{}) + + // Shutdown marks a factory as shutting down. At that point no new + // informers can be started anymore and Start will return without + // doing anything. + // + // In addition, Shutdown blocks until all goroutines have terminated. For that + // to happen, the close channel(s) that they were started with must be closed, + // either before Shutdown gets called or while it is waiting. + // + // Shutdown may be called multiple times, even concurrently. All such calls will + // block until all goroutines have terminated. + Shutdown() + + // WaitForCacheSync blocks until all started informers' caches were synced + // or the stop channel gets closed. WaitForCacheSync(stopCh <-chan struct{}) map[reflect.Type]bool + // ForResource gives generic access to a shared informer of the matching type. + ForResource(resource schema.GroupVersionResource) (GenericInformer, error) + + // InternalInformerFor returns the SharedIndexInformer for obj using an internal + // client. + InformerFor(obj runtime.Object, newFunc internalinterfaces.NewInformerFunc) cache.SharedIndexInformer + Kpack() build.Interface } diff --git a/pkg/git/fetch.go b/pkg/git/fetch.go index 990f30960..8020d95d0 100644 --- a/pkg/git/fetch.go +++ b/pkg/git/fetch.go @@ -15,8 +15,9 @@ import ( ) type Fetcher struct { - Logger *log.Logger - Keychain GitKeychain + Logger *log.Logger + Keychain GitKeychain + InitializeSubmodules bool } func init() { @@ -71,20 +72,22 @@ func (f Fetcher) Fetch(dir, gitURL, gitRevision, metadataDir string) error { return errors.Wrapf(err, "checking out revision") } - submodules, err := worktree.Submodules() - if err != nil { - return errors.Wrapf(err, "getting submodules") - } - - for _, submodule := range submodules { - f.Logger.Printf("Updating submodule %v", submodule.Config().URL) - submoduleAuth, err := f.Keychain.Resolve(submodule.Config().URL) + if f.InitializeSubmodules { + submodules, err := worktree.Submodules() if err != nil { - return err + return errors.Wrapf(err, "getting submodules") } - err = submodule.Update(&gogit.SubmoduleUpdateOptions{Auth: submoduleAuth, Init: true, RecurseSubmodules: gogit.DefaultSubmoduleRecursionDepth }) - if err != nil { - return errors.Wrapf(err, "updating submodules") + + for _, submodule := range submodules { + f.Logger.Printf("Updating submodule %v", submodule.Config().URL) + submoduleAuth, err := f.Keychain.Resolve(submodule.Config().URL) + if err != nil { + return err + } + err = submodule.Update(&gogit.SubmoduleUpdateOptions{Auth: submoduleAuth, Init: true, RecurseSubmodules: gogit.DefaultSubmoduleRecursionDepth}) + if err != nil { + return errors.Wrapf(err, "updating submodules") + } } } diff --git a/pkg/git/fetch_test.go b/pkg/git/fetch_test.go index a0784f69d..2494688a3 100644 --- a/pkg/git/fetch_test.go +++ b/pkg/git/fetch_test.go @@ -108,6 +108,7 @@ func testGitCheckout(t *testing.T, when spec.G, it spec.S) { }) it("initializes submodules", func() { + fetcher.InitializeSubmodules = true err := fetcher.Fetch(testDir, "https://github.com/git-fixtures/submodule", "master", metadataDir) require.NoError(t, err) diff --git a/pkg/git/remote_git_resolver.go b/pkg/git/remote_git_resolver.go index 6aa366403..af263f840 100644 --- a/pkg/git/remote_git_resolver.go +++ b/pkg/git/remote_git_resolver.go @@ -26,10 +26,11 @@ func (*remoteGitResolver) Resolve(auth transport.AuthMethod, sourceConfig corev1 if err != nil { return corev1alpha1.ResolvedSourceConfig{ Git: &corev1alpha1.ResolvedGitSource{ - URL: sourceConfig.Git.URL, - Revision: sourceConfig.Git.Revision, - Type: corev1alpha1.Unknown, - SubPath: sourceConfig.SubPath, + URL: sourceConfig.Git.URL, + Revision: sourceConfig.Git.Revision, + Type: corev1alpha1.Unknown, + SubPath: sourceConfig.SubPath, + InitializeSubmodules: sourceConfig.Git.InitializeSubmodules, }, }, nil } @@ -38,10 +39,11 @@ func (*remoteGitResolver) Resolve(auth transport.AuthMethod, sourceConfig corev1 if ref.Name().Short() == sourceConfig.Git.Revision { return corev1alpha1.ResolvedSourceConfig{ Git: &corev1alpha1.ResolvedGitSource{ - URL: sourceConfig.Git.URL, - Revision: ref.Hash().String(), - Type: sourceType(ref), - SubPath: sourceConfig.SubPath, + URL: sourceConfig.Git.URL, + Revision: ref.Hash().String(), + Type: sourceType(ref), + SubPath: sourceConfig.SubPath, + InitializeSubmodules: sourceConfig.Git.InitializeSubmodules, }, }, nil } @@ -49,10 +51,11 @@ func (*remoteGitResolver) Resolve(auth transport.AuthMethod, sourceConfig corev1 return corev1alpha1.ResolvedSourceConfig{ Git: &corev1alpha1.ResolvedGitSource{ - URL: sourceConfig.Git.URL, - Revision: sourceConfig.Git.Revision, - Type: corev1alpha1.Commit, - SubPath: sourceConfig.SubPath, + URL: sourceConfig.Git.URL, + Revision: sourceConfig.Git.Revision, + Type: corev1alpha1.Commit, + SubPath: sourceConfig.SubPath, + InitializeSubmodules: sourceConfig.Git.InitializeSubmodules, }, }, nil } diff --git a/pkg/openapi/openapi_generated.go b/pkg/openapi/openapi_generated.go index 341644396..c585658c9 100644 --- a/pkg/openapi/openapi_generated.go +++ b/pkg/openapi/openapi_generated.go @@ -101,6 +101,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "github.com/pivotal/kpack/pkg/apis/build/v1alpha2.ClusterStoreStatus": schema_pkg_apis_build_v1alpha2_ClusterStoreStatus(ref), "github.com/pivotal/kpack/pkg/apis/build/v1alpha2.CosignAnnotation": schema_pkg_apis_build_v1alpha2_CosignAnnotation(ref), "github.com/pivotal/kpack/pkg/apis/build/v1alpha2.CosignConfig": schema_pkg_apis_build_v1alpha2_CosignConfig(ref), + "github.com/pivotal/kpack/pkg/apis/build/v1alpha2.CosignSignature": schema_pkg_apis_build_v1alpha2_CosignSignature(ref), "github.com/pivotal/kpack/pkg/apis/build/v1alpha2.Image": schema_pkg_apis_build_v1alpha2_Image(ref), "github.com/pivotal/kpack/pkg/apis/build/v1alpha2.ImageBuild": schema_pkg_apis_build_v1alpha2_ImageBuild(ref), "github.com/pivotal/kpack/pkg/apis/build/v1alpha2.ImageBuilder": schema_pkg_apis_build_v1alpha2_ImageBuilder(ref), @@ -2799,11 +2800,24 @@ func schema_pkg_apis_build_v1alpha2_BuilderStatus(ref common.ReferenceCallback) Format: "", }, }, + "signaturePaths": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("github.com/pivotal/kpack/pkg/apis/build/v1alpha2.CosignSignature"), + }, + }, + }, + }, + }, }, }, }, Dependencies: []string{ - "github.com/pivotal/kpack/pkg/apis/core/v1alpha1.BuildStack", "github.com/pivotal/kpack/pkg/apis/core/v1alpha1.BuildpackMetadata", "github.com/pivotal/kpack/pkg/apis/core/v1alpha1.Condition", "github.com/pivotal/kpack/pkg/apis/core/v1alpha1.OrderEntry"}, + "github.com/pivotal/kpack/pkg/apis/build/v1alpha2.CosignSignature", "github.com/pivotal/kpack/pkg/apis/core/v1alpha1.BuildStack", "github.com/pivotal/kpack/pkg/apis/core/v1alpha1.BuildpackMetadata", "github.com/pivotal/kpack/pkg/apis/core/v1alpha1.Condition", "github.com/pivotal/kpack/pkg/apis/core/v1alpha1.OrderEntry"}, } } @@ -3237,15 +3251,10 @@ func schema_pkg_apis_build_v1alpha2_ClusterBuildpackSpec(ref common.ReferenceCal SchemaProps: spec.SchemaProps{ Type: []string{"object"}, Properties: map[string]spec.Schema{ - "source": { - VendorExtensible: spec.VendorExtensible{ - Extensions: spec.Extensions{ - "x-kubernetes-list-type": "", - }, - }, + "image": { SchemaProps: spec.SchemaProps{ - Default: map[string]interface{}{}, - Ref: ref("github.com/pivotal/kpack/pkg/apis/core/v1alpha1.ImageSource"), + Type: []string{"string"}, + Format: "", }, }, "serviceAccountRef": { @@ -3257,7 +3266,7 @@ func schema_pkg_apis_build_v1alpha2_ClusterBuildpackSpec(ref common.ReferenceCal }, }, Dependencies: []string{ - "github.com/pivotal/kpack/pkg/apis/core/v1alpha1.ImageSource", "k8s.io/api/core/v1.ObjectReference"}, + "k8s.io/api/core/v1.ObjectReference"}, } } @@ -3831,6 +3840,33 @@ func schema_pkg_apis_build_v1alpha2_CosignConfig(ref common.ReferenceCallback) c } } +func schema_pkg_apis_build_v1alpha2_CosignSignature(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "signingSecret": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "targetDigest": { + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + Required: []string{"signingSecret", "targetDigest"}, + }, + }, + } +} + func schema_pkg_apis_build_v1alpha2_Image(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -5149,6 +5185,12 @@ func schema_pkg_apis_core_v1alpha1_Git(ref common.ReferenceCallback) common.Open Format: "", }, }, + "initializeSubmodules": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, }, Required: []string{"url", "revision"}, }, @@ -5380,6 +5422,12 @@ func schema_pkg_apis_core_v1alpha1_ResolvedGitSource(ref common.ReferenceCallbac Format: "", }, }, + "initializeSubmodules": { + SchemaProps: spec.SchemaProps{ + Type: []string{"boolean"}, + Format: "", + }, + }, }, Required: []string{"url", "revision", "type"}, }, diff --git a/pkg/reconciler/sourceresolver/sourceresolver_test.go b/pkg/reconciler/sourceresolver/sourceresolver_test.go index 439a93463..2be7762b3 100644 --- a/pkg/reconciler/sourceresolver/sourceresolver_test.go +++ b/pkg/reconciler/sourceresolver/sourceresolver_test.go @@ -77,8 +77,9 @@ func testSourceResolver(t *testing.T, when spec.G, it spec.S) { ServiceAccountName: serviceAccount, Source: corev1alpha1.SourceConfig{ Git: &corev1alpha1.Git{ - URL: "https://github.com/build-me", - Revision: "1234", + URL: "https://github.com/build-me", + Revision: "1234", + InitializeSubmodules: true, }, }, }, @@ -86,9 +87,10 @@ func testSourceResolver(t *testing.T, when spec.G, it spec.S) { resolvedSource := corev1alpha1.ResolvedSourceConfig{ Git: &corev1alpha1.ResolvedGitSource{ - URL: "https://example.com/something", - Revision: "abcdef", - Type: corev1alpha1.Branch, + URL: "https://example.com/something", + Revision: "abcdef", + Type: corev1alpha1.Branch, + InitializeSubmodules: true, }, }