diff --git a/go.mod b/go.mod index c6265ffc8..5929227ab 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/onsi/gomega v1.28.0 github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 github.com/schollz/progressbar/v3 v3.13.1 - github.com/shipwright-io/build v0.11.1-0.20231012075424-0fa3ffa49266 + github.com/shipwright-io/build v0.12.0 github.com/spf13/cobra v1.7.0 github.com/spf13/pflag v1.0.5 github.com/texttheater/golang-levenshtein/levenshtein v0.0.0-20200805054039-cae8b0eaed6c diff --git a/go.sum b/go.sum index 35892ffd0..00eb886e7 100644 --- a/go.sum +++ b/go.sum @@ -383,8 +383,8 @@ github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+e github.com/schollz/progressbar/v3 v3.13.1 h1:o8rySDYiQ59Mwzy2FELeHY5ZARXZTVJC7iHD6PEFUiE= github.com/schollz/progressbar/v3 v3.13.1/go.mod h1:xvrbki8kfT1fzWzBT/UZd9L6GA+jdL7HAgq2RFnO6fQ= github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ= -github.com/shipwright-io/build v0.11.1-0.20231012075424-0fa3ffa49266 h1:vnHHjfCFndLWciuuRhvbQ4stEBnGXwGb7blAh9svLUQ= -github.com/shipwright-io/build v0.11.1-0.20231012075424-0fa3ffa49266/go.mod h1:VtpWnqEi98H6GHRiPh2DK5f6uzZnPuYRhTm6AO1cuTo= +github.com/shipwright-io/build v0.12.0 h1:uK3nLHfyMMJzsId3B0Ta4frufYRnlHDcm/BNurt2DvI= +github.com/shipwright-io/build v0.12.0/go.mod h1:VtpWnqEi98H6GHRiPh2DK5f6uzZnPuYRhTm6AO1cuTo= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= diff --git a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1alpha1/source.go b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1alpha1/source.go index 089a95cc8..8528529ce 100644 --- a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1alpha1/source.go +++ b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1alpha1/source.go @@ -65,3 +65,13 @@ type Source struct { // +optional Credentials *corev1.LocalObjectReference `json:"credentials,omitempty"` } + +// IsLocalCopyType tells if we have an entry of the type local +func IsLocalCopyType(sources []BuildSource) (int, bool) { + for i, bs := range sources { + if bs.Type == LocalCopy { + return i, true + } + } + return -1, false +} diff --git a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/build_conversion.go b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/build_conversion.go index a611063cb..c246cd528 100644 --- a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/build_conversion.go +++ b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/build_conversion.go @@ -48,6 +48,14 @@ func (src *Build) ConvertTo(ctx context.Context, obj *unstructured.Unstructured) alphaBuild.ObjectMeta.Annotations[v1alpha1.AnnotationBuildRunDeletion] = strconv.FormatBool(*src.Spec.Retention.AtBuildDeletion) } + // convert OCIArtifact to Bundle + if src.Spec.Source.OCIArtifact != nil { + alphaBuild.Spec.Source.BundleContainer = &v1alpha1.BundleContainer{ + Image: src.Spec.Source.OCIArtifact.Image, + Prune: (*v1alpha1.PruneOption)(src.Spec.Source.OCIArtifact.Prune), + } + } + mapito, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&alphaBuild) if err != nil { ctxlog.Error(ctx, err, "failed structuring the newObject") @@ -98,23 +106,35 @@ func (src *Build) ConvertFrom(ctx context.Context, obj *unstructured.Unstructure func (dest *BuildSpec) ConvertFrom(orig *v1alpha1.BuildSpec) error { // Handle BuildSpec Source specSource := Source{} - if orig.Source.BundleContainer != nil { - specSource.Type = OCIArtifactType - specSource.OCIArtifact = &OCIArtifact{ - Image: orig.Source.BundleContainer.Image, - Prune: (*PruneOption)(orig.Source.BundleContainer.Prune), - } - if orig.Source.Credentials != nil { - specSource.OCIArtifact.PullSecret = &orig.Source.Credentials.Name + + // only interested on spec.sources as long as an item of the list + // is of the type LocalCopy. Otherwise, we move into bundle or git types. + index, isLocal := v1alpha1.IsLocalCopyType(orig.Sources) + if isLocal { + specSource.Type = LocalType + specSource.LocalSource = &Local{ + Name: orig.Sources[index].Name, + Timeout: orig.Sources[index].Timeout, } } else { - specSource.Type = GitType - specSource.GitSource = &Git{ - URL: orig.Source.URL, - Revision: orig.Source.Revision, - } - if orig.Source.Credentials != nil { - specSource.GitSource.CloneSecret = &orig.Source.Credentials.Name + if orig.Source.BundleContainer != nil { + specSource.Type = OCIArtifactType + specSource.OCIArtifact = &OCIArtifact{ + Image: orig.Source.BundleContainer.Image, + Prune: (*PruneOption)(orig.Source.BundleContainer.Prune), + } + if orig.Source.Credentials != nil { + specSource.OCIArtifact.PullSecret = &orig.Source.Credentials.Name + } + } else { + specSource.Type = GitType + specSource.GitSource = &Git{ + URL: orig.Source.URL, + Revision: orig.Source.Revision, + } + if orig.Source.Credentials != nil { + specSource.GitSource.CloneSecret = &orig.Source.Credentials.Name + } } } specSource.ContextDir = orig.Source.ContextDir @@ -133,9 +153,8 @@ func (dest *BuildSpec) ConvertFrom(orig *v1alpha1.BuildSpec) error { // Handle BuildSpec Strategy dest.Strategy = Strategy{ - Name: orig.StrategyName(), - Kind: (*BuildStrategyKind)(orig.Strategy.Kind), - APIVersion: orig.Strategy.APIVersion, + Name: orig.StrategyName(), + Kind: (*BuildStrategyKind)(orig.Strategy.Kind), } // Handle BuildSpec ParamValues @@ -155,6 +174,17 @@ func (dest *BuildSpec) ConvertFrom(orig *v1alpha1.BuildSpec) error { dest.ParamValues = append(dest.ParamValues, dockerfileParam) } + // handle spec.Builder migration + if orig.Builder != nil { + builderParam := ParamValue{ + Name: "builder-image", + SingleValue: &SingleValue{ + Value: &orig.Builder.Image, + }, + } + dest.ParamValues = append(dest.ParamValues, builderParam) + } + // Handle BuildSpec Output dest.Output.Image = orig.Output.Image dest.Output.Insecure = orig.Output.Insecure @@ -195,8 +225,16 @@ func (dest *BuildSpec) ConvertFrom(orig *v1alpha1.BuildSpec) error { } func (dest *BuildSpec) ConvertTo(bs *v1alpha1.BuildSpec) error { - // Handle BuildSpec Source - bs.Source = getAlphaBuildSource(*dest) + // Handle BuildSpec Sources or Source + if dest.Source.Type == LocalType && dest.Source.LocalSource != nil { + bs.Sources = append(bs.Sources, v1alpha1.BuildSource{ + Name: dest.Source.LocalSource.Name, + Type: v1alpha1.LocalCopy, + Timeout: dest.Source.LocalSource.Timeout, + }) + } else { + bs.Source = getAlphaBuildSource(*dest) + } // Handle BuildSpec Trigger if dest.Trigger != nil { @@ -213,9 +251,8 @@ func (dest *BuildSpec) ConvertTo(bs *v1alpha1.BuildSpec) error { // Handle BuildSpec Strategy bs.Strategy = v1alpha1.Strategy{ - Name: dest.StrategyName(), - Kind: (*v1alpha1.BuildStrategyKind)(dest.Strategy.Kind), - APIVersion: dest.Strategy.APIVersion, + Name: dest.StrategyName(), + Kind: (*v1alpha1.BuildStrategyKind)(dest.Strategy.Kind), } // Handle BuildSpec Builder, TODO @@ -229,6 +266,12 @@ func (dest *BuildSpec) ConvertTo(bs *v1alpha1.BuildSpec) error { continue } + if p.Name == "builder-image" && p.SingleValue != nil { + bs.Builder = &v1alpha1.Image{ + Image: *p.SingleValue.Value, + } + continue + } param := v1alpha1.ParamValue{} p.convertToAlpha(¶m) bs.ParamValues = append(bs.ParamValues, param) @@ -273,6 +316,7 @@ func (dest *BuildSpec) ConvertTo(bs *v1alpha1.BuildSpec) error { } bs.Volumes = append(bs.Volumes, aux) } + return nil } @@ -284,11 +328,15 @@ func (p ParamValue) convertToAlpha(dest *v1alpha1.ParamValue) { } if p.ConfigMapValue != nil { - dest.ConfigMapValue = &v1alpha1.ObjectKeyRef{} - dest.ConfigMapValue = (*v1alpha1.ObjectKeyRef)(p.ConfigMapValue) + dest.SingleValue = &v1alpha1.SingleValue{ + ConfigMapValue: (*v1alpha1.ObjectKeyRef)(p.ConfigMapValue), + } } + if p.SecretValue != nil { - dest.SecretValue = (*v1alpha1.ObjectKeyRef)(p.SecretValue) + dest.SingleValue = &v1alpha1.SingleValue{ + SecretValue: (*v1alpha1.ObjectKeyRef)(p.SecretValue), + } } dest.Name = p.Name @@ -325,9 +373,11 @@ func convertBetaParamValue(orig v1alpha1.ParamValue) ParamValue { } if orig.ConfigMapValue != nil { + p.SingleValue = &SingleValue{} p.ConfigMapValue = (*ObjectKeyRef)(orig.ConfigMapValue) } if orig.SecretValue != nil { + p.SingleValue = &SingleValue{} p.SecretValue = (*ObjectKeyRef)(orig.SecretValue) } diff --git a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildrun_conversion.go b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildrun_conversion.go index cb7d64811..41180e9ae 100644 --- a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildrun_conversion.go +++ b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildrun_conversion.go @@ -13,6 +13,7 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/utils/pointer" ) // ensure v1beta1 implements the Conversion interface @@ -35,15 +36,32 @@ func (src *BuildRun) ConvertTo(ctx context.Context, obj *unstructured.Unstructur return err } alphaBuildRun.Spec.BuildSpec = &newBuildSpec - } else { + } else if src.Spec.Build.Name != nil { alphaBuildRun.Spec.BuildRef = &v1alpha1.BuildRef{ - Name: src.Spec.Build.Name, + Name: *src.Spec.Build.Name, } } + // BuildRunSpec Sources + if src.Spec.Source != nil && src.Spec.Source.Type == LocalType && src.Spec.Source.LocalSource != nil { + alphaBuildRun.Spec.Sources = append(alphaBuildRun.Spec.Sources, v1alpha1.BuildSource{ + Name: src.Spec.Source.LocalSource.Name, + Type: v1alpha1.LocalCopy, + Timeout: src.Spec.Source.LocalSource.Timeout, + }) + } + // BuildRunSpec ServiceAccount - alphaBuildRun.Spec.ServiceAccount = &v1alpha1.ServiceAccount{ - Name: src.Spec.ServiceAccount, + // With the deprecation of serviceAccount.Generate, serviceAccount is set to ".generate" to have the SA created on fly. + if src.Spec.ServiceAccount != nil && *src.Spec.ServiceAccount == ".generate" { + alphaBuildRun.Spec.ServiceAccount = &v1alpha1.ServiceAccount{ + Name: &src.ObjectMeta.Name, + Generate: pointer.Bool(true), + } + } else { + alphaBuildRun.Spec.ServiceAccount = &v1alpha1.ServiceAccount{ + Name: src.Spec.ServiceAccount, + } } // BuildRunSpec Timeout @@ -119,14 +137,12 @@ func (src *BuildRun) ConvertFrom(ctx context.Context, obj *unstructured.Unstruct src.Spec.ConvertFrom(&alphaBuildRun.Spec) - sources := []SourceResult{} + var sourceStatus *SourceResult for _, s := range alphaBuildRun.Status.Sources { - sr := SourceResult{ - Name: s.Name, + sourceStatus = &SourceResult{ Git: (*GitSourceResult)(s.Git), OciArtifact: (*OciArtifactSourceResult)(s.Bundle), } - sources = append(sources, sr) } conditions := []Condition{} @@ -142,8 +158,16 @@ func (src *BuildRun) ConvertFrom(ctx context.Context, obj *unstructured.Unstruct conditions = append(conditions, ct) } + if alphaBuildRun.Status.FailureDetails != nil { + src.Status.FailureDetails = &FailureDetails{ + Reason: alphaBuildRun.Status.FailureDetails.Reason, + Message: alphaBuildRun.Status.FailureDetails.Message, + Location: (*Location)(alphaBuildRun.Status.FailureDetails.Location), + } + } + src.Status = BuildRunStatus{ - Sources: sources, + Source: sourceStatus, Output: (*Output)(alphaBuildRun.Status.Output), Conditions: conditions, TaskRunName: alphaBuildRun.Status.LatestTaskRunRef, @@ -164,14 +188,25 @@ func (src *BuildRun) ConvertFrom(ctx context.Context, obj *unstructured.Unstruct func (dest *BuildRunSpec) ConvertFrom(orig *v1alpha1.BuildRunSpec) error { // BuildRunSpec BuildSpec - dest.Build = &ReferencedBuild{} if orig.BuildSpec != nil { - if dest.Build.Build != nil { - dest.Build.Build.ConvertFrom(orig.BuildSpec) - } + dest.Build.Build = &BuildSpec{} + dest.Build.Build.ConvertFrom(orig.BuildSpec) } if orig.BuildRef != nil { - dest.Build.Name = orig.BuildRef.Name + dest.Build.Name = &orig.BuildRef.Name + } + + // only interested on spec.sources as long as an item of the list + // is of the type LocalCopy. Otherwise, we move into bundle or git types. + index, isLocal := v1alpha1.IsLocalCopyType(orig.Sources) + if isLocal { + dest.Source = &BuildRunSource{ + Type: LocalType, + LocalSource: &Local{ + Name: orig.Sources[index].Name, + Timeout: orig.Sources[index].Timeout, + }, + } } if orig.ServiceAccount != nil { @@ -187,16 +222,17 @@ func (dest *BuildRunSpec) ConvertFrom(orig *v1alpha1.BuildRunSpec) error { dest.ParamValues = append(dest.ParamValues, param) } - // Handle BuildSpec Output - dest.Output = &Image{} + // Handle BuildRunSpec Output if orig.Output != nil { - dest.Output.Image = orig.Output.Image - dest.Output.Annotations = orig.Output.Annotations - dest.Output.Labels = orig.Output.Labels - } + dest.Output = &Image{ + Image: orig.Output.Image, + Annotations: orig.Output.Annotations, + Labels: orig.Output.Labels, + } - if orig.Output != nil && orig.Output.Credentials != nil { - dest.Output.PushSecret = &orig.Output.Credentials.Name + if orig.Output.Credentials != nil { + dest.Output.PushSecret = &orig.Output.Credentials.Name + } } // BuildRunSpec State diff --git a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildrun_types.go b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildrun_types.go index af06728f7..7a40e822b 100644 --- a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildrun_types.go +++ b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildrun_types.go @@ -29,15 +29,21 @@ type ReferencedBuild struct { // Name of the referent; More info: http://kubernetes.io/docs/user-guide/identifiers#names // // +optional - Name string `json:"name,omitempty"` + Name *string `json:"name,omitempty"` } // BuildRunSpec defines the desired state of BuildRun type BuildRunSpec struct { // Build refers to an embedded build specification + // This field is mandatory + // + Build ReferencedBuild `json:"build"` + + // Source refers to the location where the source code is, + // this could only be a local source // // +optional - Build *ReferencedBuild `json:"build,omitempty"` + Source *BuildRunSource `json:"source,omitempty"` // ServiceAccount refers to the kubernetes serviceaccount // which is used for resource control. @@ -104,8 +110,6 @@ const ( // SourceResult holds the results emitted from the different sources type SourceResult struct { - // Name is the name of source - Name string `json:"name"` // Git holds the results emitted from the // source step of type git @@ -156,11 +160,10 @@ type Output struct { // BuildRunStatus defines the observed state of BuildRun type BuildRunStatus struct { - // Sources holds the results emitted from the step definition - // of different sources + // Source holds the results emitted from the source step // // +optional - Sources []SourceResult `json:"sources,omitempty"` + Source *SourceResult `json:"source,omitempty"` // Output holds the results emitted from step definition of an output // @@ -373,8 +376,8 @@ func (brs *BuildRunStatus) SetCondition(condition *Condition) { // BuildName returns the name of the associated build, which can be a referenced // build resource or an embedded build specification func (buildrunSpec *BuildRunSpec) BuildName() string { - if buildrunSpec.Build != nil { - return buildrunSpec.Build.Name + if buildrunSpec.Build.Name != nil { + return *buildrunSpec.Build.Name } // Only BuildRuns with a ReferencedBuild can actually return a proper Build name diff --git a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildstrategy.go b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildstrategy.go index 3bcf80fe2..1997a63f6 100644 --- a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildstrategy.go +++ b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildstrategy.go @@ -187,10 +187,6 @@ type Strategy struct { // BuildStrategyKind indicates the kind of the buildstrategy, namespaced or cluster scoped. Kind *BuildStrategyKind `json:"kind,omitempty"` - - // API version of the referent - // +optional - APIVersion *string `json:"apiVersion,omitempty"` } // BuilderStrategy defines the common elements of build strategies diff --git a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildstrategy_conversion.go b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildstrategy_conversion.go index ae803999f..1b0715faf 100644 --- a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildstrategy_conversion.go +++ b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/buildstrategy_conversion.go @@ -41,7 +41,7 @@ func (src *BuildStrategy) ConvertTo(ctx context.Context, obj *unstructured.Unstr } func (src *BuildStrategySpec) ConvertTo(bs *v1alpha1.BuildStrategySpec) { - usesMigratedDockerfileArg := false + usesMigratedDockerfileArg, usesMigratedBuilderArg := false, false bs.Parameters = []v1alpha1.Parameter{} for _, param := range src.Parameters { @@ -50,6 +50,11 @@ func (src *BuildStrategySpec) ConvertTo(bs *v1alpha1.BuildStrategySpec) { continue } + if param.Name == "builder-image" && param.Type == ParameterTypeString && param.Default == nil { + usesMigratedBuilderArg = true + continue + } + bs.Parameters = append(bs.Parameters, v1alpha1.Parameter{ Name: param.Name, Description: param.Description, @@ -99,6 +104,28 @@ func (src *BuildStrategySpec) ConvertTo(bs *v1alpha1.BuildStrategySpec) { } } + if usesMigratedBuilderArg { + // Migrate to legacy argument + + for commandIndex, command := range buildStep.Command { + if strings.Contains(command, "$(params.builder-image)") { + buildStep.Command[commandIndex] = strings.ReplaceAll(command, "$(params.builder-image)", "$(build.builder.image)") + } + } + + for argIndex, arg := range buildStep.Args { + if strings.Contains(arg, "$(params.builder-image)") { + buildStep.Args[argIndex] = strings.ReplaceAll(arg, "$(params.builder-image)", "$(build.builder.image)") + } + } + + for envIndex, env := range buildStep.Env { + if strings.Contains(env.Value, "$(params.builder-image)") { + buildStep.Env[envIndex].Value = strings.ReplaceAll(env.Value, "$(params.builder-image)", "$(build.builder.image)") + } + } + } + bs.BuildSteps = append(bs.BuildSteps, buildStep) } @@ -141,7 +168,7 @@ func (src *BuildStrategy) ConvertFrom(ctx context.Context, obj *unstructured.Uns func (src *BuildStrategySpec) ConvertFrom(bs v1alpha1.BuildStrategySpec) { src.Steps = []Step{} - usesDockerfile := false + usesDockerfile, usesBuilderImage := false, false for _, brStep := range bs.BuildSteps { step := Step{ @@ -168,6 +195,10 @@ func (src *BuildStrategySpec) ConvertFrom(bs v1alpha1.BuildStrategySpec) { usesDockerfile = true step.Command[commandIndex] = strings.ReplaceAll(command, "$(build.dockerfile)", "$(params.dockerfile)") } + if strings.Contains(command, "$(build.builder.image)") { + usesBuilderImage = true + step.Command[commandIndex] = strings.ReplaceAll(command, "$(build.builder.image)", "$(params.builder-image)") + } } for argIndex, arg := range step.Args { @@ -179,6 +210,10 @@ func (src *BuildStrategySpec) ConvertFrom(bs v1alpha1.BuildStrategySpec) { usesDockerfile = true step.Args[argIndex] = strings.ReplaceAll(arg, "$(build.dockerfile)", "$(params.dockerfile)") } + if strings.Contains(arg, "$(build.builder.image)") { + usesBuilderImage = true + step.Args[argIndex] = strings.ReplaceAll(arg, "$(build.builder.image)", "$(params.builder-image)") + } } for envIndex, env := range step.Env { @@ -190,6 +225,10 @@ func (src *BuildStrategySpec) ConvertFrom(bs v1alpha1.BuildStrategySpec) { usesDockerfile = true step.Env[envIndex].Value = strings.ReplaceAll(env.Value, "$(build.dockerfile)", "$(params.dockerfile)") } + if strings.Contains(env.Value, "$(build.builder.image)") { + usesBuilderImage = true + step.Env[envIndex].Value = strings.ReplaceAll(env.Value, "$(build.builder.image)", "$(params.builder-image)") + } } src.Steps = append(src.Steps, step) @@ -217,6 +256,14 @@ func (src *BuildStrategySpec) ConvertFrom(bs v1alpha1.BuildStrategySpec) { }) } + if usesBuilderImage { + src.Parameters = append(src.Parameters, Parameter{ + Name: "builder-image", + Description: "The builder image.", + Type: ParameterTypeString, + }) + } + src.SecurityContext = (*BuildStrategySecurityContext)(bs.SecurityContext) src.Volumes = []BuildStrategyVolume{} diff --git a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/source.go b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/source.go index ee1bcfa72..dad731678 100644 --- a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/source.go +++ b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/source.go @@ -36,6 +36,9 @@ type Local struct { // // +optional Timeout *metav1.Duration `json:"timeout,omitempty"` + + // Name of the local step + Name string `json:"name,omitempty"` } // Git describes the git repository to pull @@ -101,4 +104,21 @@ type Source struct { // // +optional GitSource *Git `json:"git,omitempty"` + + // LocalSource + // + // +optional + LocalSource *Local `json:"local,omitempty"` +} + +// BuildRunSource describes the local source to use +type BuildRunSource struct { + // Type is the BuildRunSource qualifier, the type of the data-source. + // Only LocalType is supported. + // + // +optional + Type BuildSourceType `json:"type,omitempty"` + // LocalSource + // + LocalSource *Local `json:"local,omitempty"` } diff --git a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/zz_generated.deepcopy.go b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/zz_generated.deepcopy.go index 45d8944af..4c3dc1dfe 100644 --- a/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/zz_generated.deepcopy.go +++ b/vendor/github.com/shipwright-io/build/pkg/apis/build/v1beta1/zz_generated.deepcopy.go @@ -204,12 +204,34 @@ func (in *BuildRunRetention) DeepCopy() *BuildRunRetention { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *BuildRunSource) DeepCopyInto(out *BuildRunSource) { + *out = *in + if in.LocalSource != nil { + in, out := &in.LocalSource, &out.LocalSource + *out = new(Local) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BuildRunSource. +func (in *BuildRunSource) DeepCopy() *BuildRunSource { + if in == nil { + return nil + } + out := new(BuildRunSource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BuildRunSpec) DeepCopyInto(out *BuildRunSpec) { *out = *in - if in.Build != nil { - in, out := &in.Build, &out.Build - *out = new(ReferencedBuild) + in.Build.DeepCopyInto(&out.Build) + if in.Source != nil { + in, out := &in.Source, &out.Source + *out = new(BuildRunSource) (*in).DeepCopyInto(*out) } if in.ServiceAccount != nil { @@ -274,12 +296,10 @@ func (in *BuildRunSpec) DeepCopy() *BuildRunSpec { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *BuildRunStatus) DeepCopyInto(out *BuildRunStatus) { *out = *in - if in.Sources != nil { - in, out := &in.Sources, &out.Sources - *out = make([]SourceResult, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } + if in.Source != nil { + in, out := &in.Source, &out.Source + *out = new(SourceResult) + (*in).DeepCopyInto(*out) } if in.Output != nil { in, out := &in.Output, &out.Output @@ -984,6 +1004,11 @@ func (in *ReferencedBuild) DeepCopyInto(out *ReferencedBuild) { *out = new(BuildSpec) (*in).DeepCopyInto(*out) } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } return } @@ -1046,6 +1071,11 @@ func (in *Source) DeepCopyInto(out *Source) { *out = new(Git) (*in).DeepCopyInto(*out) } + if in.LocalSource != nil { + in, out := &in.LocalSource, &out.LocalSource + *out = new(Local) + (*in).DeepCopyInto(*out) + } return } @@ -1139,11 +1169,6 @@ func (in *Strategy) DeepCopyInto(out *Strategy) { *out = new(BuildStrategyKind) **out = **in } - if in.APIVersion != nil { - in, out := &in.APIVersion, &out.APIVersion - *out = new(string) - **out = **in - } return } diff --git a/vendor/github.com/shipwright-io/build/pkg/bundle/bundle.go b/vendor/github.com/shipwright-io/build/pkg/bundle/bundle.go index 44a932222..38cf216ed 100644 --- a/vendor/github.com/shipwright-io/build/pkg/bundle/bundle.go +++ b/vendor/github.com/shipwright-io/build/pkg/bundle/bundle.go @@ -240,6 +240,10 @@ func Unpack(in io.Reader, targetPath string) error { } var target = filepath.Join(targetPath, header.Name) + if strings.Contains(target, "..") { + return fmt.Errorf("targetPath validation failed, path contains unexpected special elements") + } + switch header.Typeflag { case tar.TypeDir: if err := os.MkdirAll(target, os.FileMode(header.Mode)); err != nil { diff --git a/vendor/modules.txt b/vendor/modules.txt index b58a3b351..9d8844d86 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -331,7 +331,7 @@ github.com/sabhiram/go-gitignore # github.com/schollz/progressbar/v3 v3.13.1 ## explicit; go 1.13 github.com/schollz/progressbar/v3 -# github.com/shipwright-io/build v0.11.1-0.20231012075424-0fa3ffa49266 +# github.com/shipwright-io/build v0.12.0 ## explicit; go 1.20 github.com/shipwright-io/build/pkg/apis/build/v1alpha1 github.com/shipwright-io/build/pkg/apis/build/v1beta1