當前位置: 首頁>>代碼示例>>Golang>>正文


Golang pkg.Package類代碼示例

本文整理匯總了Golang中github.com/cloudfoundry/bosh-init/release/pkg.Package的典型用法代碼示例。如果您正苦於以下問題:Golang Package類的具體用法?Golang Package怎麽用?Golang Package使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Package類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: describeBuilder

func describeBuilder() {
	var mockCtrl *gomock.Controller

	BeforeEach(func() {
		mockCtrl = gomock.NewController(GinkgoT())
	})

	AfterEach(func() {
		mockCtrl.Finish()
	})

	var (
		logger boshlog.Logger

		mockReleaseJobResolver *mock_deployment_release.MockJobResolver
		mockDependencyCompiler *mock_state_job.MockDependencyCompiler
		mockJobListRenderer    *mock_template.MockJobListRenderer
		mockCompressor         *mock_template.MockRenderedJobListCompressor
		mockBlobstore          *mock_blobstore.MockBlobstore

		stateBuilder Builder
	)

	BeforeEach(func() {
		logger = boshlog.NewLogger(boshlog.LevelNone)

		mockReleaseJobResolver = mock_deployment_release.NewMockJobResolver(mockCtrl)
		mockDependencyCompiler = mock_state_job.NewMockDependencyCompiler(mockCtrl)
		mockJobListRenderer = mock_template.NewMockJobListRenderer(mockCtrl)
		mockCompressor = mock_template.NewMockRenderedJobListCompressor(mockCtrl)
		mockBlobstore = mock_blobstore.NewMockBlobstore(mockCtrl)
	})

	Describe("Build", func() {
		var (
			mockRenderedJobList        *mock_template.MockRenderedJobList
			mockRenderedJobListArchive *mock_template.MockRenderedJobListArchive

			jobName            string
			instanceID         int
			deploymentManifest bideplmanifest.Manifest
			fakeStage          *fakebiui.FakeStage

			releasePackageLibyaml *birelpkg.Package
			releasePackageRuby    *birelpkg.Package
			releasePackageCPI     *birelpkg.Package

			expectCompile *gomock.Call
		)

		BeforeEach(func() {
			mockRenderedJobList = mock_template.NewMockRenderedJobList(mockCtrl)
			mockRenderedJobListArchive = mock_template.NewMockRenderedJobListArchive(mockCtrl)

			jobName = "fake-deployment-job-name"
			instanceID = 0

			deploymentManifest = bideplmanifest.Manifest{
				Name: "fake-deployment-name",
				Jobs: []bideplmanifest.Job{
					{
						Name: "fake-deployment-job-name",
						Networks: []bideplmanifest.JobNetwork{
							{
								Name: "fake-network-name",
							},
						},
						Templates: []bideplmanifest.ReleaseJobRef{
							{
								Name:    "fake-release-job-name",
								Release: "fake-release-name",
							},
						},
						Properties: biproperty.Map{
							"fake-job-property": "fake-job-property-value",
						},
					},
				},
				Networks: []bideplmanifest.Network{
					{
						Name: "fake-network-name",
						Type: "fake-network-type",
						CloudProperties: biproperty.Map{
							"fake-network-cloud-property": "fake-network-cloud-property-value",
						},
					},
				},
				Properties: biproperty.Map{
					"fake-job-property": "fake-global-property-value", //overridden by job property value
				},
			}

			fakeStage = fakebiui.NewFakeStage()

			stateBuilder = NewBuilder(
				mockReleaseJobResolver,
				mockDependencyCompiler,
				mockJobListRenderer,
				mockCompressor,
				mockBlobstore,
//.........這裏部分代碼省略.........
開發者ID:vestel,項目名稱:bosh-init,代碼行數:101,代碼來源:builder_test.go

示例2:

package pkg_test

import (
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	. "github.com/cloudfoundry/bosh-init/state/pkg"

	birelpkg "github.com/cloudfoundry/bosh-init/release/pkg"
)

var _ = Describe("DependencyResolver", func() {
	It("supports a single dependency", func() {
		a := birelpkg.Package{Name: "a"}
		b := birelpkg.Package{Name: "b"}
		a.Dependencies = []*birelpkg.Package{&b}

		deps := ResolveDependencies(&a)
		Expect(deps).To(Equal([]*birelpkg.Package{&b}))
	})

	It("supports a transitive dependency", func() {
		a := birelpkg.Package{Name: "a"}
		b := birelpkg.Package{Name: "b"}
		a.Dependencies = []*birelpkg.Package{&b}
		c := birelpkg.Package{Name: "c"}
		b.Dependencies = []*birelpkg.Package{&c}

		deps := ResolveDependencies(&a)
		Expect(deps).To(Equal([]*birelpkg.Package{&c, &b}))
	})
開發者ID:mattcui,項目名稱:bosh-init,代碼行數:31,代碼來源:resolve_dependencies_test.go

示例3: describeRemotePackageCompiler

func describeRemotePackageCompiler() {
	var mockCtrl *gomock.Controller

	BeforeEach(func() {
		mockCtrl = gomock.NewController(GinkgoT())
	})

	AfterEach(func() {
		mockCtrl.Finish()
	})

	var (
		packageRepo bistatepkg.CompiledPackageRepo

		pkgDependency *birelpkg.Package
		pkg           *birelpkg.Package

		mockBlobstore   *mock_blobstore.MockBlobstore
		mockAgentClient *mock_agentclient.MockAgentClient

		archivePath = "fake-archive-path"

		remotePackageCompiler bistatepkg.Compiler

		compiledPackages map[bistatepkg.CompiledPackageRecord]*birelpkg.Package

		expectBlobstoreAdd *gomock.Call
		expectAgentCompile *gomock.Call
	)

	BeforeEach(func() {
		mockBlobstore = mock_blobstore.NewMockBlobstore(mockCtrl)
		mockAgentClient = mock_agentclient.NewMockAgentClient(mockCtrl)

		index := biindex.NewInMemoryIndex()
		packageRepo = bistatepkg.NewCompiledPackageRepo(index)
		remotePackageCompiler = NewRemotePackageCompiler(mockBlobstore, mockAgentClient, packageRepo)

		pkgDependency = &birelpkg.Package{
			Name:        "fake-package-name-dep",
			Fingerprint: "fake-package-fingerprint-dep",
		}

		pkg = &birelpkg.Package{
			Name:         "fake-package-name",
			Fingerprint:  "fake-package-fingerprint",
			SHA1:         "fake-source-package-sha1",
			ArchivePath:  archivePath,
			Dependencies: []*birelpkg.Package{pkgDependency},
		}

		depRecord1 := bistatepkg.CompiledPackageRecord{
			BlobID:   "fake-compiled-package-blob-id-dep",
			BlobSHA1: "fake-compiled-package-sha1-dep",
		}

		compiledPackages = map[bistatepkg.CompiledPackageRecord]*birelpkg.Package{
			depRecord1: pkgDependency,
		}
	})

	JustBeforeEach(func() {
		// add compiled packages to the repo
		for record, dependency := range compiledPackages {
			err := packageRepo.Save(*dependency, record)
			Expect(err).ToNot(HaveOccurred())
		}

		packageSource := biagentclient.BlobRef{
			Name:        "fake-package-name",
			Version:     "fake-package-fingerprint",
			BlobstoreID: "fake-source-package-blob-id",
			SHA1:        "fake-source-package-sha1",
		}
		packageDependencies := []biagentclient.BlobRef{
			{
				Name:        "fake-package-name-dep",
				Version:     "fake-package-fingerprint-dep",
				BlobstoreID: "fake-compiled-package-blob-id-dep",
				SHA1:        "fake-compiled-package-sha1-dep",
			},
		}
		compiledPackageRef := biagentclient.BlobRef{
			Name:        "fake-package-name",
			Version:     "fake-package-version",
			BlobstoreID: "fake-compiled-package-blob-id",
			SHA1:        "fake-compiled-package-sha1",
		}

		expectBlobstoreAdd = mockBlobstore.EXPECT().Add(archivePath).Return("fake-source-package-blob-id", nil).AnyTimes()
		expectAgentCompile = mockAgentClient.EXPECT().CompilePackage(packageSource, packageDependencies).Return(compiledPackageRef, nil).AnyTimes()
	})

	Describe("Compile", func() {
		It("uploads the package archive to the blobstore and then compiles the package with the agent", func() {
			gomock.InOrder(
				expectBlobstoreAdd.Times(1),
				expectAgentCompile.Times(1),
			)

//.........這裏部分代碼省略.........
開發者ID:hanzhefeng,項目名稱:bosh-init,代碼行數:101,代碼來源:remote_package_compiler_test.go

示例4:

package pkg_test

import (
	. "github.com/cloudfoundry/bosh-init/internal/github.com/onsi/ginkgo"
	. "github.com/cloudfoundry/bosh-init/internal/github.com/onsi/gomega"
	birelpkg "github.com/cloudfoundry/bosh-init/release/pkg"

	. "github.com/cloudfoundry/bosh-init/state/pkg"
)

var _ = Describe("DependencyResolver", func() {
	It("supports a single dependency", func() {
		a := birelpkg.Package{Name: "a"}
		b := birelpkg.Package{Name: "b"}
		a.Dependencies = []*birelpkg.Package{&b}

		deps := ResolveDependencies(&a)
		Expect(deps).To(Equal([]*birelpkg.Package{&b}))
	})

	It("supports a transitive dependency", func() {
		a := birelpkg.Package{Name: "a"}
		b := birelpkg.Package{Name: "b"}
		a.Dependencies = []*birelpkg.Package{&b}
		c := birelpkg.Package{Name: "c"}
		b.Dependencies = []*birelpkg.Package{&c}

		deps := ResolveDependencies(&a)
		Expect(deps).To(ContainElement(&b))
		Expect(deps).To(ContainElement(&c))
		Expect(len(deps)).To(Equal(2))
開發者ID:vestel,項目名稱:bosh-init,代碼行數:31,代碼來源:resolve_dependencies_test.go

示例5:

	var (
		index               biindex.Index
		compiledPackageRepo CompiledPackageRepo
		fakeFS              *fakesys.FakeFileSystem
	)

	BeforeEach(func() {
		fakeFS = fakesys.NewFakeFileSystem()
		index = biindex.NewFileIndex("/index_file", fakeFS)
		compiledPackageRepo = NewCompiledPackageRepo(index)
	})

	Context("Save and Find", func() {
		var (
			record     CompiledPackageRecord
			dependency birelpkg.Package
			pkg        birelpkg.Package
		)

		BeforeEach(func() {
			record = CompiledPackageRecord{}
			dependency = birelpkg.Package{
				Name:        "fake-dependency-package",
				Fingerprint: "fake-dependency-fingerprint",
			}
			pkg = birelpkg.Package{
				Name:         "fake-package-name",
				Fingerprint:  "fake-package-fingerprint",
				Dependencies: []*birelpkg.Package{&dependency},
			}
		})
開發者ID:vestel,項目名稱:bosh-init,代碼行數:31,代碼來源:compiled_package_repo_test.go

示例6:

	})

	It("logs compile stages", func() {
		_, err := dependencyCompiler.Compile(releaseJobs, fakeStage)
		Expect(err).ToNot(HaveOccurred())

		Expect(fakeStage.PerformCalls).To(Equal([]*fakebiui.PerformCall{
			{Name: "Compiling package 'fake-release-package-name-1/fake-release-package-fingerprint-1'"},
			{Name: "Compiling package 'fake-release-package-name-2/fake-release-package-fingerprint-2'"},
		}))
	})

	Context("Graph with circular dependency", func() {
		var (
			package1,
			package2,
			package3 *birelpkg.Package
		)
		BeforeEach(func() {
			package1 = &birelpkg.Package{
				Name:         "fake-package-name-1",
				Dependencies: []*birelpkg.Package{},
			}
			package2 = &birelpkg.Package{
				Name:         "fake-package-name-2",
				Dependencies: []*birelpkg.Package{package1},
			}
			package3 = &birelpkg.Package{
				Name:         "fake-package-name-3",
				Dependencies: []*birelpkg.Package{package2},
			}
開發者ID:mattcui,項目名稱:bosh-init,代碼行數:31,代碼來源:dependency_compiler_test.go


注:本文中的github.com/cloudfoundry/bosh-init/release/pkg.Package類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。