Skip to content

Commit

Permalink
upgrade to latest dependencies (#450)
Browse files Browse the repository at this point in the history
bumping knative.dev/eventing 0866e62...eaec729:
  > eaec729 Update actions (# 6427)
  > 7763e03 upgrade to latest dependencies (# 6423)
bumping knative.dev/pkg 9c5a731...f5db225:
  > f5db225 Drop `UserInfo` from logger tagging in webhook. (# 2535)
  > 1777513 Update actions (# 2536)
bumping knative.dev/client 1b03977...458a6b7:
  > 458a6b7 Update actions (# 1695)
  > b696546 Added support for mounting EmptyDir volume type (# 1679)

Signed-off-by: Knative Automation <automation@knative.team>
  • Loading branch information
knative-automation committed Jun 29, 2022
1 parent 94c349e commit a9e79f6
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 46 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ require (
k8s.io/client-go v0.23.8
k8s.io/code-generator v0.23.8
k8s.io/kube-openapi v0.0.0-20220124234850-424119656bbf
knative.dev/eventing v0.32.1-0.20220622112123-0866e62ec48e
knative.dev/eventing v0.32.1-0.20220628020529-eaec7294bc50
knative.dev/hack v0.0.0-20220610014127-dc6c287516dc
knative.dev/pkg v0.0.0-20220621173822-9c5a7317fa9d
knative.dev/pkg v0.0.0-20220629012730-f5db22566a80
)

require (
github.com/hashicorp/hcl v1.0.0
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
gotest.tools/v3 v3.1.0
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9
knative.dev/client v0.32.1-0.20220622110623-1b039776c71c
knative.dev/client v0.32.1-0.20220628021229-458a6b7cca80
)

require (
Expand Down
12 changes: 7 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2305,11 +2305,11 @@ k8s.io/utils v0.0.0-20211116205334-6203023598ed/go.mod h1:jPW/WVKK9YHAvNhRxK0md/
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 h1:HNSDgDCrr/6Ly3WEGKZftiE7IY19Vz2GdbOCyI4qqhc=
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9/go.mod h1:jPW/WVKK9YHAvNhRxK0md/EJ228hCsBRufyofKtW8HA=
knative.dev/caching v0.0.0-20220610113725-9c092893371a/go.mod h1:IcfEPqEP6ma4EcRUcPkwVNx5FWHHWu8w4/eqRQguDwc=
knative.dev/client v0.32.1-0.20220622110623-1b039776c71c h1:uXB3lGaQCSoNgAwbcytl4sWz2Pxmms6tHNG13R6uBUE=
knative.dev/client v0.32.1-0.20220622110623-1b039776c71c/go.mod h1:fXs90e9XWOcg2J3czSfndKG/GrZE96/ONTBH0k2cDus=
knative.dev/client v0.32.1-0.20220628021229-458a6b7cca80 h1:uLFjDbGvJwc5iD10fA/6Ke7FhX1kuw5BysljogwbXCQ=
knative.dev/client v0.32.1-0.20220628021229-458a6b7cca80/go.mod h1:fXs90e9XWOcg2J3czSfndKG/GrZE96/ONTBH0k2cDus=
knative.dev/eventing v0.32.1-0.20220614135415-c1b0ea692715/go.mod h1:WKC5YSu8dhjcSOgrhgB5ipdV9Of/KrcETkJObM67Mhk=
knative.dev/eventing v0.32.1-0.20220622112123-0866e62ec48e h1:JE+Q+cRVpEhCKUAxpjrknbbBG8PZ4oC5M3DtBlsYOiw=
knative.dev/eventing v0.32.1-0.20220622112123-0866e62ec48e/go.mod h1:WKC5YSu8dhjcSOgrhgB5ipdV9Of/KrcETkJObM67Mhk=
knative.dev/eventing v0.32.1-0.20220628020529-eaec7294bc50 h1:CQ3ZxAH2Q+lbkZLnGWBJvznDvmMkBQ3dWln3+X+/0Kw=
knative.dev/eventing v0.32.1-0.20220628020529-eaec7294bc50/go.mod h1:2qC2AfEZG71MjJ55YWbttNuIjK6/cjgvk7tb+GiI1Cg=
knative.dev/hack v0.0.0-20220524153203-12d3e2a7addc/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/hack v0.0.0-20220609132040-fd240e2cef5c/go.mod h1:PHt8x8yX5Z9pPquBEfIj0X66f8iWkWfR0S/sarACJrI=
knative.dev/hack v0.0.0-20220610014127-dc6c287516dc h1:LyqyT+rtgZYfOb3ChGE5jTFApCOcUmAcSV+TzgLxnys=
Expand All @@ -2321,9 +2321,11 @@ knative.dev/networking v0.0.0-20220614203516-07c9d7614c61/go.mod h1:oIETD09Q4GSO
knative.dev/pkg v0.0.0-20220524202603-19adf798efb8/go.mod h1:pApypeWDkGrsMkUDkV6StWXS4CXhwGWuJEID9GGZY0Y=
knative.dev/pkg v0.0.0-20220609131940-865e331abfa5/go.mod h1:pApypeWDkGrsMkUDkV6StWXS4CXhwGWuJEID9GGZY0Y=
knative.dev/pkg v0.0.0-20220610014025-7d607d643ee2/go.mod h1:pApypeWDkGrsMkUDkV6StWXS4CXhwGWuJEID9GGZY0Y=
knative.dev/pkg v0.0.0-20220621173822-9c5a7317fa9d h1:H/naKtQODjCIr9wFb1YOG17CgbkgSFMy5dX0WZnrz6o=
knative.dev/pkg v0.0.0-20220621173822-9c5a7317fa9d/go.mod h1:hmwyuQ6uQlqLVEM4lJGg6LZ12gbnUQv9kH88sA5pLDg=
knative.dev/pkg v0.0.0-20220629012730-f5db22566a80 h1:43x1ZYRDQ9tEslxYEbTr+Fg2QfYPtiw/RXEpIf6BFq0=
knative.dev/pkg v0.0.0-20220629012730-f5db22566a80/go.mod h1:hmwyuQ6uQlqLVEM4lJGg6LZ12gbnUQv9kH88sA5pLDg=
knative.dev/reconciler-test v0.0.0-20220610141926-64ffd15625ec/go.mod h1:/vZ6/AKGYQQPYY/7BSebqt62QrxiJ97T3r1jso9dAJg=
knative.dev/reconciler-test v0.0.0-20220622130523-57e43ca43bda/go.mod h1:KTK98X+RGi33WWJMCECLmELIX3UjrinnmskHDok4hPo=
knative.dev/serving v0.32.1-0.20220621141822-357316355d00 h1:YWCweftFQuy+cflkhYw2a3xQP7mqN5kGyYEGeZSVzsE=
knative.dev/serving v0.32.1-0.20220621141822-357316355d00/go.mod h1:2DTwW8KZVZgsobW0EYhv4nTR8+LhKu2pZhEAoytUqE8=
mvdan.cc/gofumpt v0.1.1/go.mod h1:yXG1r1WqZVKWbVRtBWKWX9+CxGYfA51nSomhM0woR48=
Expand Down
14 changes: 8 additions & 6 deletions vendor/knative.dev/client/pkg/kn/flags/podspec.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,20 @@ func (p *PodSpecFlags) AddFlags(flagset *pflag.FlagSet) []string {
flagNames = append(flagNames, "env-file")

flagset.StringArrayVarP(&p.Mount, "mount", "", []string{},
"Mount a ConfigMap (prefix cm: or config-map:), a Secret (prefix secret: or sc:), or an existing Volume (without any prefix) on the specified directory. "+
"Example: --mount /mydir=cm:myconfigmap, --mount /mydir=secret:mysecret, or --mount /mydir=myvolume. "+
"When a configmap or a secret is specified, a corresponding volume is automatically generated. "+
"You can specify a volume subpath by following the volume name with slash separated path. "+
"Mount a ConfigMap (prefix cm: or config-map:), a Secret (prefix secret: or sc:), an EmptyDir (prefix ed: or emptyDir:)"+
"or an existing Volume (without any prefix) on the specified directory. "+
"Example: --mount /mydir=cm:myconfigmap, --mount /mydir=secret:mysecret, --mount /mydir=emptyDir:myvol "+
"or --mount /mydir=myvolume. When a configmap or a secret is specified, a corresponding volume is "+
"automatically generated. You can specify a volume subpath by following the volume name with slash separated path. "+
"Example: --mount /mydir=cm:myconfigmap/subpath/to/be/mounted. "+
"You can use this flag multiple times. "+
"For unmounting a directory, append \"-\", e.g. --mount /mydir-, which also removes any auto-generated volume.")
flagNames = append(flagNames, "mount")

flagset.StringArrayVarP(&p.Volume, "volume", "", []string{},
"Add a volume from a ConfigMap (prefix cm: or config-map:) or a Secret (prefix secret: or sc:). "+
"Example: --volume myvolume=cm:myconfigmap or --volume myvolume=secret:mysecret. "+
"Add a volume from a ConfigMap (prefix cm: or config-map:) a Secret (prefix secret: or sc:), or "+
"an EmptyDir (prefix ed: or emptyDir:). "+
"Example: --volume myvolume=cm:myconfigmap, --volume myvolume=secret:mysecret or --volume emptyDir:myvol:size=1Gi,type=Memory. "+
"You can use this flag multiple times. "+
"To unset a ConfigMap/Secret reference, append \"-\" to the name, e.g. --volume myvolume-.")
flagNames = append(flagNames, "volume")
Expand Down
159 changes: 131 additions & 28 deletions vendor/knative.dev/client/pkg/kn/flags/podspec_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"strconv"
"strings"

"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/apimachinery/pkg/util/yaml"

corev1 "k8s.io/api/core/v1"
Expand All @@ -35,6 +36,7 @@ type VolumeSourceType int
const (
ConfigMapVolumeSourceType VolumeSourceType = iota
SecretVolumeSourceType
EmptyDirVolumeSourceType
PortFormatErr = "the port specification '%s' is not valid. Please provide in the format 'NAME:PORT', where 'NAME' is optional. Examples: '--port h2c:8080' , '--port 8080'."
)

Expand Down Expand Up @@ -466,6 +468,8 @@ func updateVolume(volume *corev1.Volume, info *volumeSourceInfo) error {
case SecretVolumeSourceType:
volume.ConfigMap = nil
volume.Secret = &corev1.SecretVolumeSource{SecretName: info.volumeSourceName}
case EmptyDirVolumeSourceType:
volume.EmptyDir = &corev1.EmptyDirVolumeSource{Medium: corev1.StorageMedium(info.emptyDirMemoryType), SizeLimit: info.emptyDirSize}
default:
return fmt.Errorf("Invalid VolumeSourceType")
}
Expand All @@ -486,8 +490,7 @@ func updateVolumeMountsFromMap(volumeMounts []corev1.VolumeMount, toUpdate *util
if !existsVolumeNameInVolumes(name, volumes) {
return nil, fmt.Errorf("There is no volume matched with %q", name)
}

volumeMount.ReadOnly = true
volumeMount.ReadOnly = isReadOnlyVolume(name, volumes)
volumeMount.Name = name
volumeMount.SubPath = volumeMountInfo.SubPath
set[volumeMount.MountPath] = true
Expand All @@ -501,7 +504,7 @@ func updateVolumeMountsFromMap(volumeMounts []corev1.VolumeMount, toUpdate *util
if !set[mountPath] {
volumeMounts = append(volumeMounts, corev1.VolumeMount{
Name: name,
ReadOnly: true,
ReadOnly: isReadOnlyVolume(name, volumes),
MountPath: mountPath,
SubPath: volumeMountInfo.SubPath,
})
Expand Down Expand Up @@ -579,38 +582,65 @@ func removeVolumes(volumes []corev1.Volume, toRemove []string, volumeMounts []co
// =======================================================================================

type volumeSourceInfo struct {
volumeSourceType VolumeSourceType
volumeSourceName string
volumeSourceType VolumeSourceType
volumeSourceName string
emptyDirMemoryType string
emptyDirSize *resource.Quantity
}

func newVolumeSourceInfoWithSpecString(spec string) (*volumeSourceInfo, error) {
slices := strings.SplitN(spec, ":", 2)
if len(slices) != 2 {
return nil, fmt.Errorf("argument requires a value that contains the : character; got %q", spec)
slices := strings.SplitN(spec, ":", 3)
if len(slices) < 2 {
return nil, fmt.Errorf("argument requires a value that contains the : character; got %q, %q", spec, slices)
}

var volumeSourceType VolumeSourceType
if len(slices) == 2 {
var volumeSourceType VolumeSourceType

typeString := strings.TrimSpace(slices[0])
volumeSourceName := strings.TrimSpace(slices[1])
typeString := strings.TrimSpace(slices[0])
volumeSourceName := strings.TrimSpace(slices[1])

switch typeString {
case "config-map", "cm":
volumeSourceType = ConfigMapVolumeSourceType
case "secret", "sc":
volumeSourceType = SecretVolumeSourceType
default:
return nil, fmt.Errorf("unsupported volume source type \"%q\"; supported volume source types are \"config-map\" and \"secret\"", slices[0])
}
switch typeString {
case "config-map", "cm":
volumeSourceType = ConfigMapVolumeSourceType
case "secret", "sc":
volumeSourceType = SecretVolumeSourceType
case "emptyDir", "ed":
volumeSourceType = EmptyDirVolumeSourceType
default:
return nil, fmt.Errorf("unsupported volume source type \"%q\"; supported volume source types are \"config-map\" and \"secret\"", slices[0])
}

if len(volumeSourceName) == 0 {
return nil, fmt.Errorf("the name of %s cannot be an empty string", volumeSourceType)
}
if len(volumeSourceName) == 0 {
return nil, fmt.Errorf("the name of %s cannot be an empty string", volumeSourceType)
}

return &volumeSourceInfo{
volumeSourceType: volumeSourceType,
volumeSourceName: volumeSourceName,
}, nil
return &volumeSourceInfo{
volumeSourceType: volumeSourceType,
volumeSourceName: volumeSourceName,
}, nil
} else {
typeString := strings.TrimSpace(slices[0])
switch typeString {
case "config-map", "cm", "secret", "sc":
return nil, fmt.Errorf("incorrect mount details for type %q", typeString)
case "emptyDir", "ed":
volName := slices[1]
edType, edSize, err := getEmptyDirTypeAndSize(slices[2])
if err != nil {
return nil, err
}
return &volumeSourceInfo{
volumeSourceType: EmptyDirVolumeSourceType,
volumeSourceName: volName,
emptyDirMemoryType: edType,
emptyDirSize: edSize,
}, nil
default:
return nil, fmt.Errorf("unsupported volume type \"%q\"; supported volume types are \"config-map or cm\", \"secret or sc\", \"volume or vo\", and \"emptyDir or ed\"", slices[0])
}

}
}

func (vol *volumeSourceInfo) getCanonicalName() string {
Expand Down Expand Up @@ -649,6 +679,15 @@ func (vol *volumeSourceInfo) createEnvFromSource() *corev1.EnvFromSource {

// =======================================================================================

func isReadOnlyVolume(volumeName string, volumes []corev1.Volume) bool {
for _, volume := range volumes {
if volume.Name == volumeName {
return volume.EmptyDir == nil
}
}
return true
}

func existsVolumeNameInVolumes(volumeName string, volumes []corev1.Volume) bool {
for _, volume := range volumes {
if volume.Name == volumeName {
Expand Down Expand Up @@ -714,9 +753,18 @@ func reviseVolumeInfoAndMountsToUpdate(mountsToUpdate *util.OrderedMap, volumesT
})
mountInfo.VolumeName = generatedName
mountsToUpdateRevised.Set(path, mountInfo)

case "emptyDir", "ed":
generatedName := util.GenerateVolumeName(path)
mountInfo := getMountInfo(slices[1])
volumeSourceInfoByName.Set(generatedName, &volumeSourceInfo{
volumeSourceType: EmptyDirVolumeSourceType,
volumeSourceName: slices[1],
emptyDirMemoryType: "",
})
mountInfo.VolumeName = generatedName
mountsToUpdateRevised.Set(path, mountInfo)
default:
return nil, nil, fmt.Errorf("unsupported volume type \"%q\"; supported volume types are \"config-map or cm\", \"secret or sc\", and \"volume or vo\"", slices[0])
return nil, nil, fmt.Errorf("unsupported volume type \"%q\"; supported volume types are \"config-map or cm\", \"secret or sc\", \"volume or vo\", and \"emptyDir or ed\"", slices[0])
}
}
}
Expand All @@ -733,6 +781,61 @@ func reviseVolumeInfoAndMountsToUpdate(mountsToUpdate *util.OrderedMap, volumesT
return volumeSourceInfoByName, mountsToUpdateRevised, nil
}

func getEmptyDirTypeAndSize(value string) (string, *resource.Quantity, error) {
slices := strings.SplitN(value, ",", 2)
formatErr := fmt.Errorf("incorrect format to specify emptyDir type")
repeatErrStr := "cannot repeat the key %q"
var dirType string
var size *resource.Quantity
switch len(slices) {
case 0:
return "", nil, nil
case 1:
typeSizeSlices := strings.SplitN(slices[0], "=", 2)
if len(typeSizeSlices) < 2 {
return "", nil, formatErr
}
switch strings.ToLower(typeSizeSlices[0]) {
case "type":
dirType = typeSizeSlices[1]
case "size":
quantity, err := resource.ParseQuantity(typeSizeSlices[1])
if err != nil {
return "", nil, formatErr
}
size = &quantity
default:
return "", nil, formatErr
}
case 2:
for _, slice := range slices {
typeSizeSlices := strings.SplitN(slice, "=", 2)
if len(typeSizeSlices) < 2 {
return "", nil, formatErr
}
switch strings.ToLower(typeSizeSlices[0]) {
case "type":
if dirType != "" {
return "", nil, fmt.Errorf(repeatErrStr, "type")
}
dirType = typeSizeSlices[1]
case "size":
if size != nil {
return "", nil, fmt.Errorf(repeatErrStr, "size")
}
quantity, err := resource.ParseQuantity(typeSizeSlices[1])
if err != nil {
return "", nil, formatErr
}
size = &quantity
default:
return "", nil, formatErr
}
}
}
return dirType, size, nil
}

func reviseVolumesToRemove(volumeMounts []corev1.VolumeMount, volumesToRemove []string, mountsToRemove []string) []string {
for _, pathToRemove := range mountsToRemove {
for _, volumeMount := range volumeMounts {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion vendor/knative.dev/pkg/webhook/admission.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ func admissionHandler(rootLogger *zap.SugaredLogger, stats StatsReporter, c Admi
logkey.Operation, string(review.Request.Operation),
logkey.Resource, review.Request.Resource.String(),
logkey.SubResource, review.Request.SubResource,
logkey.UserInfo, fmt.Sprint(review.Request.UserInfo))
logkey.UserInfo, review.Request.UserInfo.Username,
)

ctx := logging.WithLogger(r.Context(), logger)
ctx = apis.WithHTTPRequest(ctx, r)
Expand Down
6 changes: 3 additions & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ k8s.io/utils/lru
k8s.io/utils/net
k8s.io/utils/pointer
k8s.io/utils/trace
# knative.dev/client v0.32.1-0.20220622110623-1b039776c71c
# knative.dev/client v0.32.1-0.20220628021229-458a6b7cca80
## explicit; go 1.17
knative.dev/client/pkg/config
knative.dev/client/pkg/dynamic
Expand All @@ -1265,7 +1265,7 @@ knative.dev/client/pkg/sources/v1beta2
knative.dev/client/pkg/util
knative.dev/client/pkg/util/mock
knative.dev/client/pkg/wait
# knative.dev/eventing v0.32.1-0.20220622112123-0866e62ec48e
# knative.dev/eventing v0.32.1-0.20220628020529-eaec7294bc50
## explicit; go 1.16
knative.dev/eventing/pkg/adapter/v2
knative.dev/eventing/pkg/adapter/v2/util/crstatusevent
Expand Down Expand Up @@ -1308,7 +1308,7 @@ knative.dev/hack
knative.dev/networking/pkg/apis/networking
knative.dev/networking/pkg/apis/networking/v1alpha1
knative.dev/networking/pkg/config
# knative.dev/pkg v0.0.0-20220621173822-9c5a7317fa9d
# knative.dev/pkg v0.0.0-20220629012730-f5db22566a80
## explicit; go 1.17
knative.dev/pkg/apis
knative.dev/pkg/apis/duck
Expand Down

0 comments on commit a9e79f6

Please sign in to comment.