Ejemplo n.º 1
0
func printAppDetail(a *application.Application) {
	var output []string
	var outputEnv []string
	fields := structs.New(a).Fields()

	fmt.Println("\nApplication Details:")

	for _, f := range fields {
		if f.Name() == "Addresses" {
			output = append(output, fmt.Sprintf("%s:\n", f.Name()))
			for _, v := range a.Addresses {
				output = append(output, fmt.Sprintf("……|%s", v))
			}
		} else if f.Name() == "Certificates" {
			output = append(output, fmt.Sprintf("%s:| Use \"--full\" to see certificates", f.Name()))
			output = append(output, fmt.Sprintf("– PrivateKey: |%s\n", a.Certificates.PrivateKey))
		} else if f.Name() == "CreatedAt" {
			output = append(output, fmt.Sprintf("%s: | %s\n", f.Name(), utils.FormatTime(a.CreatedAt+"Z")))
		} else if f.Name() == "CurrentDeployments" {
			output = append(output, fmt.Sprintf("%s:\n", f.Name()))
			for k, v := range a.CurrentDeployments {
				output = append(output, fmt.Sprintf("……|%s: %s", k, v))
			}
		} else if f.Name() == "Environment" {
			outputEnv = append(outputEnv, fmt.Sprintf("%s:\n", f.Name()))
			for k, v := range a.Environment {
				outputEnv = append(outputEnv, fmt.Sprintf("%s=%s", k, v))
			}
		} else if f.Name() == "Location" {
			output = append(output, fmt.Sprintf("%s: |Identifier: %s\t UUID: %s\n", f.Name(), a.Location["identifier"], a.Location["uuid"]))
		} else if f.Name() == "Metadata" {
			mdata, _ := json.Marshal(a.Metadata)
			output = append(output, fmt.Sprintf("%s: |%s\n", f.Name(), mdata))
		} else if f.Name() == "Ports" {
			output = append(output, fmt.Sprintf("%s:\n", f.Name()))
			for _, v := range a.Ports {
				output = append(output, fmt.Sprintf("……|%s", v))
			}
		} else if f.Name() == "Rules" {
			output = append(output, fmt.Sprintf("%s:\n", f.Name()))
			for k, v := range a.Rules {
				output = append(output, fmt.Sprintf("……|%s=%v", k, v))
			}
		} else if f.Name() == "SSLPorts" {
			output = append(output, fmt.Sprintf("%s:\n", f.Name()))
			for _, v := range a.SSLPorts {
				output = append(output, fmt.Sprintf("……|%s", v))
			}
		} else if f.Name() == "UpdatedAt" {
			output = append(output, fmt.Sprintf("%s: | %s\n", f.Name(), utils.FormatTime(a.UpdatedAt+"Z")))
		} else {
			output = append(output, fmt.Sprintf("%s: |%v\n", f.Name(), f.Value()))
		}
	}

	fmt.Println(columnize.SimpleFormat(output))
	fmt.Println("\n")
	fmt.Println(columnize.SimpleFormat(outputEnv))
}
Ejemplo n.º 2
0
func printSecretDetail(s *secrets.Secret) {
	var output []string
	fields := structs.New(s).Fields()

	fmt.Println("\nSecret Details:\n")

	for _, f := range fields {
		if f.Name() == "CreatedAt" {
			output = append(output, fmt.Sprintf("%s: | %s\n", f.Name(), utils.FormatTime(s.CreatedAt+"Z")))
		} else if f.Name() == "UpdatedAt" {
			output = append(output, fmt.Sprintf("%s: | %s\n", f.Name(), utils.FormatTime(s.UpdatedAt+"Z")))
		} else {
			output = append(output, fmt.Sprintf("%s: |%v\n", f.Name(), f.Value()))
		}
	}

	fmt.Println(columnize.SimpleFormat(output))
}
Ejemplo n.º 3
0
//Prints details of an Account. Fields are formatted to be more human readable.
func printAccountDetail(a *authorization.Account) {
	var output []string
	fields := structs.New(a).Fields()

	fmt.Println("\nAccount Details:\n")

	for _, f := range fields {
		if f.Name() == "CreatedAt" {
			output = append(output, fmt.Sprintf("%s: | %s\n", f.Name(), utils.FormatTime(a.CreatedAt+"Z")))
		} else if f.Name() == "UpdatedAt" {
			output = append(output, fmt.Sprintf("%s: | %s\n", f.Name(), utils.FormatTime(a.UpdatedAt+"Z")))
		} else {
			output = append(output, fmt.Sprintf("%s: |%s\n", f.Name(), f.Value()))
		}
	}

	fmt.Println(columnize.SimpleFormat(output))
}
Ejemplo n.º 4
0
func printSecretBrief(apps []*secrets.Secret) {
	var output []string

	output = append(output, fmt.Sprintf("UUID | Created At | Labels"))

	for i := 0; i < len(apps); i++ {
		output = append(output, fmt.Sprintf("%s | %s | %s", apps[i].Uuid, utils.FormatTime(apps[i].CreatedAt+"Z"), apps[i].Labels))
	}

	fmt.Println(columnize.SimpleFormat(output))
}
Ejemplo n.º 5
0
func printDeploymentDetail(d deployments.Deployment) {
	var output []string
	fields := structs.New(d).Fields()

	fmt.Println("\nDeployment Details:\n")

	for _, f := range fields {
		if f.Name() == "Metadata" {
			mdata, _ := json.Marshal(d.Metadata)
			output = append(output, fmt.Sprintf("%s: |%s\n", f.Name(), mdata))
		} else if f.Name() == "CreatedAt" {
			output = append(output, fmt.Sprintf("%s: | %s\n", f.Name(), utils.FormatTime(d.CreatedAt+"Z")))
		} else {
			output = append(output, fmt.Sprintf("%s: |%v\n", f.Name(), f.Value()))
		}
	}

	fmt.Println(columnize.SimpleFormat(output))
}