func determineParams()

in custom-targets/vertex-ai-pipeline/pipeline-deployer/request.go [90:144]


func determineParams() (*params, error) {
	location, found := os.LookupEnv(locValsKey)
	if !found {
		return nil, fmt.Errorf("environment variable %s not found", locValsKey)
	}
	if location == "" {
		return nil, fmt.Errorf("environment variable %s contains empty string", locValsKey)
	}

	project, found := os.LookupEnv(projectValsKey)
	if !found {
		return nil, fmt.Errorf("required environment variable %s not found", projectValsKey)
	}
	if project == "" {
		return nil, fmt.Errorf("environment variable %s contains empty string", projectValsKey)
	}

	pipeline, found := os.LookupEnv(pipelineEnvKey)
	if !found {
		return nil, fmt.Errorf("required environment variable %s not found", pipelineEnvKey)
	}
	if pipeline == "" {
		return nil, fmt.Errorf("environment variable %s contains empty string", pipelineEnvKey)
	}

	paramString, found := os.LookupEnv(paramValsKey)
	if !found {
		return nil, fmt.Errorf("required environment variable %s not found", paramValsKey)
	}
	var pipelineParams map[string]string
	err := json.Unmarshal([]byte(paramString), &pipelineParams)
	if err != nil {
		return nil, fmt.Errorf("unable to unmarshal params json")
	}

	if len(pipelineParams) == 0 {
		return nil, fmt.Errorf("environment variable %s contains empty string", paramValsKey)
	}

	config, found := os.LookupEnv(configPathKey)
	if !found {
		return nil, fmt.Errorf("required environment variable %s not found", configPathKey)
	}
	if config == "" {
		return nil, fmt.Errorf("environment variable %s contains empty string", configPathKey)
	}

	return &params{
		project:        project,
		pipeline:       pipeline,
		configPath:     config,
		location:       location,
		pipelineParams: pipelineParams,
	}, nil
}