### Install go-ps Library Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/mitchellh/go-ps/README.md Install the go-ps library using the standard go get command. ```bash $ go get github.com/mitchellh/go-ps ... ``` -------------------------------- ### Install Cobra Library Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/spf13/cobra/README.md Use 'go get' to install the latest version of the Cobra library. ```bash go get -u github.com/spf13/cobra@latest ``` -------------------------------- ### Install and Run Local Go Doc Site Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Installs and runs a local Go Doc site using `pkgsite`. Ensure you have Go installed and configured. ```sh go install golang.org/x/pkgsite/cmd/pkgsite@latest pkgsite ``` -------------------------------- ### Install go-yaml v2 Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/sigs.k8s.io/yaml/goyaml.v2/README.md Use 'go get' to install the go-yaml v2 package. This command fetches and installs the specified package and its dependencies. ```bash go get gopkg.in/yaml.v2 ``` -------------------------------- ### Install and Import kubernetes-sigs/yaml Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/sigs.k8s.io/yaml/README.md Install the package using go get and import it in your Go projects. ```bash go get sigs.k8s.io/yaml ``` ```go import "sigs.k8s.io/yaml" ``` -------------------------------- ### Install yaml package Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/gopkg.in/yaml.v3/README.md Use `go get` to install the yaml package for your Go project. ```bash go get gopkg.in/yaml.v3 ``` -------------------------------- ### Deploy Example Application Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/s3files/access_points/README.md Apply the Kubernetes manifests to create PersistentVolumes, PersistentVolumeClaims, and StorageClass for the S3 Files access point example. ```sh kubectl apply -f examples/kubernetes/s3files/access_points/specs/example.yaml ``` -------------------------------- ### Navigate to the Multiple Pods Example Directory Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/s3files/multiple_pods/README.md Change the current directory to the specific example that demonstrates multiple pod access. ```sh cd aws-efs-csi-driver/examples/kubernetes/s3files/multiple_pods/ ``` -------------------------------- ### Install uuid Package Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/google/uuid/README.md Use 'go get' to install the uuid package. This command fetches and installs the package and its dependencies. ```sh go get github.com/google/uuid ``` -------------------------------- ### Example Data Output from App1 Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/multiple_pods/README.md This is an example of the output seen when tailing 'out1.txt' from the 'app1' pod, showing timestamped entries. ```text ... Mon Mar 22 18:18:22 UTC 2021 Mon Mar 22 18:18:27 UTC 2021 Mon Mar 22 18:18:32 UTC 2021 Mon Mar 22 18:18:37 UTC 2021 ... ``` -------------------------------- ### Deploy Example Application using kubectl Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/s3files/volume_path/README.md Apply the example PersistentVolume, PersistentVolumeClaim, and StorageClass configuration to your Kubernetes cluster using kubectl. This command deploys the necessary resources for the S3 Files volume path example. ```sh kubectl apply -f examples/kubernetes/s3files/volume_path/specs/example.yaml ``` -------------------------------- ### Navigate to the Multiple Pods Example Directory Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/multiple_pods/README.md Change directory to the specific example folder for demonstrating multiple pod access to EFS. ```sh cd aws-efs-csi-driver/examples/kubernetes/efs/multiple_pods/ ``` -------------------------------- ### Deploy StatefulSet Example Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/s3files/statefulset/README.md Apply the example configuration to deploy a StatefulSet that uses an S3 Filesystem. Ensure you have kubectl configured to interact with your Kubernetes cluster. ```sh kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-efs-csi-driver/master/examples/kubernetes/s3files/statefulset/specs/example.yaml ``` -------------------------------- ### Deploy EFS CSI Driver Example Resources Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/encryption_in_transit/README.md Apply the necessary Kubernetes manifests for the storage class, persistent volume, persistent volume claim, and pod to deploy the example. ```bash kubectl apply -f examples/kubernetes/efs/encryption_in_transit/specs/storageclass.yaml kubectl apply -f examples/kubernetes/efs/encryption_in_transit/specs/pv.yaml kubectl apply -f examples/kubernetes/efs/encryption_in_transit/specs/claim.yaml kubectl apply -f examples/kubernetes/efs/encryption_in_transit/specs/pod.yaml ``` -------------------------------- ### Install json-iterator/go Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/json-iterator/go/README.md Install the json-iterator/go library using the go get command. This is the standard method for adding Go packages to your project. ```bash go get github.com/json-iterator/go ``` -------------------------------- ### Fix Static Example Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/emicklei/go-restful/v3/CHANGES.md The static example has been fixed for accuracy and clarity. Thanks to Arthur. ```go - fixed static example (thanks Arthur ) ``` -------------------------------- ### Configure go-codegen Plugin Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/aws/smithy-go/README.md Example configuration for the `go-codegen` build plugin in `smithy-build.json`. This setup applies the plugin to Smithy models, specifies the service and module, and enables Go module generation with a specific Go directive. ```json { "version": "1.0", "sources": [ "models" ], "maven": { "dependencies": [ "software.amazon.smithy.go:smithy-go-codegen:0.1.0" ] }, "plugins": { "go-codegen": { "service": "example.weather#Weather", "module": "github.com/example/weather", "generateGoMod": true, "goDirective": "1.24" } } } ``` -------------------------------- ### Deploy EFS StatefulSet Example Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/statefulset/README.md Apply the example EFS StatefulSet configuration to your Kubernetes cluster. ```sh kubectl apply -f https://raw.githubusercontent.com/kubernetes-sigs/aws-efs-csi-driver/master/examples/kubernetes/efs/statefulset/specs/example.yaml ``` -------------------------------- ### Install godbus/dbus Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/godbus/dbus/v5/README.md Install the dbus package using the go get command. Requires Go 1.12 or later. ```bash go get github.com/godbus/dbus/v5 ``` -------------------------------- ### Install Ginkgo Locally Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/onsi/ginkgo/v2/CONTRIBUTING.md Installs the Ginkgo CLI locally. Ensure all tests pass after making changes. ```bash go install "./..." ``` -------------------------------- ### Coexist klog/v1 and klog/v2 Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/k8s.io/klog/v2/README.md Example demonstrating how to use both klog/v1 and klog/v2 simultaneously within the same application. ```go import ( "k8s.io/klog/v1" "k8s.io/klog/v2" ) func main() { klog.InitFlags(nil) klogv1.InitFlags(nil) // ... rest of your code } ``` -------------------------------- ### Deploy Example Application using kubectl Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/access_points/README.md Apply the Kubernetes manifests for Persistent Volumes, Persistent Volume Claims, and Storage Classes to deploy the example application. This command assumes your YAML file is named 'example.yaml'. ```sh >> kubectl apply -f examples/kubernetes/efs/volume_path/specs/example.yaml ``` -------------------------------- ### Deploy Example Application Pod Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/static_provisioning/README.md Apply the YAML configuration for the sample application pod that will utilize the EFS persistent volume. ```sh kubectl apply -f examples/kubernetes/efs/static_provisioning/specs/pod.yaml ``` -------------------------------- ### Example ttrpc Plugin Usage in protoc Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/containerd/ttrpc/README.md This example demonstrates how to use the ttrpc plugin with a gogo vanity binary. It is recommended to use protobuild for managing protobufs, but protoc can be used directly. ```go package main import ( "github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/protoc-gen-gogo" "github.com/gogo/protobuf/protoc-gen-gogo/generator" "github.com/containerd/ttrpc" ) func main() { protoc_gen_gogo.Plugin.Register(&ttrpc.Plugin{}) generator.Execute(protoc_gen_gogo.Plugin.Client()) } ``` -------------------------------- ### Update Swagger12 and OpenAPI Example Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/emicklei/go-restful/v3/CHANGES.md The example for Swagger12 and OpenAPI has been updated to reflect current best practices and features. ```go - Update example for Swagger12 and OpenAPI ``` -------------------------------- ### Example Persistent Volume Output Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/s3files/static_provisioning/README.md This is an example of the output you should see when monitoring Persistent Volumes, indicating a successful binding. ```sh $ kubectl get pv -w NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE s3files-pv 5Gi RWO Retain Bound default/s3files-claim 3m31s ``` -------------------------------- ### Coexist glog and klog Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/k8s.io/klog/v2/README.md Example showing how to initialize and synchronize flags between glog and klog. It also demonstrates using stderr for combined output. ```go import ( "flag" "k8s.io/klog/v2" "github.com/golang/glog" ) func main() { klog.InitFlags(nil) glog.InitFlags() // Set alsologtostderr to true for combined output to stderr flag.Set("alsologtostderr", "true") // ... rest of your code } ``` -------------------------------- ### Update Swagger/OpenAPI Example Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/emicklei/go-restful/v3/CHANGES.md This update includes changes to the example for Swagger12 and OpenAPI. Ensure your import statements are correct for swagger users. ```go [IMPORTANT] For swagger users, change your import statement to: swagger "github.com/emicklei/go-restful-swagger12" ``` -------------------------------- ### Example Calculation for Container Memory Limit Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/parameters.md An example demonstrating the calculation of container memory limit for 50 volumes and 10 concurrent mounts, suggesting a minimum limit of 1.4 GiB. ```plaintext ((50 × 12) + (10 × 30)) × 1.5 = 1,350 MiB ``` -------------------------------- ### Deploy EFS Volume Example Application Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/volume_path/README.md Apply the PersistentVolume, PersistentVolumeClaim, and StorageClass definitions to your Kubernetes cluster to deploy the example application. ```sh kubectl apply -f examples/kubernetes/efs/volume_path/specs/example.yaml ``` -------------------------------- ### Ginkgo Spec Example Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/onsi/ginkgo/v2/README.md This example demonstrates a typical Ginkgo test suite structure, including BeforeEach, When, Context, It, and various Gomega matchers like Expect, Succeed, ContainElement, Equal, MatchError, and Eventually. It also shows SpecTimeout and By for structuring tests. ```go import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" ... ) var _ = Describe("Checking books out of the library", Label("library"), func() { var library *libraries.Library var book *books.Book var valjean *users.User BeforeEach(func() { library = libraries.NewClient() book = &books.Book{ Title: "Les Miserables", Author: "Victor Hugo", } valjean = users.NewUser("Jean Valjean") }) When("the library has the book in question", func() { BeforeEach(func(ctx SpecContext) { Expect(library.Store(ctx, book)).To(Succeed()) }) Context("and the book is available", func() { It("lends it to the reader", func(ctx SpecContext) { Expect(valjean.Checkout(ctx, library, "Les Miserables")).To(Succeed()) Expect(valjean.Books()).To(ContainElement(book)) Expect(library.UserWithBook(ctx, book)).To(Equal(valjean)) }, SpecTimeout(time.Second * 5)) }) Context("but the book has already been checked out", func() { var javert *users.User BeforeEach(func(ctx SpecContext) { javert = users.NewUser("Javert") Expect(javert.Checkout(ctx, library, "Les Miserables")).To(Succeed()) }) It("tells the user", func(ctx SpecContext) { err := valjean.Checkout(ctx, library, "Les Miserables") Expect(err).To(MatchError("Les Miserables is currently checked out")) }, SpecTimeout(time.Second * 5)) It("lets the user place a hold and get notified later", func(ctx SpecContext) { Expect(valjean.Hold(ctx, library, "Les Miserables")).To(Succeed()) Expect(valjean.Holds(ctx)).To(ContainElement(book)) By("when Javert returns the book") Expect(javert.Return(ctx, library, book)).To(Succeed()) By("it eventually informs Valjean") notification := "Les Miserables is ready for pick up" Eventually(ctx, valjean.Notifications).Should(ContainElement(notification)) Expect(valjean.Checkout(ctx, library, "Les Miserables")).To(Succeed()) Expect(valjean.Books(ctx)).To(ContainElement(book)) Expect(valjean.Holds(ctx)).To(BeEmpty()) }, SpecTimeout(time.Second * 10)) }) }) When("the library does not have the book in question", func() { It("tells the reader the book is unavailable", func(ctx SpecContext) { err := valjean.Checkout(ctx, library, "Les Miserables") Expect(err).To(MatchError("Les Miserables is not in the library catalog")) }, SpecTimeout(time.Second * 5)) }) }) ``` -------------------------------- ### Example of Tagging Resources Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/parameters.md Demonstrates how to apply space-separated key:value pairs as tags to Amazon EFS resources. Includes escaping for special characters. ```bash --tags=name:efs-tag-test date:Jan24 ``` ```bash --tags="tag\:name:tag\:value" ``` -------------------------------- ### Deploy EFS Static Provisioning Resources Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/static_provisioning/README.md Apply the StorageClass, PersistentVolume, and PersistentVolumeClaim YAML files to deploy the EFS static provisioning setup. ```sh kubectl apply -f examples/kubernetes/efs/static_provisioning/specs/storageclass.yaml kubectl apply -f examples/kubernetes/efs/static_provisioning/specs/pv.yaml kubectl apply -f examples/kubernetes/efs/static_provisioning/specs/claim.yaml ``` -------------------------------- ### Get opentelemetry-go Project Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md This command fetches the opentelemetry-go project into your Go workspace. Ignore any build constraint warnings. ```go go get -d go.opentelemetry.io/otel ``` -------------------------------- ### Install Latest json-patch Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/gopkg.in/evanphx/json-patch.v4/README.md Use this command to get the latest version of the json-patch library. ```bash go get -u github.com/evanphx/json-patch/v5 ``` -------------------------------- ### Expected Go Module Dependency Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/antlr4-go/antlr/v4/README.md This example illustrates the expected and desired `go get` resolution for the ANTLR4 Go runtime version, which clearly indicates the specific release tag. ```go require ( github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.13.0 ) ``` -------------------------------- ### Define a RESTful WebService in Go Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/emicklei/go-restful/v3/README.md Example of defining a WebService with routes for user retrieval. It specifies the path, supported content types, and defines a GET route for fetching a user by ID. ```go ws := new(restful.WebService) ws. Path("/users") Consumes(restful.MIME_XML, restful.MIME_JSON) Produces(restful.MIME_JSON, restful.MIME_XML) ws.Route(ws.GET("/{user-id}").To(u.findUser). Doc("get a user") Param(ws.PathParameter("user-id", "identifier of the user").DataType("string")) Writes(User{})) ... func (u UserResource) findUser(request *restful.Request, response *restful.Response) { id := request.PathParameter("user-id") ... } ``` -------------------------------- ### Deploy Example Application using kubectl Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/s3files/azid/README.md Apply the Persistent Volume, Persistence Volume Claim, and Storage Class definitions to your Kubernetes cluster using kubectl. ```bash >> kubectl apply -f examples/kubernetes/s3files/azid/specs/example.yaml ``` -------------------------------- ### Create, Snapshot, Clone, and Destroy ZFS Filesystem Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/mistifyio/go-zfs/README.md This Go code demonstrates how to create a ZFS filesystem, take a snapshot of it, clone the snapshot into a new filesystem, and then destroy all created entities. Error handling is omitted for brevity. Requires root privileges and a ZFS pool named 'test'. ```go //assuming a zpool named test //error handling omitted f, err := zfs.CreateFilesystem("test/snapshot-test", nil) ok(t, err) s, err := f.Snapshot("test", nil) ok(t, err) // snapshot is named "test/snapshot-test@test" c, err := s.Clone("test/clone-test", nil) err := c.Destroy() err := s.Destroy() err := f.Destroy() ``` -------------------------------- ### Incorrect Go Module Dependency Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/antlr4-go/antlr/v4/README.md This example shows how `go get` might resolve the ANTLR4 Go runtime version when retrieved from the main ANTLR4 repository, leading to unclear and difficult-to-upgrade module references. ```go require ( github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230219212500-1f9a474cc2dc ) ``` -------------------------------- ### Deploy Sample Applications Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/multiple_pods/README.md Apply the YAML configurations for 'app1' and 'app2' to deploy pods that will consume the EFS persistent volume. ```sh kubectl apply -f specs/pod1.yaml kubectl apply -f specs/pod2.yaml ``` -------------------------------- ### Install AWS EFS CSI Driver using Helm Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/install.md Installs or upgrades the AWS EFS CSI driver release in the 'kube-system' namespace using the Helm chart. Ensure Helm V3 or later is installed. ```sh helm upgrade --install aws-efs-csi-driver --namespace kube-system aws-efs-csi-driver/aws-efs-csi-driver ``` -------------------------------- ### Install Stable json-patch Versions Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/gopkg.in/evanphx/json-patch.v4/README.md Install specific stable versions of the json-patch library using these commands. ```bash go get -u gopkg.in/evanphx/json-patch.v5 ``` ```bash go get -u gopkg.in/evanphx/json-patch.v4 ``` -------------------------------- ### Create Root Logger Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/go-logr/logr/README.md Initialize the root logger early in the application's lifecycle. This example shows creating a logger using a hypothetical 'logimpl' implementation with initial parameters. ```Go func main() { // ... other setup code ... // Create the "root" logger. We have chosen the "logimpl" implementation, // which takes some initial parameters and returns a logr.Logger. logger := logimpl.New(param1, param2) // ... other setup code ... } ``` -------------------------------- ### Example Persistent Volume Status Output Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/static_provisioning/README.md This is an example of the output when a Persistent Volume is successfully bound to a claim. ```sh $ kubectl get pv -w NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE efs-pv 5Gi RWO Retain Bound default/efs-claim 3m31s ``` -------------------------------- ### Example: TagSet and TagOptions for CBOR Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/fxamacker/cbor/v2/README.md Demonstrates creating a TagSet, registering a tag with a specific type, and using it to create decoding and encoding modes for CBOR data. ```go // Use signedCWT struct defined in "Decoding CWT" example. // Create TagSet (safe for concurrency). tags := cbor.NewTagSet() // Register tag COSE_Sign1 18 with signedCWT type. tags.Add( cbor.TagOptions{EncTag: cbor.EncTagRequired, DecTag: cbor.DecTagRequired}, reflect.TypeOf(signedCWT{}), 18) // Create DecMode with immutable tags. dm, _ := cbor.DecOptions{}.DecModeWithTags(tags) // Unmarshal to signedCWT with tag support. var v signedCWT if err := dm.Unmarshal(data, &v); err != nil { return err } // Create EncMode with immutable tags. em, _ := cbor.EncOptions{}.EncModeWithTags(tags) // Marshal signedCWT with tag number. if data, err := cbor.Marshal(v); err != nil { return err } ``` -------------------------------- ### Create and Use fsnotify Watcher in Go Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/fsnotify/fsnotify/README.md This example demonstrates how to create a new fsnotify watcher, set up goroutines to listen for events and errors, add a directory to watch, and handle file modifications. Ensure you handle watcher errors and close the watcher when done. ```go package main import ( "log" "github.com/fsnotify/fsnotify" ) func main() { // Create new watcher. watcher, err := fsnotify.NewWatcher() if err != nil { log.Fatal(err) } defer watcher.Close() // Start listening for events. go func() { for { select { case event, ok := <-watcher.Events: if !ok { return } log.Println("event:", event) if event.Has(fsnotify.Write) { log.Println("modified file:", event.Name) } case err, ok := <-watcher.Errors: if !ok { return } log.Println("error:", err) } } }() // Add a path. err = watcher.Add("/tmp") if err != nil { log.Fatal(err) } // Block main goroutine forever. <-make(chan struct{}) } ``` -------------------------------- ### Install Cobra CLI Generator Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/spf13/cobra/README.md Install the cobra-cli command line program to generate Cobra applications and command files. ```bash go install github.com/spf13/cobra-cli@latest ``` -------------------------------- ### SecureJoin for Creating Directories Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/cyphar/filepath-securejoin/README.md Demonstrates the usage of securejoin.SecureJoin for creating directories, which is a less safe alternative to MkdirAll. ```go path, err := securejoin.SecureJoin(root, unsafePath) err = os.MkdirAll(path, mode) ``` -------------------------------- ### Fix OpenAPI Examples Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/emicklei/go-restful/v3/CHANGES.md This fix addresses issues with OpenAPI examples, ensuring they are correct and up-to-date. Addressed by issue #425. ```go - fix openapi examples (#425) ``` -------------------------------- ### SpdyStream Server Example Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/moby/spdystream/README.md Listens for incoming TCP connections on localhost:8080, accepts them, and serves them using SpdyStream with a handler that mirrors incoming stream data. Requires the client to connect. ```go package main import ( "github.com/moby/spdystream" "net" ) func main() { listener, err := net.Listen("tcp", "localhost:8080") if err != nil { panic(err) } for { conn, err := listener.Accept() if err != nil { panic(err) } spdyConn, err := spdystream.NewConnection(conn, true) if err != nil { panic(err) } go spdyConn.Serve(spdystream.MirrorStreamHandler) } } ``` -------------------------------- ### SpdyStream Client Example Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/moby/spdystream/README.md Connects to a mirroring server without authentication, creates a SPDY stream, writes data to it, reads the echoed data, and closes the stream. Requires a running server on localhost:8080. ```go package main import ( "fmt" "github.com/moby/spdystream" "net" "net/http" ) func main() { conn, err := net.Dial("tcp", "localhost:8080") if err != nil { panic(err) } spdyConn, err := spdystream.NewConnection(conn, false) if err != nil { panic(err) } go spdyConn.Serve(spdystream.NoOpStreamHandler) stream, err := spdyConn.CreateStream(http.Header{}, nil, false) if err != nil { panic(err) } stream.Wait() fmt.Fprint(stream, "Writing to stream") buf := make([]byte, 25) stream.Read(buf) fmt.Println(string(buf)) stream.Close() } ``` -------------------------------- ### Create and Use Framework Instance in Tests Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/k8s.io/kubernetes/test/e2e/framework/README.md Instantiate a framework for tests and define cleanup logic using `AfterEach`. The `It` block contains the actual test implementation. ```go f := framework.NewDefaultFramework("some tests") ginkgo.AfterEach(func() { # Do something with f.ClientSet. }) ginkgo.It("test something", func(ctx context.Context) { # The actual test. }) ``` -------------------------------- ### Run mkall.sh for Old Build System Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/golang.org/x/sys/unix/README.md Use this command to generate Go files for your current OS and architecture when using the old build system. Ensure GOOS and GOARCH are set correctly. ```bash mkall.sh ``` -------------------------------- ### Add JWT HMAC with SHA-512 Authentication Example Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/emicklei/go-restful/v3/CHANGES.md This snippet provides an example of JWT HMAC with SHA-512 authentication. Ensure the necessary libraries are imported. ```go added JWT HMAC with SHA-512 authentication code example (thanks Amim Knabben ) ``` -------------------------------- ### Download Pod and PVC Manifest Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/dynamic_provisioning/README.md Download the example manifest that includes both a Pod definition and a Persistent Volume Claim (PVC). This manifest will be used to test dynamic provisioning. ```bash curl -O https://raw.githubusercontent.com/kubernetes-sigs/aws-efs-csi-driver/master/examples/kubernetes/efs/dynamic_provisioning/specs/pod.yaml ``` -------------------------------- ### Developer Certificate of Origin Example Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/docker/go-units/CONTRIBUTING.md An example of the Developer Certificate of Origin text that must be included in commit messages. This certifies that you have the right to submit the contribution. ```text Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 660 York Street, Suite 102, San Francisco, CA 94110 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. ``` -------------------------------- ### Preview Documentation Changes Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/onsi/ginkgo/v2/CONTRIBUTING.md Builds and serves the Ginkgo documentation locally using Jekyll. This allows you to preview your documentation changes before committing. ```bash bundle && bundle exec jekyll serve ``` -------------------------------- ### Instantiate with Options in Go Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/go.opentelemetry.io/otel/CONTRIBUTING.md Illustrates how to instantiate a type T using a variadic slice of Option. Any required parameters can be passed before the options. ```go func NewT(options ...Option) T {…} ``` -------------------------------- ### Configure Helm Install with Custom Image Repository Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/install.md Installs the driver using Helm, specifying a custom image repository. Replace 'region-code' with your AWS region. ```sh helm upgrade --install aws-efs-csi-driver --namespace kube-system aws-efs-csi-driver/aws-efs-csi-driver --set image.repository=602401143452.dkr.ecr.region-code.amazonaws.com/eks/aws-efs-csi-driver ``` -------------------------------- ### Example EFS File System ID Output Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/multiple_pods/README.md This is an example output format for an Amazon EFS file system ID obtained via the AWS CLI. ```text fs-582a03f3 ``` -------------------------------- ### Extract Sub-list using Slice Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/google/cel-go/ext/README.md The slice(start, end) method returns a new sub-list containing elements from the start index up to (but not including) the end index. ```cel [1,2,3,4].slice(1, 3) // return [2, 3] ``` ```cel [1,2,3,4].slice(2, 4) // return [3, 4] ``` -------------------------------- ### Static Provisioning Workflow Diagram Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/design.md Sequence diagram illustrating the steps involved in static provisioning of EFS volumes. Highlights manual creation of EFS file systems and Kubernetes Persistent Volumes. ```mermaid sequenceDiagram participant C as Customer participant EFS as EFS File System participant K8s as Kubernetes participant App as Application Pod C->>EFS: 1. Create File System C->>K8s: 2. Create PV (with FS ID) C->>K8s: 3. Create PVC K8s->>K8s: 4. Bind PV to PVC C->>K8s: 5. Create Pod with PVC K8s->>App: 6. Schedule Pod App->>EFS: 7. Access via Mount Path Note over C,App: Customer manages file system
and directory structure manually ``` -------------------------------- ### Configure Helm Install to Use FIPS Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/install.md Installs the driver using Helm, forcing it to use FIPS for mounting the file system. This is for environments requiring FIPS compliance. ```sh helm upgrade --install aws-efs-csi-driver --namespace kube-system aws-efs-csi-driver/aws-efs-csi-driver --set useFIPS=true ``` -------------------------------- ### Initialize Procfs and Get Stats Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/prometheus/procfs/README.md Initializes the proc filesystem mount point and retrieves CPU statistics. Use this for basic /proc filesystem access. ```go fs, err := procfs.NewFS("/proc") stats, err := fs.Stat() ``` -------------------------------- ### Apply Static Provisioning Configurations (Explicit Mount Target IP) Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/cross_account_mount/README.md Applies configurations for static provisioning, pinning the mount to a specific IP address using `volumeAttributes.mounttargetip`. This is useful for single-AZ workloads or when DNS prerequisites are not met. ```sh >> kubectl apply -f examples/kubernetes/efs/cross_account_mount/specs/storageclass-static-prov.yaml >> kubectl apply -f examples/kubernetes/efs/cross_account_mount/specs/pv-mounttargetip.yaml >> kubectl apply -f examples/kubernetes/efs/cross_account_mount/specs/claim.yaml >> kubectl apply -f examples/kubernetes/efs/cross_account_mount/specs/pod-static-prov.yaml ``` -------------------------------- ### Configure Helm Install for No Outbound Internet Access Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/install.md Installs the driver using Helm, specifying custom image repositories for sidecar containers. Use this if your cluster lacks outbound internet access. ```sh helm upgrade --install aws-efs-csi-driver --namespace kube-system aws-efs-csi-driver/aws-efs-csi-driver --set sidecars.livenessProbe.image.repository=602401143452.dkr.ecr.region-code.amazonaws.com/eks/livenessprobe \ --set sidecars.node-driver-registrar.image.repository=602401143452.dkr.ecr.region-code.amazonaws.com/eks/csi-node-driver-registrar \ --set sidecars.csiProvisioner.image.repository=602401143452.dkr.ecr.region-code.amazonaws.com/eks/csi-provisioner ``` -------------------------------- ### SecureJoin for Opening Files Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/cyphar/filepath-securejoin/README.md Illustrates the usage of securejoin.SecureJoin for opening files, which is a less safe alternative to OpenInRoot. ```go path, err := securejoin.SecureJoin(root, unsafePath) file, err := os.OpenFile(path, unix.O_PATH|unix.O_CLOEXEC) ``` -------------------------------- ### Example StorageClass Configuration Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/examples/kubernetes/efs/dynamic_provisioning/README.md An example of a StorageClass configuration for Amazon EFS. Ensure you replace `fs-582a03f3` with your actual file system ID and adjust other parameters like `provisioningMode`, `directoryPerms`, and `basePath` as needed. ```yaml fileSystemId: fs-582a03f3 ``` -------------------------------- ### Apply Multiple JSON Patches via CLI Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/gopkg.in/evanphx/json-patch.v4/README.md Use the `json-patch` CLI tool to apply multiple patch files to a JSON document provided via stdin. Install using `go install github.com/evanphx/json-patch/cmd/json-patch`. ```json [ {"op": "replace", "path": "/name", "value": "Jane"}, {"op": "remove", "path": "/height"} ] ``` ```json [ {"op": "add", "path": "/address", "value": "123 Main St"}, {"op": "replace", "path": "/age", "value": "21"} ] ``` ```json { "name": "John", "age": 24, "height": 3.21 } ``` ```bash $ go install github.com/evanphx/json-patch/cmd/json-patch $ cat document.json | json-patch -p patch.1.json -p patch.2.json {"address":"123 Main St","age":"21","name":"Jane"} ``` -------------------------------- ### Dynamic Provisioning Sequence Diagram Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/docs/design.md Illustrates the sequence of operations for dynamic provisioning, including access point creation, PV/PVC binding, and pod scheduling. This diagram is useful for understanding the overall workflow and component interactions. ```mermaid sequenceDiagram actor User participant K8sAPI as Kubernetes API participant CSIP as CSI Provisioner participant CSIDC as EFS CSI Controller participant Kubelet participant CSINode as EFS CSI Node participant EFS rect rgb(240, 248, 255) Note over User,EFS: Provisioning Phase User->>K8sAPI: Creates StorageClass User->>K8sAPI: Creates PVC User->>K8sAPI: Creates Pod with PVC reference CSIP->>CSIP: Watches PVC creation CSIP->>CSIDC: Calls CreateVolume RPC CSIDC->>CSIDC: Parse CreateVolumeRequest parameters from StorageClass CSIDC->>CSIDC: Determine UID/GID from StorageClass or allocate from range CSIDC->>EFS: CreateAccessPoint API call (includes UID/GID, directory path, permissions) EFS-->>CSIDC: AccessPoint created with ID CSIDC->>CSIDC: Generate VolumeId (fileSystemId::accessPointId) CSIDC-->>CSIP: Return CreateVolumeResponse with VolumeId CSIP->>K8sAPI: Create PV object with VolumeId K8sAPI->>K8sAPI: Bind PVC to PV K8sAPI->>Kubelet: Schedule Pod with bound PVC end rect rgb(240, 255, 240) Note over User,EFS: Node Publish Phase K8sAPI->>Kubelet: Schedule Pod to node Kubelet->>CSINode: Call NodePublishVolume RPC CSINode->>CSINode: Parse VolumeId (extract fileSystemId, accessPointId) CSINode->>CSINode: Process volume context and mount options CSINode->>EFS: Mount via efs-utils mount.efs (with accesspoint=ID, tls options) EFS-->>CSINode: Filesystem mounted at target path CSINode-->>Kubelet: NodePublishVolume success Kubelet->>Kubelet: Start pod containers with mounted volume end rect rgb(255, 245, 238) Note over User,EFS: Deletion Phase User->>K8sAPI: Deletes PVC CSIP->>CSIP: Watches PVC deletion CSIP->>CSIDC: Calls DeleteVolume RPC CSIDC->>CSIDC: Parse VolumeId to extract accessPointId opt deleteAccessPointRootDir enabled CSIDC->>EFS: Temporarily mount filesystem CSIDC->>CSIDC: Delete access point root directory and contents CSIDC->>EFS: Unmount filesystem end CSIDC->>EFS: DeleteAccessPoint API call EFS-->>CSIDC: Access Point deleted CSIDC-->>CSIP: Return DeleteVolumeResponse CSIP->>K8sAPI: Delete PV object end ``` -------------------------------- ### Strings.IndexOf Source: https://github.com/kubernetes-sigs/aws-efs-csi-driver/blob/master/vendor/github.com/google/cel-go/ext/README.md Finds the first occurrence of a substring within a string, returning its zero-based index. Optionally, a starting position for the search can be specified. Returns -1 if the substring is not found. An error occurs for negative start positions. ```APIDOC ## Strings.IndexOf ### Description Returns the integer index of the first occurrence of the search string. If the search string is not found the function returns -1. The function also accepts an optional position from which to begin the substring search. If the substring is the empty string, the index where the search starts is returned (zero or custom). ### Signature `.indexOf() -> ` `.indexOf(, ) -> ` ### Examples ``` 'hello mellow'.indexOf('') // returns 0 'hello mellow'.indexOf('ello') // returns 1 'hello mellow'.indexOf('jello') // returns -1 'hello mellow'.indexOf('', 2) // returns 2 'hello mellow'.indexOf('ello', 2) // returns 7 'hello mellow'.indexOf('ello', 20) // returns -1 'hello mellow'.indexOf('ello', -1) // error ``` ```