an invalid URL or a URL with a blank // scheme is passed through in order to determine if its shorthand for // something else well-known. type Detector interface { // Detect will detect whether the string matches a known pattern to // turn it into a proper URL. Detect(string, string) (string, bool, error) }
schemes must implement to download type Getter interface { // Get downloads the given URL into the given directory. This always // assumes that we're updating and gets the latest version that it can. // // The directory may already exist (if we're updating). If it is in a // format that isn't understood, an error should be returned. Get shouldn't // simply nuke the directory. Get(string, *url.URL) error // GetFile downloads the give URL into the given path. The URL must // reference a single file. If possible, the Getter should check if // the remote end contains the same file and no-op this operation. GetFile(string, *url.URL) error
on the given URL. This is used to // allow clients to let the getters decide which mode to use. ClientMode(*url.URL) (ClientMode, error) // SetClient allows a getter to know it's client // in order to access client's Get functions or // progress tracking. SetClient(*Client) }
context.Background(), //define the destination to where the directory will be stored. This will create the directory if it doesnt exist Dst: "/tmp/gogetter", Dir: true, //the repository with a subdirectory I would like to clone only Src: "github.com/hashicorp/terraform/examples/cross-provider", Mode: getter.ClientModeDir, }
values, static or dynamic from Vault paths and export them into your configuration. Consul Allows you to read values from Consul key and services into a file
TemplateConfigs and returns a pointer to the new // Runner and any error that occurred during creation. runner, err := manger.NewRunner(defaultConfig, false) if err != nil { return err } var out bytes.Buffer go runner.Start() defer runner.Stop() if err = runner.Run(); err != nil { return err } runner.SetOutStream(&out) runner.SetErrStream(&out)
its own type. We want to save the result of the error so we can return that back to the client. The final case is to keep rendering the template CODE EDITOR for { select { case err := <-runner.ErrCh: return err case <-runner.DoneCh: return nil case <-runner.TemplateRenderedCh(): } }
to write a plugin that offloads work to another system. This is especially useful for things that may not fit in the "standard library" of Consul Template, but still need to be shared across multiple instances.”
is also the name of the binary, either a full path or just the program name. It will be executed in a shell with the inherited PATH so e.g. the plugin cat will run the first executable cat that is found on the PATH.