本文整理匯總了Golang中github.com/cloudfoundry/bosh-agent/settings/directories.Provider.TmpDir方法的典型用法代碼示例。如果您正苦於以下問題:Golang Provider.TmpDir方法的具體用法?Golang Provider.TmpDir怎麽用?Golang Provider.TmpDir使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cloudfoundry/bosh-agent/settings/directories.Provider
的用法示例。
在下文中一共展示了Provider.TmpDir方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewWindowsCertManager
func NewWindowsCertManager(fs boshsys.FileSystem, runner boshsys.CmdRunner, dirProvider boshdir.Provider, logger logger.Logger) Manager {
return &windowsCertManager{
fs: fs,
runner: runner,
dirProvider: dirProvider,
logger: logger,
backupPath: path.Join(dirProvider.TmpDir(), "rootCertBackup.sst"),
}
}
示例2:
dirProvider = boshdir.NewProvider(tempDir)
certManager = cert.NewWindowsCertManager(fs, boshsys.NewExecCmdRunner(log), dirProvider, log)
})
AfterEach(func() {
for _, thumbprint := range certThumbprints {
cmd := exec.Command("powershell", "-Command", fmt.Sprintf(removeCertScript, `Cert:\LocalMachine\Root\`+thumbprint))
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).To(BeNil())
Eventually(session).Should(gexec.Exit(0))
}
os.RemoveAll(tempDir)
})
It("should create the tmpDir if doesn't exist", func() {
_, err := os.Stat(dirProvider.TmpDir())
fmt.Println("BEfore", dirProvider.TmpDir(), err)
missing := os.IsNotExist(err)
Expect(missing).To(BeTrue())
err = certManager.UpdateCertificates(validCerts)
Expect(err).To(BeNil())
_, err = os.Stat(dirProvider.TmpDir())
Expect(err).To(BeNil())
})
Context("When TempDir exists", func() {
BeforeEach(func() {
err := fs.MkdirAll(dirProvider.TmpDir(), os.FileMode(0777))
Expect(err).To(BeNil())
})
It("adds certs to the trusted cert chain", func() {