diff --git a/go.mod b/go.mod index 5feac6abb5..79fa3d8ce1 100644 --- a/go.mod +++ b/go.mod @@ -30,9 +30,9 @@ require ( k8s.io/client-go v0.22.5 k8s.io/code-generator v0.22.5 k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c - knative.dev/eventing v0.29.1-0.20220217054812-7a48f4269b6f - knative.dev/hack v0.0.0-20220216040439-0456e8bf6547 - knative.dev/pkg v0.0.0-20220215153400-3c00bb0157b9 + knative.dev/eventing v0.29.1-0.20220221175003-2a69eec1e358 + knative.dev/hack v0.0.0-20220218190734-a8ef7b67feec + knative.dev/pkg v0.0.0-20220217155112-d48172451966 knative.dev/reconciler-test v0.0.0-20220216192840-2c3291f210ce sigs.k8s.io/controller-runtime v0.9.6 ) diff --git a/go.sum b/go.sum index c459e30723..b60d40dad4 100644 --- a/go.sum +++ b/go.sum @@ -2240,17 +2240,19 @@ k8s.io/utils v0.0.0-20210722164352-7f3ee0f31471/go.mod h1:jPW/WVKK9YHAvNhRxK0md/ k8s.io/utils v0.0.0-20210819203725-bdf08cb9a70a/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= k8s.io/utils v0.0.0-20211208161948-7d6a63dca704 h1:ZKMMxTvduyf5WUtREOqg5LiXaN1KO/+0oOQPRFrClpo= k8s.io/utils v0.0.0-20211208161948-7d6a63dca704/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA= -knative.dev/eventing v0.29.1-0.20220217054812-7a48f4269b6f h1:hcX3eV41PawEWk45B7tb14+qIPvRa3qgXUIPwsJECv0= -knative.dev/eventing v0.29.1-0.20220217054812-7a48f4269b6f/go.mod h1:Q6l5svQIhulsqkTQco38HKGCM54Imx7GSIRBASXINAM= +knative.dev/eventing v0.29.1-0.20220221175003-2a69eec1e358 h1:ze96GfPEwFkegFUtZyhJpl1glk6oGi6KfHCxsbV6RwE= +knative.dev/eventing v0.29.1-0.20220221175003-2a69eec1e358/go.mod h1:Q6l5svQIhulsqkTQco38HKGCM54Imx7GSIRBASXINAM= knative.dev/hack v0.0.0-20220118141833-9b2ed8471e30/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/hack v0.0.0-20220209225905-7331bb16ba00/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/hack v0.0.0-20220215185059-b9cb1983b600/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= -knative.dev/hack v0.0.0-20220216040439-0456e8bf6547 h1:lEWsaG/yMLLp3onNushrawsHFXD4LXCXTo5FUUa2GiU= knative.dev/hack v0.0.0-20220216040439-0456e8bf6547/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= +knative.dev/hack v0.0.0-20220218190734-a8ef7b67feec h1:ihYrJkaAT6sJeBUQf0rwOO0//sXUAUG+m/B1t3zBNBI= +knative.dev/hack v0.0.0-20220218190734-a8ef7b67feec/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI= knative.dev/hack/schema v0.0.0-20220215185059-b9cb1983b600/go.mod h1:ffjwmdcrH5vN3mPhO8RrF2KfNnbHeCE2C60A+2cv3U0= knative.dev/pkg v0.0.0-20220118160532-77555ea48cd4/go.mod h1:etVT7Tm8pSDf4RKhGk4r7j/hj3dNBpvT7bO6a6wpahs= -knative.dev/pkg v0.0.0-20220215153400-3c00bb0157b9 h1:u0vYuNe0BTFvbqN8euaauL/kN3jR7mjmxMc+QRnWsUw= knative.dev/pkg v0.0.0-20220215153400-3c00bb0157b9/go.mod h1:6ZoCgi60jSUn/WrwTGNAZbsz5/kmwiZZD8EovSLzYZ4= +knative.dev/pkg v0.0.0-20220217155112-d48172451966 h1:4qXRfR/ZhanbOoJYQwJjmAoFEg3qi5x/KVTRp06HK1U= +knative.dev/pkg v0.0.0-20220217155112-d48172451966/go.mod h1:qymIihGpeunap7KEUhrKRcm0LjhkCjL+n7ryIx2kLH0= knative.dev/reconciler-test v0.0.0-20220215020657-3f8092fb8739/go.mod h1:m2q6+mGqlPsJ6qP0ssMv3x2UBwIgTdTxgxJ6GK5kgu4= knative.dev/reconciler-test v0.0.0-20220216192840-2c3291f210ce h1:EzRwv7mxqEbBE6dQlOXBUuMeq4f2SbM/CTi1pKiXraA= knative.dev/reconciler-test v0.0.0-20220216192840-2c3291f210ce/go.mod h1:m2q6+mGqlPsJ6qP0ssMv3x2UBwIgTdTxgxJ6GK5kgu4= diff --git a/vendor/knative.dev/hack/presubmit-tests.sh b/vendor/knative.dev/hack/presubmit-tests.sh index 08bd85d4a1..679a00e3f9 100644 --- a/vendor/knative.dev/hack/presubmit-tests.sh +++ b/vendor/knative.dev/hack/presubmit-tests.sh @@ -23,7 +23,7 @@ source $(dirname "${BASH_SOURCE[0]}")/library.sh readonly PRESUBMIT_TEST_FAIL_FAST=${PRESUBMIT_TEST_FAIL_FAST:-0} # Extensions or file patterns that don't require presubmit tests. -readonly NO_PRESUBMIT_FILES=(\.png \.gitignore \.gitattributes ^OWNERS ^OWNERS_ALIASES ^AUTHORS) +readonly NO_PRESUBMIT_FILES=(\.png \.gitignore \.gitattributes ^OWNERS ^OWNERS_ALIASES ^AUTHORS \.github/*) # Flag if this is a presubmit run or not. (( IS_PROW )) && [[ ${JOB_TYPE} == "presubmit" ]] && IS_PRESUBMIT=1 || IS_PRESUBMIT=0 diff --git a/vendor/knative.dev/pkg/apis/url.go b/vendor/knative.dev/pkg/apis/url.go index 89a4d2454c..e54cb1d076 100644 --- a/vendor/knative.dev/pkg/apis/url.go +++ b/vendor/knative.dev/pkg/apis/url.go @@ -27,6 +27,7 @@ import ( // URL is an alias of url.URL. // It has custom json marshal methods that enable it to be used in K8s CRDs // such that the CRD resource will have the URL but operator code can can work with url.URL struct +// +kubebuilder:validation:Type=string type URL url.URL // ParseURL attempts to parse the given string as a URL. diff --git a/vendor/knative.dev/pkg/changeset/commit.go b/vendor/knative.dev/pkg/changeset/commit.go index 52c77998f0..3668dfebd1 100644 --- a/vendor/knative.dev/pkg/changeset/commit.go +++ b/vendor/knative.dev/pkg/changeset/commit.go @@ -17,6 +17,7 @@ limitations under the License. package changeset import ( + "bufio" "fmt" "io/ioutil" "os" @@ -28,6 +29,10 @@ import ( const ( commitIDFile = "HEAD" koDataPathEnvName = "KO_DATA_PATH" + // packedRefsFile is a file containing a list of refs, used to compact the + // list of refs instead of storing them on the filesystem directly. + // See https://git-scm.com/docs/git-pack-refs + packedRefsFile = "packed-refs" ) var commitIDRE = regexp.MustCompile(`^[a-f0-9]{40}$`) @@ -41,9 +46,27 @@ func Get() (string, error) { } commitID := strings.TrimSpace(string(data)) if rID := strings.TrimPrefix(commitID, "ref: "); rID != commitID { + // First try to read from the direct ref file - e.g. refs/heads/main data, err := readFileFromKoData(rID) if err != nil { - return "", err + if !os.IsNotExist(err) { + return "", err + } + + // Ref file didn't exist - it might be contained in the packed-refs + // file. + var pferr error + data, pferr = findPackedRef(rID) + // Only return the sub-error if the packed-refs file exists, otherwise + // just let the original error return (e.g. treat it as if we didn't + // even attempt the operation). This is primarily to keep the error + // messages clean. + if pferr != nil { + if os.IsNotExist(pferr) { + return "", err + } + return "", pferr + } } commitID = strings.TrimSpace(string(data)) } @@ -58,9 +81,49 @@ func Get() (string, error) { // to be wrapped into the container from /kodata by ko. If it fails, returns // the error it gets. func readFileFromKoData(filename string) ([]byte, error) { + f, err := koDataFile(filename) + if err != nil { + return nil, err + } + defer f.Close() + return ioutil.ReadAll(f) +} + +// readFileFromKoData tries to open the file with given name under KO_DATA_PATH. +// The file is expected to be wrapped into the container from /kodata by ko. +// If it fails, returns the error it gets. +func koDataFile(filename string) (*os.File, error) { koDataPath := os.Getenv(koDataPathEnvName) if koDataPath == "" { return nil, fmt.Errorf("%q does not exist or is empty", koDataPathEnvName) } - return ioutil.ReadFile(filepath.Join(koDataPath, filename)) + return os.Open(filepath.Join(koDataPath, filename)) +} + +// findPackedRef searches the packed-ref file for ref values. +// This can happen if the # of refs in a repo grows too much - git will try +// and condense them into a file. +// See https://git-scm.com/docs/git-pack-refs +func findPackedRef(ref string) ([]byte, error) { + f, err := koDataFile(packedRefsFile) + if err != nil { + return nil, err + } + defer f.Close() + + scanner := bufio.NewScanner(f) + for scanner.Scan() { + // We only care about lines with ` ` pairs. + // Why this might happen: + // 1. Lines starting with ^ refer to unpeeled tag SHAs + // (e.g. the commits pointed to by annotated tags) + s := strings.Split(scanner.Text(), " ") + if len(s) != 2 { + continue + } + if ref == s[1] { + return []byte(s[0]), nil + } + } + return nil, fmt.Errorf("%q ref not found in packed-refs", ref) } diff --git a/vendor/modules.txt b/vendor/modules.txt index 70d35e1ee6..f19013e91f 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1149,7 +1149,7 @@ k8s.io/utils/buffer k8s.io/utils/integer k8s.io/utils/pointer k8s.io/utils/trace -# knative.dev/eventing v0.29.1-0.20220217054812-7a48f4269b6f +# knative.dev/eventing v0.29.1-0.20220221175003-2a69eec1e358 ## explicit; go 1.16 knative.dev/eventing/pkg/adapter/v2 knative.dev/eventing/pkg/adapter/v2/util/crstatusevent @@ -1247,10 +1247,10 @@ knative.dev/eventing/test/test_images/event-sender knative.dev/eventing/test/test_images/heartbeats knative.dev/eventing/test/test_images/performance knative.dev/eventing/test/test_images/print -# knative.dev/hack v0.0.0-20220216040439-0456e8bf6547 +# knative.dev/hack v0.0.0-20220218190734-a8ef7b67feec ## explicit; go 1.14 knative.dev/hack -# knative.dev/pkg v0.0.0-20220215153400-3c00bb0157b9 +# knative.dev/pkg v0.0.0-20220217155112-d48172451966 ## explicit; go 1.17 knative.dev/pkg/apis knative.dev/pkg/apis/duck