コード例 #1
0
ファイル: service_test.go プロジェクト: convox/rack
func TestDefaultNetworkName(t *testing.T) {
	networks := manifest.Networks{}

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

	assert.Equal(t, s.NetworkName(), "")
}
コード例 #2
0
ファイル: init.go プロジェクト: convox/rack
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)
}
コード例 #3
0
ファイル: service_test.go プロジェクト: convox/rack
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")
}
コード例 #4
0
ファイル: service_test.go プロジェクト: convox/rack
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")
}
コード例 #5
0
ファイル: service_test.go プロジェクト: convox/rack
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)
}