Exemple #1
0
func updateConfig(conn db.Conn, configPath string) error {
	pathStr, _ := os.LookupEnv(quiltPath)
	if pathStr == "" {
		pathStr = stitch.GetQuiltPath()
	}

	f, err := util.Open(configPath)
	if err != nil {
		f, err = util.Open(filepath.Join(pathStr, configPath))
		if err != nil {
			return err
		}
	}

	defer f.Close()

	sc := scanner.Scanner{
		Position: scanner.Position{
			Filename: configPath,
		},
	}

	spec, err := stitch.New(*sc.Init(bufio.NewReader(f)), pathStr, false)
	if err != nil {
		return err
	}

	return engine.UpdatePolicy(conn, spec)
}
Exemple #2
0
func stop(conn db.Conn, namespace string) {
	specStr := "(define AdminACL (list))"
	if namespace != "" {
		specStr += fmt.Sprintf(` (define Namespace "%s")`, namespace)
	}

	var sc scanner.Scanner
	spec, err := stitch.New(*sc.Init(strings.NewReader(specStr)), "", false)
	if err != nil {
		panic(err)
	}

	err = engine.UpdatePolicy(conn, spec)
	if err != nil {
		panic(err)
	}
}