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


Golang manifest.Service類代碼示例

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


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

示例1: TestDefaultNetworkName

func TestDefaultNetworkName(t *testing.T) {
	networks := manifest.Networks{}

	s := manifest.Service{
		Networks: networks,
	}

	assert.Equal(t, s.NetworkName(), "")
}
開發者ID:convox,項目名稱:rack,代碼行數:9,代碼來源:service_test.go

示例2: generateManifest

func generateManifest(dir string, def string) error {
	if exists("Procfile") {
		pf, err := readProcfile("Procfile")
		if err != nil {
			return err
		}

		m := manifest.Manifest{
			Services: make(map[string]manifest.Service),
		}

		for _, e := range pf {
			me := manifest.Service{
				Build: manifest.Build{
					Context: ".",
				},
				Command: manifest.Command{
					String: e.Command,
				},
				Labels: make(manifest.Labels),
				Ports:  make(manifest.Ports, 0),
			}

			switch e.Name {
			case "web":
				me.Labels["convox.port.443.protocol"] = "tls"
				me.Labels["convox.port.443.proxy"] = "true"

				me.Ports = append(me.Ports, manifest.Port{
					Balancer:  80,
					Container: 4000,
					Public:    true,
				})
				me.Ports = append(me.Ports, manifest.Port{
					Balancer:  443,
					Container: 4001,
					Public:    true,
				})
			}

			m.Services[e.Name] = me
		}

		data, err := yaml.Marshal(m)

		if err != nil {
			return err
		}

		// write the generated docker-compose.yml and return
		return writeFile("docker-compose.yml", data, 0644)
	}

	// write the default if we get here
	return writeAsset("docker-compose.yml", def)
}
開發者ID:convox,項目名稱:rack,代碼行數:56,代碼來源:init.go

示例3: TestTag

func TestTag(t *testing.T) {
	s := manifest.Service{
		Name: "foo",
	}
	assert.Equal(t, s.Tag("api"), "api/foo")

	s = manifest.Service{
		Name: "foo_bar",
	}
	assert.Equal(t, s.Tag("api"), "api/foo-bar")
}
開發者ID:convox,項目名稱:rack,代碼行數:11,代碼來源:service_test.go

示例4: TestNetworkName

func TestNetworkName(t *testing.T) {
	networks := manifest.Networks{
		"foo": manifest.InternalNetwork{
			"external": manifest.ExternalNetwork{
				Name: "foonet",
			},
		},
	}

	s := manifest.Service{
		Networks: networks,
	}

	assert.Equal(t, s.NetworkName(), "foonet")
}
開發者ID:convox,項目名稱:rack,代碼行數:15,代碼來源:service_test.go

示例5: TestLabelsByPrefix

func TestLabelsByPrefix(t *testing.T) {

	labels := manifest.Labels{
		"foofake": "label",
		"foo_foo": "under_bar",
		"foo-bar": "hypen-string",
		"te-st":   "hypen-string",
		"bahtest": "hypen-string",
	}

	s := manifest.Service{
		Labels: labels,
	}

	prefixed := s.LabelsByPrefix("foo")
	assert.Equal(t, map[string]string{
		"foofake": "label",
		"foo_foo": "under_bar",
		"foo-bar": "hypen-string",
	}, prefixed)
}
開發者ID:convox,項目名稱:rack,代碼行數:21,代碼來源:service_test.go


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