Restructure application sources to separate types (#799)

This commit is contained in:
Jesse Suen 2018-11-17 16:20:25 -08:00 committed by GitHub
parent b439424cef
commit 925f9486e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 1646 additions and 856 deletions

View file

@ -92,48 +92,13 @@ func NewApplicationCreateCommand(clientOpts *argocdclient.ClientOptions) *cobra.
}
appName = args[0]
}
if appOpts.repoURL == "" || appOpts.appPath == "" || appName == "" {
log.Fatal("name, repo, path are required")
}
app = argoappv1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: appName,
},
Spec: argoappv1.ApplicationSpec{
Project: appOpts.project,
Source: argoappv1.ApplicationSource{
RepoURL: appOpts.repoURL,
Path: appOpts.appPath,
Environment: appOpts.env,
TargetRevision: appOpts.revision,
},
},
}
}
if appOpts.destServer != "" {
app.Spec.Destination.Server = appOpts.destServer
}
if appOpts.destNamespace != "" {
app.Spec.Destination.Namespace = appOpts.destNamespace
}
if appOpts.namePrefix != "" {
app.Spec.Source.NamePrefix = appOpts.namePrefix
}
setParameterOverrides(&app, appOpts.parameters)
if len(appOpts.valuesFiles) > 0 {
app.Spec.Source.ValuesFiles = appOpts.valuesFiles
}
switch appOpts.syncPolicy {
case "automated":
app.Spec.SyncPolicy = &argoappv1.SyncPolicy{
Automated: &argoappv1.SyncPolicyAutomated{
Prune: appOpts.autoPrune,
},
}
case "none", "":
app.Spec.SyncPolicy = nil
default:
log.Fatalf("Invalid sync-policy: %s", appOpts.syncPolicy)
setAppOptions(c.Flags(), &app, &appOpts)
setParameterOverrides(&app, appOpts.parameters)
}
conn, appIf := argocdclient.NewClientOrDie(clientOpts).NewApplicationClientOrDie()
defer util.Close(conn)
@ -192,15 +157,7 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
fmt.Printf(printOpFmtStr, "Repo:", app.Spec.Source.RepoURL)
fmt.Printf(printOpFmtStr, "Target:", app.Spec.Source.TargetRevision)
fmt.Printf(printOpFmtStr, "Path:", app.Spec.Source.Path)
if app.Spec.Source.Environment != "" {
fmt.Printf(printOpFmtStr, "Environment:", app.Spec.Source.Environment)
}
if len(app.Spec.Source.ValuesFiles) > 0 {
fmt.Printf(printOpFmtStr, "Helm Values:", strings.Join(app.Spec.Source.ValuesFiles, ","))
}
if len(app.Spec.Source.NamePrefix) > 0 {
fmt.Printf(printOpFmtStr, "Name Prefix:", app.Spec.Source.NamePrefix)
}
printAppSourceDetails(&app.Spec.Source)
var syncPolicy string
if app.Spec.SyncPolicy != nil && app.Spec.SyncPolicy.Automated != nil {
syncPolicy = "Automated"
@ -244,6 +201,21 @@ func NewApplicationGetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
return command
}
func printAppSourceDetails(appSrc *argoappv1.ApplicationSource) {
if env := argoappv1.KsonnetEnv(appSrc); env != "" {
fmt.Printf(printOpFmtStr, "Environment:", env)
}
valueFiles := argoappv1.HelmValueFiles(appSrc)
if len(valueFiles) > 0 {
fmt.Printf(printOpFmtStr, "Helm Values:", strings.Join(valueFiles, ","))
}
if appSrc.Kustomize != nil {
if appSrc.Kustomize.NamePrefix != "" {
fmt.Printf(printOpFmtStr, "Name Prefix:", appSrc.Kustomize.NamePrefix)
}
}
}
func printAppConditions(w io.Writer, app *argoappv1.Application) {
fmt.Fprintf(w, "CONDITION\tMESSAGE\n")
for _, item := range app.Status.Conditions {
@ -287,8 +259,7 @@ func printParams(app *argoappv1.Application) {
}
fmt.Println()
w := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
isKsonnet := app.Spec.Source.Environment != ""
if isKsonnet {
if needsComponentColumn(&app.Spec.Source) {
fmt.Fprintf(w, "COMPONENT\tNAME\tVALUE\tOVERRIDE\n")
for _, p := range app.Status.Parameters {
overrideValue := overrides[fmt.Sprintf("%s/%s", p.Component, p.Name)]
@ -304,6 +275,16 @@ func printParams(app *argoappv1.Application) {
_ = w.Flush()
}
// needsComponentColumn returns true if the app source is such that it requires parameters in the
// COMPONENT=PARAM=NAME
func needsComponentColumn(source *argoappv1.ApplicationSource) bool {
ksEnv := argoappv1.KsonnetEnv(source)
if ksEnv != "" {
return true
}
return false
}
// NewApplicationSetCommand returns a new instance of an `argocd app set` command
func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Command {
var (
@ -322,41 +303,7 @@ func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
defer util.Close(conn)
app, err := appIf.Get(context.Background(), &application.ApplicationQuery{Name: &appName})
errors.CheckError(err)
visited := 0
c.Flags().Visit(func(f *pflag.Flag) {
visited++
switch f.Name {
case "repo":
app.Spec.Source.RepoURL = appOpts.repoURL
case "path":
app.Spec.Source.Path = appOpts.appPath
case "env":
app.Spec.Source.Environment = appOpts.env
case "revision":
app.Spec.Source.TargetRevision = appOpts.revision
case "values":
app.Spec.Source.ValuesFiles = appOpts.valuesFiles
case "dest-server":
app.Spec.Destination.Server = appOpts.destServer
case "dest-namespace":
app.Spec.Destination.Namespace = appOpts.destNamespace
case "project":
app.Spec.Project = appOpts.project
case "name-prefix":
app.Spec.Source.NamePrefix = appOpts.namePrefix
case "sync-policy":
switch appOpts.syncPolicy {
case "automated":
app.Spec.SyncPolicy = &argoappv1.SyncPolicy{
Automated: &argoappv1.SyncPolicyAutomated{},
}
case "none":
app.Spec.SyncPolicy = nil
default:
log.Fatalf("Invalid sync-policy: %s", appOpts.syncPolicy)
}
}
})
visited := setAppOptions(c.Flags(), app, &appOpts)
if visited == 0 {
log.Error("Please set at least one option to update")
c.HelpFunc()(c, args)
@ -368,7 +315,6 @@ func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
}
app.Spec.SyncPolicy.Automated.Prune = appOpts.autoPrune
}
setParameterOverrides(app, appOpts.parameters)
oldOverrides := app.Spec.Source.ComponentParameterOverrides
updatedSpec, err := appIf.UpdateSpec(context.Background(), &application.ApplicationUpdateSpecRequest{
@ -385,6 +331,77 @@ func NewApplicationSetCommand(clientOpts *argocdclient.ClientOptions) *cobra.Com
return command
}
func setAppOptions(flags *pflag.FlagSet, app *argoappv1.Application, appOpts *appOptions) int {
visited := 0
flags.Visit(func(f *pflag.Flag) {
visited++
switch f.Name {
case "repo":
app.Spec.Source.RepoURL = appOpts.repoURL
case "path":
app.Spec.Source.Path = appOpts.appPath
case "env":
setKsonnetOpt(&app.Spec.Source, &appOpts.env)
case "revision":
app.Spec.Source.TargetRevision = appOpts.revision
case "values":
setHelmOpt(&app.Spec.Source, appOpts.valuesFiles, nil)
case "release-name":
setHelmOpt(&app.Spec.Source, nil, &appOpts.releaseName)
case "dest-server":
app.Spec.Destination.Server = appOpts.destServer
case "dest-namespace":
app.Spec.Destination.Namespace = appOpts.destNamespace
case "project":
app.Spec.Project = appOpts.project
case "nameprefix":
setKustomizeOpt(&app.Spec.Source, &appOpts.namePrefix)
case "sync-policy":
switch appOpts.syncPolicy {
case "automated":
app.Spec.SyncPolicy = &argoappv1.SyncPolicy{
Automated: &argoappv1.SyncPolicyAutomated{},
}
case "none":
app.Spec.SyncPolicy = nil
default:
log.Fatalf("Invalid sync-policy: %s", appOpts.syncPolicy)
}
}
})
return visited
}
func setKsonnetOpt(src *argoappv1.ApplicationSource, env *string) {
if src.Ksonnet == nil {
src.Ksonnet = &argoappv1.ApplicationSourceKsonnet{}
}
if env != nil {
src.Ksonnet.Environment = *env
}
}
func setKustomizeOpt(src *argoappv1.ApplicationSource, namePrefix *string) {
if src.Kustomize == nil {
src.Kustomize = &argoappv1.ApplicationSourceKustomize{}
}
if namePrefix != nil {
src.Kustomize.NamePrefix = *namePrefix
}
}
func setHelmOpt(src *argoappv1.ApplicationSource, valueFiles []string, releaseName *string) {
if src.Helm == nil {
src.Helm = &argoappv1.ApplicationSourceHelm{}
}
if valueFiles != nil {
src.Helm.ValueFiles = valueFiles
}
if releaseName != nil {
src.Helm.ReleaseName = *releaseName
}
}
func checkDroppedParams(newOverrides []argoappv1.ComponentParameter, oldOverrides []argoappv1.ComponentParameter) {
newOverrideMap := argo.ParamToMap(newOverrides)
@ -406,6 +423,7 @@ type appOptions struct {
destNamespace string
parameters []string
valuesFiles []string
releaseName string
project string
syncPolicy string
autoPrune bool
@ -421,10 +439,11 @@ func addAppFlags(command *cobra.Command, opts *appOptions) {
command.Flags().StringVar(&opts.destNamespace, "dest-namespace", "", "K8s target namespace (overrides the namespace specified in the ksonnet app.yaml)")
command.Flags().StringArrayVarP(&opts.parameters, "parameter", "p", []string{}, "set a parameter override (e.g. -p guestbook=image=example/guestbook:latest)")
command.Flags().StringArrayVar(&opts.valuesFiles, "values", []string{}, "Helm values file(s) to use")
command.Flags().StringVar(&opts.releaseName, "release-name", "", "Helm release-name")
command.Flags().StringVar(&opts.project, "project", "", "Application project name")
command.Flags().StringVar(&opts.syncPolicy, "sync-policy", "", "Set the sync policy (one of: automated, none)")
command.Flags().BoolVar(&opts.autoPrune, "auto-prune", false, "Set automatic pruning when sync is automated")
command.Flags().StringVar(&opts.namePrefix, "name-prefix", "", "Set a prefix to add to resource names for kustomize and helm app")
command.Flags().StringVar(&opts.namePrefix, "nameprefix", "", "Kustomize nameprefix")
}
// NewApplicationUnsetCommand returns a new instance of an `argocd app unset` command
@ -432,13 +451,12 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
var (
parameters []string
valuesFiles []string
namePrefix bool
)
var command = &cobra.Command{
Use: "unset APPNAME -p COMPONENT=PARAM",
Short: "Unset application parameters",
Run: func(c *cobra.Command, args []string) {
if len(args) != 1 || (len(parameters) == 0 && len(valuesFiles) == 0 && !namePrefix) {
if len(args) != 1 || (len(parameters) == 0 && len(valuesFiles) == 0) {
c.HelpFunc()(c, args)
os.Exit(1)
}
@ -447,7 +465,7 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
defer util.Close(conn)
app, err := appIf.Get(context.Background(), &application.ApplicationQuery{Name: &appName})
errors.CheckError(err)
isKsonnetApp := app.Spec.Source.Environment != ""
isKsonnetApp := argoappv1.KsonnetEnv(&app.Spec.Source) != ""
updated := false
for _, paramStr := range parameters {
@ -475,23 +493,21 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
}
}
}
specValueFiles := argoappv1.HelmValueFiles(&app.Spec.Source)
for _, valuesFile := range valuesFiles {
for i, vf := range app.Spec.Source.ValuesFiles {
for i, vf := range specValueFiles {
if vf == valuesFile {
app.Spec.Source.ValuesFiles = append(app.Spec.Source.ValuesFiles[0:i], app.Spec.Source.ValuesFiles[i+1:]...)
specValueFiles = append(specValueFiles[0:i], specValueFiles[i+1:]...)
updated = true
break
}
}
}
if namePrefix {
app.Spec.Source.NamePrefix = ""
updated = true
}
setHelmOpt(&app.Spec.Source, specValueFiles, nil)
if !updated {
return
}
_, err = appIf.UpdateSpec(context.Background(), &application.ApplicationUpdateSpecRequest{
Name: &app.Name,
Spec: app.Spec,
@ -501,8 +517,6 @@ func NewApplicationUnsetCommand(clientOpts *argocdclient.ClientOptions) *cobra.C
}
command.Flags().StringArrayVarP(&parameters, "parameter", "p", []string{}, "unset a parameter override (e.g. -p guestbook=image)")
command.Flags().StringArrayVar(&valuesFiles, "values", []string{}, "unset one or more helm values files")
command.Flags().BoolVar(&namePrefix, "name-prefix", false, "Unset the name prefix")
return command
}
@ -670,8 +684,8 @@ func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
var fmtStr string
headers := []interface{}{"NAME", "CLUSTER", "NAMESPACE", "PROJECT", "STATUS", "HEALTH", "CONDITIONS"}
if output == "wide" {
fmtStr = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"
headers = append(headers, "ENV", "REPO", "PATH", "TARGET")
fmtStr = "%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n"
headers = append(headers, "REPO", "PATH", "TARGET")
} else {
fmtStr = "%s\t%s\t%s\t%s\t%s\t%s\t%s\n"
}
@ -687,7 +701,7 @@ func NewApplicationListCommand(clientOpts *argocdclient.ClientOptions) *cobra.Co
formatConditionsSummary(app),
}
if output == "wide" {
vals = append(vals, app.Spec.Source.Environment, app.Spec.Source.RepoURL, app.Spec.Source.Path, app.Spec.Source.TargetRevision)
vals = append(vals, app.Spec.Source.RepoURL, app.Spec.Source.Path, app.Spec.Source.TargetRevision)
}
fmt.Fprintf(w, fmtStr, vals...)
}
@ -1136,10 +1150,10 @@ func setParameterOverrides(app *argoappv1.Application, parameters []string) {
} else {
newParams = make([]argoappv1.ComponentParameter, 0)
}
isKsonnetApp := app.Spec.Source.Environment != ""
needsComponent := needsComponentColumn(&app.Spec.Source)
for _, paramStr := range parameters {
var newParam argoappv1.ComponentParameter
if isKsonnetApp {
if needsComponent {
parts := strings.SplitN(paramStr, "=", 3)
if len(parts) != 3 {
log.Fatalf("Expected ksonnet parameter of the form: component=param=value. Received: %s", paramStr)

View file

@ -40,7 +40,7 @@ func (m *ResourcesQuery) Reset() { *m = ResourcesQuery{} }
func (m *ResourcesQuery) String() string { return proto.CompactTextString(m) }
func (*ResourcesQuery) ProtoMessage() {}
func (*ResourcesQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_application_b7c966df2a6bd563, []int{0}
return fileDescriptor_application_ceea98df6b81388c, []int{0}
}
func (m *ResourcesQuery) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -108,7 +108,7 @@ func (m *ResourcesResponse) Reset() { *m = ResourcesResponse{} }
func (m *ResourcesResponse) String() string { return proto.CompactTextString(m) }
func (*ResourcesResponse) ProtoMessage() {}
func (*ResourcesResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_application_b7c966df2a6bd563, []int{1}
return fileDescriptor_application_ceea98df6b81388c, []int{1}
}
func (m *ResourcesResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -729,10 +729,10 @@ var (
)
func init() {
proto.RegisterFile("controller/services/application.proto", fileDescriptor_application_b7c966df2a6bd563)
proto.RegisterFile("controller/services/application.proto", fileDescriptor_application_ceea98df6b81388c)
}
var fileDescriptor_application_b7c966df2a6bd563 = []byte{
var fileDescriptor_application_ceea98df6b81388c = []byte{
// 328 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x52, 0xcb, 0x4a, 0x03, 0x31,
0x14, 0x35, 0x7d, 0x20, 0x8d, 0xa0, 0x18, 0x5c, 0x0c, 0x5d, 0x94, 0x52, 0x10, 0x66, 0x63, 0x42,

View file

@ -117,14 +117,11 @@ func (s *appStateManager) getTargetObjs(app *v1alpha1.Application, revision stri
manifestInfo, err := repoClient.GenerateManifest(context.Background(), &repository.ManifestRequest{
Repo: repo,
Environment: app.Spec.Source.Environment,
Path: app.Spec.Source.Path,
Revision: revision,
ComponentParameterOverrides: mfReqOverrides,
AppLabel: app.Name,
ValueFiles: app.Spec.Source.ValuesFiles,
Namespace: app.Spec.Destination.Namespace,
NamePrefix: app.Spec.Source.NamePrefix,
ApplicationSource: &app.Spec.Source,
})
if err != nil {
return nil, nil, err

File diff suppressed because it is too large Load diff

View file

@ -108,6 +108,7 @@ message ApplicationSource {
optional string path = 2;
// Environment is a ksonnet application environment name
// DEPRECATED: specify environment in ksonnet.environment instead
optional string environment = 3;
// TargetRevision defines the commit, tag, or branch in which to sync the application to.
@ -118,10 +119,38 @@ message ApplicationSource {
repeated ComponentParameter componentParameterOverrides = 5;
// ValuesFiles is a list of Helm values files to use when generating a template
// DEPRECATED: specify values in helm.valueFiles instead
repeated string valuesFiles = 6;
// NamePrefix is a prefix appended to resources for helm and kustomize apps
optional string namePrefix = 7;
// Helm holds helm specific options
optional ApplicationSourceHelm helm = 7;
// Kustomize holds kustomize specific options
optional ApplicationSourceKustomize kustomize = 8;
// Ksonnet holds ksonnet specific options
optional ApplicationSourceKsonnet ksonnet = 9;
}
// ApplicationSourceHelm holds helm specific options
message ApplicationSourceHelm {
// The Helm release name. If omitted will use the application name
optional string releaseName = 1;
// ValuesFiles is a list of Helm value files to use when generating a template
repeated string valueFiles = 2;
}
// ApplicationSourceKsonnet holds ksonnet specific options
message ApplicationSourceKsonnet {
// Environment is a ksonnet application environment name
optional string environment = 1;
}
// ApplicationSourceKustomize holds kustomize specific options
message ApplicationSourceKustomize {
// NamePrefix is a prefix appended to resources for kustomize apps
optional string namePrefix = 1;
}
// ApplicationSpec represents desired application state. Contains link to repository with application definition and additional parameters link definition revision.

View file

@ -18,6 +18,107 @@ import (
"github.com/argoproj/argo-cd/util/git"
)
// Application is a definition of Application resource.
// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type Application struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"`
Spec ApplicationSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
Status ApplicationStatus `json:"status" protobuf:"bytes,3,opt,name=status"`
Operation *Operation `json:"operation,omitempty" protobuf:"bytes,4,opt,name=operation"`
}
// ApplicationSpec represents desired application state. Contains link to repository with application definition and additional parameters link definition revision.
type ApplicationSpec struct {
// Source is a reference to the location ksonnet application definition
Source ApplicationSource `json:"source" protobuf:"bytes,1,opt,name=source"`
// Destination overrides the kubernetes server and namespace defined in the environment ksonnet app.yaml
Destination ApplicationDestination `json:"destination" protobuf:"bytes,2,name=destination"`
// Project is a application project name. Empty name means that application belongs to 'default' project.
Project string `json:"project" protobuf:"bytes,3,name=project"`
// SyncPolicy controls when a sync will be performed
SyncPolicy *SyncPolicy `json:"syncPolicy,omitempty" protobuf:"bytes,4,name=syncPolicy"`
}
// ApplicationSource contains information about github repository, path within repository and target application environment.
type ApplicationSource struct {
// RepoURL is the git repository URL of the application manifests
RepoURL string `json:"repoURL" protobuf:"bytes,1,opt,name=repoURL"`
// Path is a directory path within the repository containing a
Path string `json:"path" protobuf:"bytes,2,opt,name=path"`
// Environment is a ksonnet application environment name
// DEPRECATED: specify environment in ksonnet.environment instead
Environment string `json:"environment,omitempty" protobuf:"bytes,3,opt,name=environment"`
// TargetRevision defines the commit, tag, or branch in which to sync the application to.
// If omitted, will sync to HEAD
TargetRevision string `json:"targetRevision,omitempty" protobuf:"bytes,4,opt,name=targetRevision"`
// ComponentParameterOverrides are a list of parameter override values
ComponentParameterOverrides []ComponentParameter `json:"componentParameterOverrides,omitempty" protobuf:"bytes,5,opt,name=componentParameterOverrides"`
// ValuesFiles is a list of Helm values files to use when generating a template
// DEPRECATED: specify values in helm.valueFiles instead
ValuesFiles []string `json:"valuesFiles,omitempty" protobuf:"bytes,6,opt,name=valuesFiles"`
// Helm holds helm specific options
Helm *ApplicationSourceHelm `json:"helm,omitempty" protobuf:"bytes,7,opt,name=helm"`
// Kustomize holds kustomize specific options
Kustomize *ApplicationSourceKustomize `json:"kustomize,omitempty" protobuf:"bytes,8,opt,name=kustomize"`
// Ksonnet holds ksonnet specific options
Ksonnet *ApplicationSourceKsonnet `json:"ksonnet,omitempty" protobuf:"bytes,9,opt,name=ksonnet"`
}
type ApplicationSourceType string
const (
ApplicationSourceTypeHelm ApplicationSourceType = "Helm"
ApplicationSourceTypeKustomize ApplicationSourceType = "Kustomize"
ApplicationSourceTypeKsonnet ApplicationSourceType = "Ksonnet"
ApplicationSourceTypeDirectory ApplicationSourceType = "Directory"
)
// ApplicationSourceHelm holds helm specific options
type ApplicationSourceHelm struct {
// The Helm release name. If omitted will use the application name
ReleaseName string `json:"releaseName,omitempty" protobuf:"bytes,1,opt,name=releaseName"`
// ValuesFiles is a list of Helm value files to use when generating a template
ValueFiles []string `json:"valueFiles,omitempty" protobuf:"bytes,2,opt,name=valueFiles"`
}
// ApplicationSourceKustomize holds kustomize specific options
type ApplicationSourceKustomize struct {
// NamePrefix is a prefix appended to resources for kustomize apps
NamePrefix string `json:"namePrefix" protobuf:"bytes,1,opt,name=namePrefix"`
}
// ApplicationSourceKsonnet holds ksonnet specific options
type ApplicationSourceKsonnet struct {
// Environment is a ksonnet application environment name
Environment string `json:"environment,omitempty" protobuf:"bytes,1,opt,name=environment"`
}
// ApplicationDestination contains deployment destination information
type ApplicationDestination struct {
// Server overrides the environment server value in the ksonnet app.yaml
Server string `json:"server,omitempty" protobuf:"bytes,1,opt,name=server"`
// Namespace overrides the environment namespace value in the ksonnet app.yaml
Namespace string `json:"namespace,omitempty" protobuf:"bytes,2,opt,name=namespace"`
}
// ApplicationStatus contains information about application status in target environment.
type ApplicationStatus struct {
ComparisonResult ComparisonResult `json:"comparisonResult" protobuf:"bytes,1,opt,name=comparisonResult"`
History []DeploymentInfo `json:"history" protobuf:"bytes,2,opt,name=history"`
Parameters []ComponentParameter `json:"parameters,omitempty" protobuf:"bytes,3,opt,name=parameters"`
Health HealthStatus `json:"health,omitempty" protobuf:"bytes,4,opt,name=health"`
OperationState *OperationState `json:"operationState,omitempty" protobuf:"bytes,5,opt,name=operationState"`
Conditions []ApplicationCondition `json:"conditions,omitempty" protobuf:"bytes,6,opt,name=conditions"`
}
// Operation contains requested operation parameters.
type Operation struct {
Sync *SyncOperation `json:"sync,omitempty" protobuf:"bytes,1,opt,name=sync"`
}
// SyncOperationResource contains resources to sync.
type SyncOperationResource struct {
Group string `json:"group,omitempty" protobuf:"bytes,1,opt,name=group"`
@ -61,11 +162,6 @@ func (po ParameterOverrides) String() string {
return fmt.Sprintf("%v", []ComponentParameter(po))
}
// Operation contains requested operation parameters.
type Operation struct {
Sync *SyncOperation `json:"sync,omitempty" protobuf:"bytes,1,opt,name=sync"`
}
type OperationPhase string
const (
@ -215,18 +311,6 @@ type DeploymentInfo struct {
ID int64 `json:"id" protobuf:"bytes,5,opt,name=id"`
}
// Application is a definition of Application resource.
// +genclient
// +genclient:noStatus
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type Application struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"`
Spec ApplicationSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"`
Status ApplicationStatus `json:"status" protobuf:"bytes,3,opt,name=status"`
Operation *Operation `json:"operation,omitempty" protobuf:"bytes,4,opt,name=operation"`
}
// ApplicationWatchEvent contains information about application change.
type ApplicationWatchEvent struct {
Type watch.EventType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=k8s.io/apimachinery/pkg/watch.EventType"`
@ -247,18 +331,6 @@ type ApplicationList struct {
Items []Application `json:"items" protobuf:"bytes,2,rep,name=items"`
}
// ApplicationSpec represents desired application state. Contains link to repository with application definition and additional parameters link definition revision.
type ApplicationSpec struct {
// Source is a reference to the location ksonnet application definition
Source ApplicationSource `json:"source" protobuf:"bytes,1,opt,name=source"`
// Destination overrides the kubernetes server and namespace defined in the environment ksonnet app.yaml
Destination ApplicationDestination `json:"destination" protobuf:"bytes,2,name=destination"`
// Project is a application project name. Empty name means that application belongs to 'default' project.
Project string `json:"project" protobuf:"bytes,3,name=project"`
// SyncPolicy controls when a sync will be performed
SyncPolicy *SyncPolicy `json:"syncPolicy,omitempty" protobuf:"bytes,4,name=syncPolicy"`
}
// ComponentParameter contains information about component parameter value
type ComponentParameter struct {
Component string `json:"component,omitempty" protobuf:"bytes,1,opt,name=component"`
@ -266,33 +338,6 @@ type ComponentParameter struct {
Value string `json:"value" protobuf:"bytes,3,opt,name=value"`
}
// ApplicationSource contains information about github repository, path within repository and target application environment.
type ApplicationSource struct {
// RepoURL is the git repository URL of the application manifests
RepoURL string `json:"repoURL" protobuf:"bytes,1,opt,name=repoURL"`
// Path is a directory path within the repository containing a
Path string `json:"path" protobuf:"bytes,2,opt,name=path"`
// Environment is a ksonnet application environment name
Environment string `json:"environment,omitempty" protobuf:"bytes,3,opt,name=environment"`
// TargetRevision defines the commit, tag, or branch in which to sync the application to.
// If omitted, will sync to HEAD
TargetRevision string `json:"targetRevision,omitempty" protobuf:"bytes,4,opt,name=targetRevision"`
// ComponentParameterOverrides are a list of parameter override values
ComponentParameterOverrides []ComponentParameter `json:"componentParameterOverrides,omitempty" protobuf:"bytes,5,opt,name=componentParameterOverrides"`
// ValuesFiles is a list of Helm values files to use when generating a template
ValuesFiles []string `json:"valuesFiles,omitempty" protobuf:"bytes,6,opt,name=valuesFiles"`
// NamePrefix is a prefix appended to resources for helm and kustomize apps
NamePrefix string `json:"namePrefix" protobuf:"bytes,7,opt,name=namePrefix"`
}
// ApplicationDestination contains deployment destination information
type ApplicationDestination struct {
// Server overrides the environment server value in the ksonnet app.yaml
Server string `json:"server,omitempty" protobuf:"bytes,1,opt,name=server"`
// Namespace overrides the environment namespace value in the ksonnet app.yaml
Namespace string `json:"namespace,omitempty" protobuf:"bytes,2,opt,name=namespace"`
}
// ComparisonStatus is a type which represents possible comparison results
type ComparisonStatus string
@ -303,16 +348,6 @@ const (
ComparisonStatusOutOfSync ComparisonStatus = "OutOfSync"
)
// ApplicationStatus contains information about application status in target environment.
type ApplicationStatus struct {
ComparisonResult ComparisonResult `json:"comparisonResult" protobuf:"bytes,1,opt,name=comparisonResult"`
History []DeploymentInfo `json:"history" protobuf:"bytes,2,opt,name=history"`
Parameters []ComponentParameter `json:"parameters,omitempty" protobuf:"bytes,3,opt,name=parameters"`
Health HealthStatus `json:"health,omitempty" protobuf:"bytes,4,opt,name=health"`
OperationState *OperationState `json:"operationState,omitempty" protobuf:"bytes,5,opt,name=operationState"`
Conditions []ApplicationCondition `json:"conditions,omitempty" protobuf:"bytes,6,opt,name=conditions"`
}
// ApplicationConditionType represents type of application condition. Type name has following convention:
// prefix "Error" means error condition
// prefix "Warning" means warning condition
@ -726,3 +761,21 @@ func (r ResourceState) LiveObject() (*unstructured.Unstructured, error) {
func (r ResourceState) TargetObject() (*unstructured.Unstructured, error) {
return UnmarshalToUnstructured(r.TargetState)
}
// KsonnetEnv is helper to get the ksonnet environment from the legacy field or structured field
// TODO: delete this helper when we drop the top level Environment field
func KsonnetEnv(source *ApplicationSource) string {
if source.Ksonnet != nil && source.Ksonnet.Environment != "" {
return source.Ksonnet.Environment
}
return source.Environment
}
// HelmValueFiles is helper to get the helm value files from the legacy field or structured field
// TODO: delete this helper when we drop the top level ValuesFiles field
func HelmValueFiles(source *ApplicationSource) []string {
if source.Helm != nil && len(source.Helm.ValueFiles) > 0 {
return source.Helm.ValueFiles
}
return source.ValuesFiles
}

View file

@ -243,6 +243,33 @@ func (in *ApplicationSource) DeepCopyInto(out *ApplicationSource) {
*out = make([]string, len(*in))
copy(*out, *in)
}
if in.Helm != nil {
in, out := &in.Helm, &out.Helm
if *in == nil {
*out = nil
} else {
*out = new(ApplicationSourceHelm)
(*in).DeepCopyInto(*out)
}
}
if in.Kustomize != nil {
in, out := &in.Kustomize, &out.Kustomize
if *in == nil {
*out = nil
} else {
*out = new(ApplicationSourceKustomize)
**out = **in
}
}
if in.Ksonnet != nil {
in, out := &in.Ksonnet, &out.Ksonnet
if *in == nil {
*out = nil
} else {
*out = new(ApplicationSourceKsonnet)
**out = **in
}
}
return
}
@ -256,6 +283,59 @@ func (in *ApplicationSource) DeepCopy() *ApplicationSource {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ApplicationSourceHelm) DeepCopyInto(out *ApplicationSourceHelm) {
*out = *in
if in.ValueFiles != nil {
in, out := &in.ValueFiles, &out.ValueFiles
*out = make([]string, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSourceHelm.
func (in *ApplicationSourceHelm) DeepCopy() *ApplicationSourceHelm {
if in == nil {
return nil
}
out := new(ApplicationSourceHelm)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ApplicationSourceKsonnet) DeepCopyInto(out *ApplicationSourceKsonnet) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSourceKsonnet.
func (in *ApplicationSourceKsonnet) DeepCopy() *ApplicationSourceKsonnet {
if in == nil {
return nil
}
out := new(ApplicationSourceKsonnet)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ApplicationSourceKustomize) DeepCopyInto(out *ApplicationSourceKustomize) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ApplicationSourceKustomize.
func (in *ApplicationSourceKustomize) DeepCopy() *ApplicationSourceKustomize {
if in == nil {
return nil
}
out := new(ApplicationSourceKustomize)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ApplicationSpec) DeepCopyInto(out *ApplicationSpec) {
*out = *in

View file

@ -23,6 +23,7 @@ import (
"github.com/argoproj/argo-cd/util"
"github.com/argoproj/argo-cd/util/cache"
"github.com/argoproj/argo-cd/util/git"
"github.com/argoproj/argo-cd/util/hash"
"github.com/argoproj/argo-cd/util/helm"
"github.com/argoproj/argo-cd/util/ksonnet"
"github.com/argoproj/argo-cd/util/kube"
@ -34,15 +35,6 @@ const (
DefaultRepoCacheExpiration = 24 * time.Hour
)
type AppSourceType string
const (
AppSourceKsonnet AppSourceType = "ksonnet"
AppSourceHelm AppSourceType = "helm"
AppSourceKustomize AppSourceType = "kustomize"
AppSourceDirectory AppSourceType = "directory"
)
// Service implements ManifestService interface
type Service struct {
repoLock *util.KeyLock
@ -160,7 +152,7 @@ func (s *Service) GenerateManifest(c context.Context, q *ManifestRequest) (*Mani
if err != nil {
return nil, err
}
appPath := filepath.Join(gitClient.Root(), q.Path)
appPath := filepath.Join(gitClient.Root(), q.ApplicationSource.Path)
genRes, err := generateManifests(appPath, q)
if err != nil {
@ -179,6 +171,29 @@ func (s *Service) GenerateManifest(c context.Context, q *ManifestRequest) (*Mani
return &res, nil
}
// helper to formulate helm template options from a manifest request
func helmOpts(q *ManifestRequest) helm.HelmTemplateOpts {
opts := helm.HelmTemplateOpts{
Namespace: q.Namespace,
}
valueFiles := v1alpha1.HelmValueFiles(q.ApplicationSource)
if q.ApplicationSource.Helm != nil {
opts.ReleaseName = q.ApplicationSource.Helm.ReleaseName
opts.ValueFiles = valueFiles
}
return opts
}
func kustomizeOpts(q *ManifestRequest) kustomize.KustomizeBuildOpts {
opts := kustomize.KustomizeBuildOpts{
Namespace: q.Namespace,
}
if q.ApplicationSource.Kustomize != nil {
opts.NamePrefix = q.ApplicationSource.Kustomize.NamePrefix
}
return opts
}
// generateManifests generates manifests from a path
func generateManifests(appPath string, q *ManifestRequest) (*ManifestResponse, error) {
var targetObjs []*unstructured.Unstructured
@ -188,31 +203,29 @@ func generateManifests(appPath string, q *ManifestRequest) (*ManifestResponse, e
appSourceType := IdentifyAppSourceTypeByAppDir(appPath)
switch appSourceType {
case AppSourceKsonnet:
targetObjs, params, dest, err = ksShow(appPath, q.Environment, q.ComponentParameterOverrides)
case AppSourceHelm:
// TODO: Add prefix
case v1alpha1.ApplicationSourceTypeKsonnet:
env := v1alpha1.KsonnetEnv(q.ApplicationSource)
targetObjs, params, dest, err = ksShow(appPath, env, q.ComponentParameterOverrides)
case v1alpha1.ApplicationSourceTypeHelm:
h := helm.NewHelmApp(appPath)
err = h.DependencyBuild()
if err != nil {
return nil, err
}
appName := q.AppLabel
if q.NamePrefix != "" {
appName = q.NamePrefix + q.AppLabel
}
targetObjs, err = h.Template(appName, q.Namespace, q.ValueFiles, q.ComponentParameterOverrides)
opts := helmOpts(q)
targetObjs, err = h.Template(q.AppLabel, opts, q.ComponentParameterOverrides)
if err != nil {
return nil, err
}
params, err = h.GetParameters(q.ValueFiles)
params, err = h.GetParameters(opts.ValueFiles)
if err != nil {
return nil, err
}
case AppSourceKustomize:
case v1alpha1.ApplicationSourceTypeKustomize:
k := kustomize.NewKustomizeApp(appPath)
targetObjs, params, err = k.Build(q.Namespace, q.NamePrefix, q.ComponentParameterOverrides)
case AppSourceDirectory:
opts := kustomizeOpts(q)
targetObjs, params, err = k.Build(opts, q.ComponentParameterOverrides)
case v1alpha1.ApplicationSourceTypeDirectory:
targetObjs, err = findManifests(appPath)
}
if err != nil {
@ -271,31 +284,31 @@ func tempRepoPath(repo string) string {
}
// IdentifyAppSourceTypeByAppDir examines a directory and determines its application source type
func IdentifyAppSourceTypeByAppDir(appDirPath string) AppSourceType {
func IdentifyAppSourceTypeByAppDir(appDirPath string) v1alpha1.ApplicationSourceType {
if pathExists(appDirPath, "app.yaml") {
return AppSourceKsonnet
return v1alpha1.ApplicationSourceTypeKsonnet
}
if pathExists(appDirPath, "Chart.yaml") {
return AppSourceHelm
return v1alpha1.ApplicationSourceTypeHelm
}
if pathExists(appDirPath, "kustomization.yaml") {
return AppSourceKustomize
return v1alpha1.ApplicationSourceTypeKustomize
}
return AppSourceDirectory
return v1alpha1.ApplicationSourceTypeDirectory
}
// IdentifyAppSourceTypeByAppPath determines application source type by app file path
func IdentifyAppSourceTypeByAppPath(appFilePath string) AppSourceType {
func IdentifyAppSourceTypeByAppPath(appFilePath string) v1alpha1.ApplicationSourceType {
if strings.HasSuffix(appFilePath, "app.yaml") {
return AppSourceKsonnet
return v1alpha1.ApplicationSourceTypeKsonnet
}
if strings.HasSuffix(appFilePath, "Chart.yaml") {
return AppSourceHelm
return v1alpha1.ApplicationSourceTypeHelm
}
if strings.HasSuffix(appFilePath, "kustomization.yaml") {
return AppSourceKustomize
return v1alpha1.ApplicationSourceTypeKustomize
}
return AppSourceDirectory
return v1alpha1.ApplicationSourceTypeDirectory
}
// checkoutRevision is a convenience function to initialize a repo, fetch, and checkout a revision
@ -317,9 +330,13 @@ func checkoutRevision(gitClient git.Client, commitSHA string) (string, error) {
}
func manifestCacheKey(commitSHA string, q *ManifestRequest) string {
appSrc := q.ApplicationSource.DeepCopy()
appSrc.RepoURL = "" // superceded by commitSHA
appSrc.TargetRevision = "" // superceded by commitSHA
appSrcStr, _ := json.Marshal(appSrc)
pStr, _ := json.Marshal(q.ComponentParameterOverrides)
valuesFiles := strings.Join(q.ValueFiles, ",")
return fmt.Sprintf("mfst|%s|%s|%s|%s|%s|%s|%s|%s", q.AppLabel, q.Path, q.Environment, commitSHA, string(pStr), valuesFiles, q.Namespace, q.NamePrefix)
fnva := hash.FNVa(string(appSrcStr) + string(pStr))
return fmt.Sprintf("mfst|%s|%s|%s|%d", q.AppLabel, commitSHA, q.Namespace, fnva)
}
func listDirCacheKey(commitSHA string, q *ListDirRequest) string {
@ -350,7 +367,7 @@ func ksShow(appPath, envName string, overrides []*v1alpha1.ComponentParameter) (
}
dest, err := ksApp.Destination(envName)
if err != nil {
return nil, nil, nil, status.Errorf(codes.NotFound, "environment %q does not exist in ksonnet app", envName)
return nil, nil, nil, status.Errorf(codes.InvalidArgument, err.Error())
}
targetObjs, err := ksApp.Show(envName)
if err != nil {

View file

@ -31,13 +31,10 @@ const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package
type ManifestRequest struct {
Repo *v1alpha1.Repository `protobuf:"bytes,1,opt,name=repo" json:"repo,omitempty"`
Revision string `protobuf:"bytes,2,opt,name=revision,proto3" json:"revision,omitempty"`
Path string `protobuf:"bytes,3,opt,name=path,proto3" json:"path,omitempty"`
Environment string `protobuf:"bytes,4,opt,name=environment,proto3" json:"environment,omitempty"`
AppLabel string `protobuf:"bytes,5,opt,name=appLabel,proto3" json:"appLabel,omitempty"`
ComponentParameterOverrides []*v1alpha1.ComponentParameter `protobuf:"bytes,6,rep,name=componentParameterOverrides" json:"componentParameterOverrides,omitempty"`
ValueFiles []string `protobuf:"bytes,7,rep,name=valueFiles" json:"valueFiles,omitempty"`
Namespace string `protobuf:"bytes,8,opt,name=namespace,proto3" json:"namespace,omitempty"`
NamePrefix string `protobuf:"bytes,9,opt,name=namePrefix,proto3" json:"namePrefix,omitempty"`
ApplicationSource *v1alpha1.ApplicationSource `protobuf:"bytes,10,opt,name=applicationSource" json:"applicationSource,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
@ -47,7 +44,7 @@ func (m *ManifestRequest) Reset() { *m = ManifestRequest{} }
func (m *ManifestRequest) String() string { return proto.CompactTextString(m) }
func (*ManifestRequest) ProtoMessage() {}
func (*ManifestRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_bbb9ca7fa4202717, []int{0}
return fileDescriptor_repository_a8022d4991c5d6a5, []int{0}
}
func (m *ManifestRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -90,20 +87,6 @@ func (m *ManifestRequest) GetRevision() string {
return ""
}
func (m *ManifestRequest) GetPath() string {
if m != nil {
return m.Path
}
return ""
}
func (m *ManifestRequest) GetEnvironment() string {
if m != nil {
return m.Environment
}
return ""
}
func (m *ManifestRequest) GetAppLabel() string {
if m != nil {
return m.AppLabel
@ -118,13 +101,6 @@ func (m *ManifestRequest) GetComponentParameterOverrides() []*v1alpha1.Component
return nil
}
func (m *ManifestRequest) GetValueFiles() []string {
if m != nil {
return m.ValueFiles
}
return nil
}
func (m *ManifestRequest) GetNamespace() string {
if m != nil {
return m.Namespace
@ -132,11 +108,11 @@ func (m *ManifestRequest) GetNamespace() string {
return ""
}
func (m *ManifestRequest) GetNamePrefix() string {
func (m *ManifestRequest) GetApplicationSource() *v1alpha1.ApplicationSource {
if m != nil {
return m.NamePrefix
return m.ApplicationSource
}
return ""
return nil
}
type ManifestResponse struct {
@ -154,7 +130,7 @@ func (m *ManifestResponse) Reset() { *m = ManifestResponse{} }
func (m *ManifestResponse) String() string { return proto.CompactTextString(m) }
func (*ManifestResponse) ProtoMessage() {}
func (*ManifestResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_bbb9ca7fa4202717, []int{1}
return fileDescriptor_repository_a8022d4991c5d6a5, []int{1}
}
func (m *ManifestResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -232,7 +208,7 @@ func (m *ListDirRequest) Reset() { *m = ListDirRequest{} }
func (m *ListDirRequest) String() string { return proto.CompactTextString(m) }
func (*ListDirRequest) ProtoMessage() {}
func (*ListDirRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_bbb9ca7fa4202717, []int{2}
return fileDescriptor_repository_a8022d4991c5d6a5, []int{2}
}
func (m *ListDirRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -294,7 +270,7 @@ func (m *FileList) Reset() { *m = FileList{} }
func (m *FileList) String() string { return proto.CompactTextString(m) }
func (*FileList) ProtoMessage() {}
func (*FileList) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_bbb9ca7fa4202717, []int{3}
return fileDescriptor_repository_a8022d4991c5d6a5, []int{3}
}
func (m *FileList) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -344,7 +320,7 @@ func (m *GetFileRequest) Reset() { *m = GetFileRequest{} }
func (m *GetFileRequest) String() string { return proto.CompactTextString(m) }
func (*GetFileRequest) ProtoMessage() {}
func (*GetFileRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_bbb9ca7fa4202717, []int{4}
return fileDescriptor_repository_a8022d4991c5d6a5, []int{4}
}
func (m *GetFileRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -406,7 +382,7 @@ func (m *GetFileResponse) Reset() { *m = GetFileResponse{} }
func (m *GetFileResponse) String() string { return proto.CompactTextString(m) }
func (*GetFileResponse) ProtoMessage() {}
func (*GetFileResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_bbb9ca7fa4202717, []int{5}
return fileDescriptor_repository_a8022d4991c5d6a5, []int{5}
}
func (m *GetFileResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -626,18 +602,6 @@ func (m *ManifestRequest) MarshalTo(dAtA []byte) (int, error) {
i = encodeVarintRepository(dAtA, i, uint64(len(m.Revision)))
i += copy(dAtA[i:], m.Revision)
}
if len(m.Path) > 0 {
dAtA[i] = 0x1a
i++
i = encodeVarintRepository(dAtA, i, uint64(len(m.Path)))
i += copy(dAtA[i:], m.Path)
}
if len(m.Environment) > 0 {
dAtA[i] = 0x22
i++
i = encodeVarintRepository(dAtA, i, uint64(len(m.Environment)))
i += copy(dAtA[i:], m.Environment)
}
if len(m.AppLabel) > 0 {
dAtA[i] = 0x2a
i++
@ -656,32 +620,21 @@ func (m *ManifestRequest) MarshalTo(dAtA []byte) (int, error) {
i += n
}
}
if len(m.ValueFiles) > 0 {
for _, s := range m.ValueFiles {
dAtA[i] = 0x3a
i++
l = len(s)
for l >= 1<<7 {
dAtA[i] = uint8(uint64(l)&0x7f | 0x80)
l >>= 7
i++
}
dAtA[i] = uint8(l)
i++
i += copy(dAtA[i:], s)
}
}
if len(m.Namespace) > 0 {
dAtA[i] = 0x42
i++
i = encodeVarintRepository(dAtA, i, uint64(len(m.Namespace)))
i += copy(dAtA[i:], m.Namespace)
}
if len(m.NamePrefix) > 0 {
dAtA[i] = 0x4a
if m.ApplicationSource != nil {
dAtA[i] = 0x52
i++
i = encodeVarintRepository(dAtA, i, uint64(len(m.NamePrefix)))
i += copy(dAtA[i:], m.NamePrefix)
i = encodeVarintRepository(dAtA, i, uint64(m.ApplicationSource.Size()))
n2, err := m.ApplicationSource.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n2
}
if m.XXX_unrecognized != nil {
i += copy(dAtA[i:], m.XXX_unrecognized)
@ -774,11 +727,11 @@ func (m *ListDirRequest) MarshalTo(dAtA []byte) (int, error) {
dAtA[i] = 0xa
i++
i = encodeVarintRepository(dAtA, i, uint64(m.Repo.Size()))
n2, err := m.Repo.MarshalTo(dAtA[i:])
n3, err := m.Repo.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n2
i += n3
}
if len(m.Revision) > 0 {
dAtA[i] = 0x12
@ -853,11 +806,11 @@ func (m *GetFileRequest) MarshalTo(dAtA []byte) (int, error) {
dAtA[i] = 0xa
i++
i = encodeVarintRepository(dAtA, i, uint64(m.Repo.Size()))
n3, err := m.Repo.MarshalTo(dAtA[i:])
n4, err := m.Repo.MarshalTo(dAtA[i:])
if err != nil {
return 0, err
}
i += n3
i += n4
}
if len(m.Revision) > 0 {
dAtA[i] = 0x12
@ -924,14 +877,6 @@ func (m *ManifestRequest) Size() (n int) {
if l > 0 {
n += 1 + l + sovRepository(uint64(l))
}
l = len(m.Path)
if l > 0 {
n += 1 + l + sovRepository(uint64(l))
}
l = len(m.Environment)
if l > 0 {
n += 1 + l + sovRepository(uint64(l))
}
l = len(m.AppLabel)
if l > 0 {
n += 1 + l + sovRepository(uint64(l))
@ -942,18 +887,12 @@ func (m *ManifestRequest) Size() (n int) {
n += 1 + l + sovRepository(uint64(l))
}
}
if len(m.ValueFiles) > 0 {
for _, s := range m.ValueFiles {
l = len(s)
n += 1 + l + sovRepository(uint64(l))
}
}
l = len(m.Namespace)
if l > 0 {
n += 1 + l + sovRepository(uint64(l))
}
l = len(m.NamePrefix)
if l > 0 {
if m.ApplicationSource != nil {
l = m.ApplicationSource.Size()
n += 1 + l + sovRepository(uint64(l))
}
if m.XXX_unrecognized != nil {
@ -1169,64 +1108,6 @@ func (m *ManifestRequest) Unmarshal(dAtA []byte) error {
}
m.Revision = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Path", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRepository
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthRepository
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Path = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Environment", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRepository
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthRepository
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.Environment = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AppLabel", wireType)
@ -1287,35 +1168,6 @@ func (m *ManifestRequest) Unmarshal(dAtA []byte) error {
return err
}
iNdEx = postIndex
case 7:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field ValueFiles", wireType)
}
var stringLen uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRepository
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
return ErrInvalidLengthRepository
}
postIndex := iNdEx + intStringLen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.ValueFiles = append(m.ValueFiles, string(dAtA[iNdEx:postIndex]))
iNdEx = postIndex
case 8:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Namespace", wireType)
@ -1345,11 +1197,11 @@ func (m *ManifestRequest) Unmarshal(dAtA []byte) error {
}
m.Namespace = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 9:
case 10:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field NamePrefix", wireType)
return fmt.Errorf("proto: wrong wireType = %d for field ApplicationSource", wireType)
}
var stringLen uint64
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowRepository
@ -1359,20 +1211,24 @@ func (m *ManifestRequest) Unmarshal(dAtA []byte) error {
}
b := dAtA[iNdEx]
iNdEx++
stringLen |= (uint64(b) & 0x7F) << shift
msglen |= (int(b) & 0x7F) << shift
if b < 0x80 {
break
}
}
intStringLen := int(stringLen)
if intStringLen < 0 {
if msglen < 0 {
return ErrInvalidLengthRepository
}
postIndex := iNdEx + intStringLen
postIndex := iNdEx + msglen
if postIndex > l {
return io.ErrUnexpectedEOF
}
m.NamePrefix = string(dAtA[iNdEx:postIndex])
if m.ApplicationSource == nil {
m.ApplicationSource = &v1alpha1.ApplicationSource{}
}
if err := m.ApplicationSource.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
@ -2146,47 +2002,45 @@ var (
)
func init() {
proto.RegisterFile("reposerver/repository/repository.proto", fileDescriptor_repository_bbb9ca7fa4202717)
proto.RegisterFile("reposerver/repository/repository.proto", fileDescriptor_repository_a8022d4991c5d6a5)
}
var fileDescriptor_repository_bbb9ca7fa4202717 = []byte{
// 597 bytes of a gzipped FileDescriptorProto
var fileDescriptor_repository_a8022d4991c5d6a5 = []byte{
// 576 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcf, 0x6e, 0xd3, 0x4e,
0x10, 0xae, 0x9b, 0x34, 0x6d, 0xb6, 0x3f, 0xfd, 0x5a, 0x56, 0x15, 0xb2, 0xdc, 0x2a, 0xb2, 0x2c,
0x81, 0x72, 0xc1, 0x56, 0xc2, 0x85, 0x0b, 0x42, 0x82, 0x42, 0x85, 0xd4, 0xaa, 0x95, 0x39, 0xc1,
0x05, 0x6d, 0x9c, 0xa9, 0xb3, 0xc4, 0xde, 0x5d, 0x76, 0x37, 0x16, 0x3c, 0x05, 0x0f, 0xc0, 0x0b,
0x21, 0x4e, 0x3c, 0x02, 0xca, 0xad, 0x6f, 0x81, 0x76, 0x63, 0xc7, 0x4e, 0x1a, 0xf5, 0x82, 0x90,
0x7a, 0x9b, 0xf9, 0x66, 0xfd, 0x7d, 0xf3, 0x4f, 0x63, 0xf4, 0x58, 0x82, 0xe0, 0x0a, 0x64, 0x01,
0x32, 0xb2, 0x26, 0xd5, 0x5c, 0x7e, 0x6d, 0x98, 0xa1, 0x90, 0x5c, 0x73, 0x8c, 0x6a, 0xc4, 0x3b,
0x4a, 0x79, 0xca, 0x2d, 0x1c, 0x19, 0x6b, 0xf1, 0xc2, 0x3b, 0x49, 0x39, 0x4f, 0x33, 0x88, 0x88,
0xa0, 0x11, 0x61, 0x8c, 0x6b, 0xa2, 0x29, 0x67, 0xaa, 0x8c, 0x06, 0xd3, 0x67, 0x2a, 0xa4, 0xdc,
0x46, 0x13, 0x2e, 0x21, 0x2a, 0x06, 0x51, 0x0a, 0x0c, 0x24, 0xd1, 0x30, 0x2e, 0xdf, 0xbc, 0x4d,
0xa9, 0x9e, 0xcc, 0x46, 0x61, 0xc2, 0xf3, 0x88, 0x48, 0x2b, 0xf1, 0xc9, 0x1a, 0x4f, 0x92, 0x71,
0x24, 0xa6, 0xa9, 0xf9, 0x58, 0x45, 0x44, 0x88, 0x8c, 0x26, 0x96, 0x3c, 0x2a, 0x06, 0x24, 0x13,
0x13, 0x72, 0x8b, 0x2a, 0xf8, 0xd9, 0x42, 0x07, 0x17, 0x84, 0xd1, 0x6b, 0x50, 0x3a, 0x86, 0xcf,
0x33, 0x50, 0x1a, 0xbf, 0x47, 0x6d, 0x53, 0x84, 0xeb, 0xf8, 0x4e, 0x7f, 0x7f, 0xf8, 0x3a, 0xac,
0xd5, 0xc2, 0x4a, 0xcd, 0x1a, 0x1f, 0x93, 0x71, 0x28, 0xa6, 0x69, 0x68, 0xd4, 0xc2, 0x86, 0x5a,
0x58, 0xa9, 0x85, 0xf1, 0xb2, 0x17, 0xb1, 0xa5, 0xc4, 0x1e, 0xda, 0x93, 0x50, 0x50, 0x45, 0x39,
0x73, 0xb7, 0x7d, 0xa7, 0xdf, 0x8d, 0x97, 0x3e, 0xc6, 0xa8, 0x2d, 0x88, 0x9e, 0xb8, 0x2d, 0x8b,
0x5b, 0x1b, 0xfb, 0x68, 0x1f, 0x58, 0x41, 0x25, 0x67, 0x39, 0x30, 0xed, 0xb6, 0x6d, 0xa8, 0x09,
0x19, 0x46, 0x22, 0xc4, 0x39, 0x19, 0x41, 0xe6, 0xee, 0x2c, 0x18, 0x2b, 0x1f, 0x7f, 0x73, 0xd0,
0x71, 0xc2, 0x73, 0xc1, 0x19, 0x30, 0x7d, 0x45, 0x24, 0xc9, 0x41, 0x83, 0xbc, 0x2c, 0x40, 0x4a,
0x3a, 0x06, 0xe5, 0x76, 0xfc, 0x56, 0x7f, 0x7f, 0x78, 0xf1, 0x17, 0x05, 0xbe, 0xba, 0xc5, 0x1e,
0xdf, 0xa5, 0x88, 0x7b, 0x08, 0x15, 0x24, 0x9b, 0xc1, 0x1b, 0x9a, 0x81, 0x72, 0x77, 0xfd, 0x56,
0xbf, 0x1b, 0x37, 0x10, 0x7c, 0x82, 0xba, 0x8c, 0xe4, 0xa0, 0x04, 0x49, 0xc0, 0xdd, 0xb3, 0xe5,
0xd4, 0x80, 0xf9, 0xda, 0x38, 0x57, 0x12, 0xae, 0xe9, 0x17, 0xb7, 0x6b, 0xc3, 0x0d, 0x24, 0xb8,
0x71, 0xd0, 0x61, 0x3d, 0x4c, 0x25, 0x38, 0x53, 0x60, 0x28, 0xf3, 0x12, 0x53, 0xae, 0x63, 0x15,
0x6b, 0x60, 0x55, 0x70, 0x7b, 0x5d, 0xf0, 0x21, 0xea, 0x2c, 0x56, 0xbe, 0x1c, 0x4a, 0xe9, 0xad,
0x8c, 0xb1, 0xbd, 0x36, 0x46, 0x40, 0x1d, 0x61, 0x0a, 0x57, 0xee, 0xce, 0xbf, 0x68, 0x6f, 0x49,
0x1e, 0x7c, 0x77, 0xd0, 0xff, 0xe7, 0x54, 0xe9, 0x53, 0x2a, 0xef, 0xdf, 0xde, 0x06, 0x3e, 0xda,
0x33, 0x03, 0x35, 0x09, 0xe2, 0x23, 0xb4, 0x43, 0x35, 0xe4, 0x55, 0xf3, 0x17, 0x8e, 0xcd, 0xff,
0x0c, 0xb4, 0x79, 0x75, 0x0f, 0xf3, 0x7f, 0x84, 0x0e, 0x96, 0xc9, 0x95, 0x7b, 0x84, 0x51, 0x7b,
0x4c, 0x34, 0xb1, 0xd9, 0xfd, 0x17, 0x5b, 0x7b, 0x78, 0xe3, 0xa0, 0x07, 0xb5, 0xd6, 0x3b, 0x90,
0x05, 0x4d, 0x00, 0x5f, 0xa2, 0xc3, 0xb3, 0xf2, 0xcc, 0x54, 0xdb, 0x88, 0x8f, 0xc3, 0xc6, 0xa5,
0x5c, 0x3b, 0x38, 0xde, 0xc9, 0xe6, 0xe0, 0x42, 0x38, 0xd8, 0xc2, 0xcf, 0xd1, 0x6e, 0x39, 0x6a,
0xec, 0x35, 0x9f, 0xae, 0xce, 0xdf, 0x3b, 0x6a, 0xc6, 0xaa, 0xf6, 0x07, 0x5b, 0xf8, 0x14, 0xed,
0x96, 0xc5, 0xac, 0x7e, 0xbe, 0xda, 0x7e, 0xef, 0x78, 0x63, 0xac, 0x4a, 0xe2, 0xe5, 0x8b, 0x1f,
0xf3, 0x9e, 0xf3, 0x6b, 0xde, 0x73, 0x7e, 0xcf, 0x7b, 0xce, 0x87, 0xc1, 0x5d, 0x27, 0x78, 0xe3,
0xaf, 0x62, 0xd4, 0xb1, 0x17, 0xf7, 0xe9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbe, 0x03, 0x2d,
0xa5, 0x4a, 0x06, 0x00, 0x00,
0x10, 0xae, 0x9b, 0x34, 0x4d, 0xa7, 0x3f, 0xfd, 0xda, 0xae, 0x22, 0x64, 0x39, 0x51, 0x14, 0x59,
0x02, 0xe5, 0x82, 0xad, 0x84, 0x0b, 0x17, 0x84, 0x80, 0x42, 0x85, 0x94, 0xaa, 0xc8, 0x3d, 0xc1,
0x05, 0x6d, 0x9c, 0xc1, 0x59, 0x12, 0x7b, 0x97, 0xdd, 0x8d, 0x25, 0x78, 0x09, 0x1e, 0x80, 0x17,
0xe2, 0xd8, 0x47, 0x40, 0xb9, 0xf5, 0x2d, 0x90, 0x37, 0x76, 0xe2, 0xfc, 0x51, 0x2f, 0x15, 0x82,
0xdb, 0xec, 0x7c, 0xe3, 0xf9, 0xbe, 0xf9, 0xa3, 0x31, 0x3c, 0x92, 0x28, 0xb8, 0x42, 0x99, 0xa2,
0xf4, 0x8d, 0xc9, 0x34, 0x97, 0x5f, 0x4b, 0xa6, 0x27, 0x24, 0xd7, 0x9c, 0xc0, 0xca, 0xe3, 0x34,
0x22, 0x1e, 0x71, 0xe3, 0xf6, 0x33, 0x6b, 0x11, 0xe1, 0xb4, 0x22, 0xce, 0xa3, 0x29, 0xfa, 0x54,
0x30, 0x9f, 0x26, 0x09, 0xd7, 0x54, 0x33, 0x9e, 0xa8, 0x1c, 0x75, 0x27, 0x4f, 0x95, 0xc7, 0xb8,
0x41, 0x43, 0x2e, 0xd1, 0x4f, 0x7b, 0x7e, 0x84, 0x09, 0x4a, 0xaa, 0x71, 0x94, 0xc7, 0xbc, 0x8d,
0x98, 0x1e, 0xcf, 0x86, 0x5e, 0xc8, 0x63, 0x9f, 0x4a, 0x43, 0xf1, 0xd9, 0x18, 0x8f, 0xc3, 0x91,
0x2f, 0x26, 0x51, 0xf6, 0xb1, 0xf2, 0xa9, 0x10, 0x53, 0x16, 0x9a, 0xe4, 0x7e, 0xda, 0xa3, 0x53,
0x31, 0xa6, 0x5b, 0xa9, 0xdc, 0x9b, 0x0a, 0x9c, 0x5c, 0xd2, 0x84, 0x7d, 0x42, 0xa5, 0x03, 0xfc,
0x32, 0x43, 0xa5, 0xc9, 0x7b, 0xa8, 0x66, 0x45, 0xd8, 0x56, 0xc7, 0xea, 0x1e, 0xf7, 0x5f, 0x7b,
0x2b, 0x36, 0xaf, 0x60, 0x33, 0xc6, 0xc7, 0x70, 0xe4, 0x89, 0x49, 0xe4, 0x65, 0x6c, 0x5e, 0x89,
0xcd, 0x2b, 0xd8, 0xbc, 0x60, 0xd9, 0x8b, 0xc0, 0xa4, 0x24, 0x0e, 0xd4, 0x25, 0xa6, 0x4c, 0x31,
0x9e, 0xd8, 0xfb, 0x1d, 0xab, 0x7b, 0x14, 0x2c, 0xdf, 0x19, 0x46, 0x85, 0x18, 0xd0, 0x21, 0x4e,
0xed, 0x83, 0x05, 0x56, 0xbc, 0xc9, 0x77, 0x0b, 0x9a, 0x21, 0x8f, 0x05, 0x4f, 0x30, 0xd1, 0xef,
0xa8, 0xa4, 0x31, 0x6a, 0x94, 0x57, 0x29, 0x4a, 0xc9, 0x46, 0xa8, 0xec, 0x5a, 0xa7, 0xd2, 0x3d,
0xee, 0x5f, 0xde, 0x43, 0xea, 0xab, 0xad, 0xec, 0xc1, 0x5d, 0x8c, 0xa4, 0x05, 0x47, 0x09, 0x8d,
0x51, 0x09, 0x1a, 0xa2, 0x5d, 0x37, 0x72, 0x57, 0x0e, 0xf2, 0x0d, 0xce, 0x4a, 0x2c, 0xd7, 0x7c,
0x26, 0x43, 0xb4, 0xc1, 0xf4, 0x73, 0x70, 0x0f, 0x91, 0x2f, 0x36, 0x73, 0x06, 0xdb, 0x34, 0xee,
0xad, 0x05, 0xa7, 0xab, 0x91, 0x2a, 0xc1, 0x13, 0x85, 0x99, 0xdc, 0x38, 0xf7, 0x29, 0xdb, 0xea,
0x54, 0x32, 0xb9, 0x4b, 0xc7, 0x7a, 0x31, 0xfb, 0x9b, 0xc5, 0x3c, 0x80, 0xda, 0x62, 0xf1, 0xed,
0x8a, 0x81, 0xf2, 0xd7, 0xda, 0x30, 0xab, 0x1b, 0xc3, 0x44, 0xa8, 0x89, 0xac, 0x69, 0xca, 0x3e,
0xf8, 0x13, 0xa3, 0xc9, 0x93, 0xbb, 0x3f, 0x2c, 0xf8, 0x7f, 0xc0, 0x94, 0x3e, 0x67, 0xf2, 0x2f,
0x6f, 0x2f, 0x81, 0xaa, 0xa0, 0x7a, 0x9c, 0xb7, 0xc8, 0xd8, 0x6e, 0x07, 0xea, 0x6f, 0xd8, 0x14,
0x33, 0x81, 0xa4, 0x01, 0x07, 0x4c, 0x63, 0x5c, 0x34, 0x7f, 0xf1, 0x30, 0xfa, 0x2f, 0x50, 0x67,
0x51, 0xff, 0xa0, 0xfe, 0x87, 0x70, 0xb2, 0x14, 0x97, 0xef, 0x11, 0x81, 0xea, 0x88, 0x6a, 0x6a,
0xd4, 0xfd, 0x17, 0x18, 0xbb, 0x7f, 0x6b, 0xc1, 0xd9, 0x8a, 0xeb, 0x1a, 0x65, 0xca, 0x42, 0x24,
0x57, 0x70, 0x7a, 0x91, 0x1f, 0x9b, 0x62, 0x1b, 0x49, 0xd3, 0x2b, 0xdd, 0xcb, 0x8d, 0xb3, 0xe3,
0xb4, 0x76, 0x83, 0x0b, 0x62, 0x77, 0x8f, 0x3c, 0x83, 0xc3, 0x7c, 0xd4, 0xc4, 0x29, 0x87, 0xae,
0xcf, 0xdf, 0x69, 0x94, 0xb1, 0xa2, 0xfd, 0xee, 0x1e, 0x39, 0x87, 0xc3, 0xbc, 0x98, 0xf5, 0xcf,
0xd7, 0xdb, 0xef, 0x34, 0x77, 0x62, 0x85, 0x88, 0x97, 0xcf, 0x7f, 0xce, 0xdb, 0xd6, 0xcd, 0xbc,
0x6d, 0xfd, 0x9a, 0xb7, 0xad, 0x0f, 0xbd, 0xbb, 0x0e, 0xf1, 0xce, 0x1f, 0xc6, 0xb0, 0x66, 0xee,
0xee, 0x93, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xab, 0x6b, 0xe9, 0x55, 0x50, 0x06, 0x00, 0x00,
}

View file

@ -12,13 +12,10 @@ import "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1/generated.prot
message ManifestRequest {
github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.Repository repo = 1;
string revision = 2;
string path = 3;
string environment = 4;
string appLabel = 5;
repeated github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ComponentParameter componentParameterOverrides = 6;
repeated string valueFiles = 7;
string namespace = 8;
string namePrefix = 9;
github.com.argoproj.argo_cd.pkg.apis.application.v1alpha1.ApplicationSource applicationSource = 10;
}
message ManifestResponse {

View file

@ -4,13 +4,17 @@ import (
"testing"
"github.com/stretchr/testify/assert"
argoappv1 "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
)
func TestGenerateYamlManifestInDir(t *testing.T) {
// update this value if we add/remove manifests
const countOfManifests = 23
q := ManifestRequest{}
q := ManifestRequest{
ApplicationSource: &argoappv1.ApplicationSource{},
}
res1, err := generateManifests("../../manifests/base", &q)
assert.Nil(t, err)
assert.Equal(t, len(res1.Manifests), countOfManifests)
@ -22,7 +26,9 @@ func TestGenerateYamlManifestInDir(t *testing.T) {
}
func TestGenerateJsonnetManifestInDir(t *testing.T) {
q := ManifestRequest{}
q := ManifestRequest{
ApplicationSource: &argoappv1.ApplicationSource{},
}
res1, err := generateManifests("./testdata/jsonnet", &q)
assert.Nil(t, err)
assert.Equal(t, len(res1.Manifests), 2)

View file

@ -37,7 +37,7 @@ func (m *UpdatePasswordRequest) Reset() { *m = UpdatePasswordRequest{} }
func (m *UpdatePasswordRequest) String() string { return proto.CompactTextString(m) }
func (*UpdatePasswordRequest) ProtoMessage() {}
func (*UpdatePasswordRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_account_3e64cf795478a98b, []int{0}
return fileDescriptor_account_c12a236fbb4926f3, []int{0}
}
func (m *UpdatePasswordRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -90,7 +90,7 @@ func (m *UpdatePasswordResponse) Reset() { *m = UpdatePasswordResponse{}
func (m *UpdatePasswordResponse) String() string { return proto.CompactTextString(m) }
func (*UpdatePasswordResponse) ProtoMessage() {}
func (*UpdatePasswordResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_account_3e64cf795478a98b, []int{1}
return fileDescriptor_account_c12a236fbb4926f3, []int{1}
}
func (m *UpdatePasswordResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -566,10 +566,10 @@ var (
)
func init() {
proto.RegisterFile("server/account/account.proto", fileDescriptor_account_3e64cf795478a98b)
proto.RegisterFile("server/account/account.proto", fileDescriptor_account_c12a236fbb4926f3)
}
var fileDescriptor_account_3e64cf795478a98b = []byte{
var fileDescriptor_account_c12a236fbb4926f3 = []byte{
// 268 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x4e, 0x2d, 0x2a,
0x4b, 0x2d, 0xd2, 0x4f, 0x4c, 0x4e, 0xce, 0x2f, 0xcd, 0x2b, 0x81, 0xd1, 0x7a, 0x05, 0x45, 0xf9,

View file

@ -179,14 +179,11 @@ func (s *Server) GetManifests(ctx context.Context, q *ApplicationManifestQuery)
}
manifestInfo, err := repoClient.GenerateManifest(context.Background(), &repository.ManifestRequest{
Repo: repo,
Environment: a.Spec.Source.Environment,
Path: a.Spec.Source.Path,
Revision: revision,
ComponentParameterOverrides: overrides,
AppLabel: a.Name,
ValueFiles: a.Spec.Source.ValuesFiles,
Namespace: a.Spec.Destination.Namespace,
NamePrefix: a.Spec.Source.NamePrefix,
ApplicationSource: &a.Spec.Source,
})
if err != nil {
return nil, err
@ -291,7 +288,7 @@ func (s *Server) Update(ctx context.Context, q *ApplicationUpdateRequest) (*appv
// throws an error is passed override is invalid
// if passed override and old overrides are invalid, throws error, old overrides not dropped
func (s *Server) removeInvalidOverrides(a *appv1.Application, q *ApplicationUpdateSpecRequest) (*ApplicationUpdateSpecRequest, error) {
if a.Spec.Source.Environment == "" {
if appv1.KsonnetEnv(&a.Spec.Source) == "" {
// this method is only valid for ksonnet apps
return q, nil
}

View file

@ -52,7 +52,7 @@ func (m *ApplicationQuery) Reset() { *m = ApplicationQuery{} }
func (m *ApplicationQuery) String() string { return proto.CompactTextString(m) }
func (*ApplicationQuery) ProtoMessage() {}
func (*ApplicationQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{0}
return fileDescriptor_application_dd8073928224ef68, []int{0}
}
func (m *ApplicationQuery) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -116,7 +116,7 @@ func (m *ApplicationResourceEventsQuery) Reset() { *m = ApplicationResou
func (m *ApplicationResourceEventsQuery) String() string { return proto.CompactTextString(m) }
func (*ApplicationResourceEventsQuery) ProtoMessage() {}
func (*ApplicationResourceEventsQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{1}
return fileDescriptor_application_dd8073928224ef68, []int{1}
}
func (m *ApplicationResourceEventsQuery) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -179,7 +179,7 @@ func (m *ApplicationManifestQuery) Reset() { *m = ApplicationManifestQue
func (m *ApplicationManifestQuery) String() string { return proto.CompactTextString(m) }
func (*ApplicationManifestQuery) ProtoMessage() {}
func (*ApplicationManifestQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{2}
return fileDescriptor_application_dd8073928224ef68, []int{2}
}
func (m *ApplicationManifestQuery) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -232,7 +232,7 @@ func (m *ApplicationResponse) Reset() { *m = ApplicationResponse{} }
func (m *ApplicationResponse) String() string { return proto.CompactTextString(m) }
func (*ApplicationResponse) ProtoMessage() {}
func (*ApplicationResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{3}
return fileDescriptor_application_dd8073928224ef68, []int{3}
}
func (m *ApplicationResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -273,7 +273,7 @@ func (m *ApplicationCreateRequest) Reset() { *m = ApplicationCreateReque
func (m *ApplicationCreateRequest) String() string { return proto.CompactTextString(m) }
func (*ApplicationCreateRequest) ProtoMessage() {}
func (*ApplicationCreateRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{4}
return fileDescriptor_application_dd8073928224ef68, []int{4}
}
func (m *ApplicationCreateRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -327,7 +327,7 @@ func (m *ApplicationUpdateRequest) Reset() { *m = ApplicationUpdateReque
func (m *ApplicationUpdateRequest) String() string { return proto.CompactTextString(m) }
func (*ApplicationUpdateRequest) ProtoMessage() {}
func (*ApplicationUpdateRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{5}
return fileDescriptor_application_dd8073928224ef68, []int{5}
}
func (m *ApplicationUpdateRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -375,7 +375,7 @@ func (m *ApplicationDeleteRequest) Reset() { *m = ApplicationDeleteReque
func (m *ApplicationDeleteRequest) String() string { return proto.CompactTextString(m) }
func (*ApplicationDeleteRequest) ProtoMessage() {}
func (*ApplicationDeleteRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{6}
return fileDescriptor_application_dd8073928224ef68, []int{6}
}
func (m *ApplicationDeleteRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -436,7 +436,7 @@ func (m *ApplicationSyncRequest) Reset() { *m = ApplicationSyncRequest{}
func (m *ApplicationSyncRequest) String() string { return proto.CompactTextString(m) }
func (*ApplicationSyncRequest) ProtoMessage() {}
func (*ApplicationSyncRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{7}
return fileDescriptor_application_dd8073928224ef68, []int{7}
}
func (m *ApplicationSyncRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -527,7 +527,7 @@ func (m *ParameterOverrides) Reset() { *m = ParameterOverrides{} }
func (m *ParameterOverrides) String() string { return proto.CompactTextString(m) }
func (*ParameterOverrides) ProtoMessage() {}
func (*ParameterOverrides) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{8}
return fileDescriptor_application_dd8073928224ef68, []int{8}
}
func (m *ParameterOverrides) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -576,7 +576,7 @@ func (m *Parameter) Reset() { *m = Parameter{} }
func (m *Parameter) String() string { return proto.CompactTextString(m) }
func (*Parameter) ProtoMessage() {}
func (*Parameter) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{9}
return fileDescriptor_application_dd8073928224ef68, []int{9}
}
func (m *Parameter) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -639,7 +639,7 @@ func (m *ApplicationUpdateSpecRequest) Reset() { *m = ApplicationUpdateS
func (m *ApplicationUpdateSpecRequest) String() string { return proto.CompactTextString(m) }
func (*ApplicationUpdateSpecRequest) ProtoMessage() {}
func (*ApplicationUpdateSpecRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{10}
return fileDescriptor_application_dd8073928224ef68, []int{10}
}
func (m *ApplicationUpdateSpecRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -696,7 +696,7 @@ func (m *ApplicationRollbackRequest) Reset() { *m = ApplicationRollbackR
func (m *ApplicationRollbackRequest) String() string { return proto.CompactTextString(m) }
func (*ApplicationRollbackRequest) ProtoMessage() {}
func (*ApplicationRollbackRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{11}
return fileDescriptor_application_dd8073928224ef68, []int{11}
}
func (m *ApplicationRollbackRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -767,7 +767,7 @@ func (m *ApplicationDeleteResourceRequest) Reset() { *m = ApplicationDel
func (m *ApplicationDeleteResourceRequest) String() string { return proto.CompactTextString(m) }
func (*ApplicationDeleteResourceRequest) ProtoMessage() {}
func (*ApplicationDeleteResourceRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{12}
return fileDescriptor_application_dd8073928224ef68, []int{12}
}
func (m *ApplicationDeleteResourceRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -841,7 +841,7 @@ func (m *ApplicationPodLogsQuery) Reset() { *m = ApplicationPodLogsQuery
func (m *ApplicationPodLogsQuery) String() string { return proto.CompactTextString(m) }
func (*ApplicationPodLogsQuery) ProtoMessage() {}
func (*ApplicationPodLogsQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{13}
return fileDescriptor_application_dd8073928224ef68, []int{13}
}
func (m *ApplicationPodLogsQuery) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -931,7 +931,7 @@ func (m *LogEntry) Reset() { *m = LogEntry{} }
func (m *LogEntry) String() string { return proto.CompactTextString(m) }
func (*LogEntry) ProtoMessage() {}
func (*LogEntry) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{14}
return fileDescriptor_application_dd8073928224ef68, []int{14}
}
func (m *LogEntry) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -985,7 +985,7 @@ func (m *OperationTerminateRequest) Reset() { *m = OperationTerminateReq
func (m *OperationTerminateRequest) String() string { return proto.CompactTextString(m) }
func (*OperationTerminateRequest) ProtoMessage() {}
func (*OperationTerminateRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{15}
return fileDescriptor_application_dd8073928224ef68, []int{15}
}
func (m *OperationTerminateRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1031,7 +1031,7 @@ func (m *OperationTerminateResponse) Reset() { *m = OperationTerminateRe
func (m *OperationTerminateResponse) String() string { return proto.CompactTextString(m) }
func (*OperationTerminateResponse) ProtoMessage() {}
func (*OperationTerminateResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_application_bd7d6e09af32e4fb, []int{16}
return fileDescriptor_application_dd8073928224ef68, []int{16}
}
func (m *OperationTerminateResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -4968,10 +4968,10 @@ var (
)
func init() {
proto.RegisterFile("server/application/application.proto", fileDescriptor_application_bd7d6e09af32e4fb)
proto.RegisterFile("server/application/application.proto", fileDescriptor_application_dd8073928224ef68)
}
var fileDescriptor_application_bd7d6e09af32e4fb = []byte{
var fileDescriptor_application_dd8073928224ef68 = []byte{
// 1488 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcd, 0x6f, 0x1c, 0x45,
0x16, 0xdf, 0x9a, 0xf1, 0xd7, 0x3c, 0x47, 0xab, 0x55, 0x6d, 0xe2, 0xed, 0x6d, 0x1c, 0x7b, 0xd4,

View file

@ -45,7 +45,7 @@ func (m *ClusterQuery) Reset() { *m = ClusterQuery{} }
func (m *ClusterQuery) String() string { return proto.CompactTextString(m) }
func (*ClusterQuery) ProtoMessage() {}
func (*ClusterQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_cluster_bf8d7367dfc95a3e, []int{0}
return fileDescriptor_cluster_0875510a34378ea0, []int{0}
}
func (m *ClusterQuery) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -91,7 +91,7 @@ func (m *ClusterResponse) Reset() { *m = ClusterResponse{} }
func (m *ClusterResponse) String() string { return proto.CompactTextString(m) }
func (*ClusterResponse) ProtoMessage() {}
func (*ClusterResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_cluster_bf8d7367dfc95a3e, []int{1}
return fileDescriptor_cluster_0875510a34378ea0, []int{1}
}
func (m *ClusterResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -132,7 +132,7 @@ func (m *ClusterCreateRequest) Reset() { *m = ClusterCreateRequest{} }
func (m *ClusterCreateRequest) String() string { return proto.CompactTextString(m) }
func (*ClusterCreateRequest) ProtoMessage() {}
func (*ClusterCreateRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_cluster_bf8d7367dfc95a3e, []int{2}
return fileDescriptor_cluster_0875510a34378ea0, []int{2}
}
func (m *ClusterCreateRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -189,7 +189,7 @@ func (m *ClusterCreateFromKubeConfigRequest) Reset() { *m = ClusterCreat
func (m *ClusterCreateFromKubeConfigRequest) String() string { return proto.CompactTextString(m) }
func (*ClusterCreateFromKubeConfigRequest) ProtoMessage() {}
func (*ClusterCreateFromKubeConfigRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_cluster_bf8d7367dfc95a3e, []int{3}
return fileDescriptor_cluster_0875510a34378ea0, []int{3}
}
func (m *ClusterCreateFromKubeConfigRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -257,7 +257,7 @@ func (m *ClusterUpdateRequest) Reset() { *m = ClusterUpdateRequest{} }
func (m *ClusterUpdateRequest) String() string { return proto.CompactTextString(m) }
func (*ClusterUpdateRequest) ProtoMessage() {}
func (*ClusterUpdateRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_cluster_bf8d7367dfc95a3e, []int{4}
return fileDescriptor_cluster_0875510a34378ea0, []int{4}
}
func (m *ClusterUpdateRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1393,10 +1393,10 @@ var (
)
func init() {
proto.RegisterFile("server/cluster/cluster.proto", fileDescriptor_cluster_bf8d7367dfc95a3e)
proto.RegisterFile("server/cluster/cluster.proto", fileDescriptor_cluster_0875510a34378ea0)
}
var fileDescriptor_cluster_bf8d7367dfc95a3e = []byte{
var fileDescriptor_cluster_0875510a34378ea0 = []byte{
// 564 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x95, 0xcd, 0x6e, 0x13, 0x31,
0x10, 0xc7, 0xe5, 0xb6, 0xda, 0x12, 0x83, 0xf8, 0xb0, 0x0a, 0x5a, 0xd2, 0x10, 0xa5, 0x3e, 0x54,

View file

@ -46,7 +46,7 @@ func (m *ProjectCreateRequest) Reset() { *m = ProjectCreateRequest{} }
func (m *ProjectCreateRequest) String() string { return proto.CompactTextString(m) }
func (*ProjectCreateRequest) ProtoMessage() {}
func (*ProjectCreateRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_project_8d94583ca767d5b3, []int{0}
return fileDescriptor_project_082822b5d17b8c4e, []int{0}
}
func (m *ProjectCreateRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -96,7 +96,7 @@ func (m *ProjectTokenDeleteRequest) Reset() { *m = ProjectTokenDeleteReq
func (m *ProjectTokenDeleteRequest) String() string { return proto.CompactTextString(m) }
func (*ProjectTokenDeleteRequest) ProtoMessage() {}
func (*ProjectTokenDeleteRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_project_8d94583ca767d5b3, []int{1}
return fileDescriptor_project_082822b5d17b8c4e, []int{1}
}
func (m *ProjectTokenDeleteRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -162,7 +162,7 @@ func (m *ProjectTokenCreateRequest) Reset() { *m = ProjectTokenCreateReq
func (m *ProjectTokenCreateRequest) String() string { return proto.CompactTextString(m) }
func (*ProjectTokenCreateRequest) ProtoMessage() {}
func (*ProjectTokenCreateRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_project_8d94583ca767d5b3, []int{2}
return fileDescriptor_project_082822b5d17b8c4e, []int{2}
}
func (m *ProjectTokenCreateRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -231,7 +231,7 @@ func (m *ProjectTokenResponse) Reset() { *m = ProjectTokenResponse{} }
func (m *ProjectTokenResponse) String() string { return proto.CompactTextString(m) }
func (*ProjectTokenResponse) ProtoMessage() {}
func (*ProjectTokenResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_project_8d94583ca767d5b3, []int{3}
return fileDescriptor_project_082822b5d17b8c4e, []int{3}
}
func (m *ProjectTokenResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -279,7 +279,7 @@ func (m *ProjectQuery) Reset() { *m = ProjectQuery{} }
func (m *ProjectQuery) String() string { return proto.CompactTextString(m) }
func (*ProjectQuery) ProtoMessage() {}
func (*ProjectQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_project_8d94583ca767d5b3, []int{4}
return fileDescriptor_project_082822b5d17b8c4e, []int{4}
}
func (m *ProjectQuery) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -326,7 +326,7 @@ func (m *ProjectUpdateRequest) Reset() { *m = ProjectUpdateRequest{} }
func (m *ProjectUpdateRequest) String() string { return proto.CompactTextString(m) }
func (*ProjectUpdateRequest) ProtoMessage() {}
func (*ProjectUpdateRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_project_8d94583ca767d5b3, []int{5}
return fileDescriptor_project_082822b5d17b8c4e, []int{5}
}
func (m *ProjectUpdateRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -372,7 +372,7 @@ func (m *EmptyResponse) Reset() { *m = EmptyResponse{} }
func (m *EmptyResponse) String() string { return proto.CompactTextString(m) }
func (*EmptyResponse) ProtoMessage() {}
func (*EmptyResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_project_8d94583ca767d5b3, []int{6}
return fileDescriptor_project_082822b5d17b8c4e, []int{6}
}
func (m *EmptyResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1846,10 +1846,10 @@ var (
)
func init() {
proto.RegisterFile("server/project/project.proto", fileDescriptor_project_8d94583ca767d5b3)
proto.RegisterFile("server/project/project.proto", fileDescriptor_project_082822b5d17b8c4e)
}
var fileDescriptor_project_8d94583ca767d5b3 = []byte{
var fileDescriptor_project_082822b5d17b8c4e = []byte{
// 697 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x5d, 0x6b, 0x13, 0x4d,
0x14, 0x66, 0x9a, 0xbe, 0x79, 0xdf, 0x4e, 0x5e, 0xb5, 0x0c, 0xad, 0xa6, 0xb1, 0x8d, 0x61, 0x2e,

View file

@ -157,16 +157,16 @@ func (s *Server) ListApps(ctx context.Context, q *RepoAppsQuery) (*RepoAppsRespo
for _, i := range ksonnetRes.Items {
d := filepath.Dir(i)
if _, ok := componentDirs[d]; ok {
items = append(items, &AppInfo{Type: string(repository.AppSourceKsonnet), Path: i})
items = append(items, &AppInfo{Type: string(appsv1.ApplicationSourceTypeKsonnet), Path: i})
}
}
for i := range helmRes.Items {
items = append(items, &AppInfo{Type: string(repository.AppSourceHelm), Path: helmRes.Items[i]})
items = append(items, &AppInfo{Type: string(appsv1.ApplicationSourceTypeHelm), Path: helmRes.Items[i]})
}
for i := range kustomizationRes.Items {
items = append(items, &AppInfo{Type: string(repository.AppSourceKustomize), Path: kustomizationRes.Items[i]})
items = append(items, &AppInfo{Type: string(appsv1.ApplicationSourceTypeKustomize), Path: kustomizationRes.Items[i]})
}
return &RepoAppsResponse{Items: items}, nil
@ -210,7 +210,7 @@ func (s *Server) GetAppDetails(ctx context.Context, q *RepoAppDetailsQuery) (*Re
appSourceType := repository.IdentifyAppSourceTypeByAppPath(q.Path)
switch appSourceType {
case repository.AppSourceKsonnet:
case appsv1.ApplicationSourceTypeKsonnet:
var appSpec KsonnetAppSpec
appSpec.Path = q.Path
err = yaml.Unmarshal(appSpecRes.Data, &appSpec)
@ -221,7 +221,7 @@ func (s *Server) GetAppDetails(ctx context.Context, q *RepoAppDetailsQuery) (*Re
Type: string(appSourceType),
Ksonnet: &appSpec,
}, nil
case repository.AppSourceHelm:
case appsv1.ApplicationSourceTypeHelm:
var appSpec HelmAppSpec
appSpec.Path = q.Path
err = yaml.Unmarshal(appSpecRes.Data, &appSpec)
@ -249,7 +249,7 @@ func (s *Server) GetAppDetails(ctx context.Context, q *RepoAppDetailsQuery) (*Re
Type: string(appSourceType),
Helm: &appSpec,
}, nil
case repository.AppSourceKustomize:
case appsv1.ApplicationSourceTypeKustomize:
appSpec := KustomizeAppSpec{
Path: q.Path,
}

View file

@ -46,7 +46,7 @@ func (m *RepoAppsQuery) Reset() { *m = RepoAppsQuery{} }
func (m *RepoAppsQuery) String() string { return proto.CompactTextString(m) }
func (*RepoAppsQuery) ProtoMessage() {}
func (*RepoAppsQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{0}
return fileDescriptor_repository_324bad698d34f88e, []int{0}
}
func (m *RepoAppsQuery) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -102,7 +102,7 @@ func (m *AppInfo) Reset() { *m = AppInfo{} }
func (m *AppInfo) String() string { return proto.CompactTextString(m) }
func (*AppInfo) ProtoMessage() {}
func (*AppInfo) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{1}
return fileDescriptor_repository_324bad698d34f88e, []int{1}
}
func (m *AppInfo) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -159,7 +159,7 @@ func (m *RepoAppDetailsQuery) Reset() { *m = RepoAppDetailsQuery{} }
func (m *RepoAppDetailsQuery) String() string { return proto.CompactTextString(m) }
func (*RepoAppDetailsQuery) ProtoMessage() {}
func (*RepoAppDetailsQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{2}
return fileDescriptor_repository_324bad698d34f88e, []int{2}
}
func (m *RepoAppDetailsQuery) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -224,7 +224,7 @@ func (m *RepoAppDetailsResponse) Reset() { *m = RepoAppDetailsResponse{}
func (m *RepoAppDetailsResponse) String() string { return proto.CompactTextString(m) }
func (*RepoAppDetailsResponse) ProtoMessage() {}
func (*RepoAppDetailsResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{3}
return fileDescriptor_repository_324bad698d34f88e, []int{3}
}
func (m *RepoAppDetailsResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -293,7 +293,7 @@ func (m *RepoAppsResponse) Reset() { *m = RepoAppsResponse{} }
func (m *RepoAppsResponse) String() string { return proto.CompactTextString(m) }
func (*RepoAppsResponse) ProtoMessage() {}
func (*RepoAppsResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{4}
return fileDescriptor_repository_324bad698d34f88e, []int{4}
}
func (m *RepoAppsResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -344,7 +344,7 @@ func (m *KsonnetAppSpec) Reset() { *m = KsonnetAppSpec{} }
func (m *KsonnetAppSpec) String() string { return proto.CompactTextString(m) }
func (*KsonnetAppSpec) ProtoMessage() {}
func (*KsonnetAppSpec) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{5}
return fileDescriptor_repository_324bad698d34f88e, []int{5}
}
func (m *KsonnetAppSpec) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -408,7 +408,7 @@ func (m *HelmAppSpec) Reset() { *m = HelmAppSpec{} }
func (m *HelmAppSpec) String() string { return proto.CompactTextString(m) }
func (*HelmAppSpec) ProtoMessage() {}
func (*HelmAppSpec) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{6}
return fileDescriptor_repository_324bad698d34f88e, []int{6}
}
func (m *HelmAppSpec) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -470,7 +470,7 @@ func (m *KustomizeAppSpec) Reset() { *m = KustomizeAppSpec{} }
func (m *KustomizeAppSpec) String() string { return proto.CompactTextString(m) }
func (*KustomizeAppSpec) ProtoMessage() {}
func (*KustomizeAppSpec) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{7}
return fileDescriptor_repository_324bad698d34f88e, []int{7}
}
func (m *KustomizeAppSpec) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -524,7 +524,7 @@ func (m *KsonnetEnvironment) Reset() { *m = KsonnetEnvironment{} }
func (m *KsonnetEnvironment) String() string { return proto.CompactTextString(m) }
func (*KsonnetEnvironment) ProtoMessage() {}
func (*KsonnetEnvironment) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{8}
return fileDescriptor_repository_324bad698d34f88e, []int{8}
}
func (m *KsonnetEnvironment) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -595,7 +595,7 @@ func (m *KsonnetEnvironmentDestination) Reset() { *m = KsonnetEnvironmen
func (m *KsonnetEnvironmentDestination) String() string { return proto.CompactTextString(m) }
func (*KsonnetEnvironmentDestination) ProtoMessage() {}
func (*KsonnetEnvironmentDestination) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{9}
return fileDescriptor_repository_324bad698d34f88e, []int{9}
}
func (m *KsonnetEnvironmentDestination) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -650,7 +650,7 @@ func (m *RepoQuery) Reset() { *m = RepoQuery{} }
func (m *RepoQuery) String() string { return proto.CompactTextString(m) }
func (*RepoQuery) ProtoMessage() {}
func (*RepoQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{10}
return fileDescriptor_repository_324bad698d34f88e, []int{10}
}
func (m *RepoQuery) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -696,7 +696,7 @@ func (m *RepoResponse) Reset() { *m = RepoResponse{} }
func (m *RepoResponse) String() string { return proto.CompactTextString(m) }
func (*RepoResponse) ProtoMessage() {}
func (*RepoResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{11}
return fileDescriptor_repository_324bad698d34f88e, []int{11}
}
func (m *RepoResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -737,7 +737,7 @@ func (m *RepoCreateRequest) Reset() { *m = RepoCreateRequest{} }
func (m *RepoCreateRequest) String() string { return proto.CompactTextString(m) }
func (*RepoCreateRequest) ProtoMessage() {}
func (*RepoCreateRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{12}
return fileDescriptor_repository_324bad698d34f88e, []int{12}
}
func (m *RepoCreateRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -791,7 +791,7 @@ func (m *RepoUpdateRequest) Reset() { *m = RepoUpdateRequest{} }
func (m *RepoUpdateRequest) String() string { return proto.CompactTextString(m) }
func (*RepoUpdateRequest) ProtoMessage() {}
func (*RepoUpdateRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_repository_3c54adc3c349824a, []int{13}
return fileDescriptor_repository_324bad698d34f88e, []int{13}
}
func (m *RepoUpdateRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -3675,10 +3675,10 @@ var (
)
func init() {
proto.RegisterFile("server/repository/repository.proto", fileDescriptor_repository_3c54adc3c349824a)
proto.RegisterFile("server/repository/repository.proto", fileDescriptor_repository_324bad698d34f88e)
}
var fileDescriptor_repository_3c54adc3c349824a = []byte{
var fileDescriptor_repository_324bad698d34f88e = []byte{
// 893 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x5f, 0x6f, 0x1b, 0x45,
0x10, 0xd7, 0x25, 0xa9, 0x1b, 0x8f, 0xdb, 0x2a, 0xdd, 0x96, 0x60, 0x0e, 0xc7, 0x8d, 0x16, 0x09,

View file

@ -47,7 +47,7 @@ func (m *SessionCreateRequest) Reset() { *m = SessionCreateRequest{} }
func (m *SessionCreateRequest) String() string { return proto.CompactTextString(m) }
func (*SessionCreateRequest) ProtoMessage() {}
func (*SessionCreateRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_session_217b926c109d1cc2, []int{0}
return fileDescriptor_session_8e535ce77fc5e082, []int{0}
}
func (m *SessionCreateRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -108,7 +108,7 @@ func (m *SessionDeleteRequest) Reset() { *m = SessionDeleteRequest{} }
func (m *SessionDeleteRequest) String() string { return proto.CompactTextString(m) }
func (*SessionDeleteRequest) ProtoMessage() {}
func (*SessionDeleteRequest) Descriptor() ([]byte, []int) {
return fileDescriptor_session_217b926c109d1cc2, []int{1}
return fileDescriptor_session_8e535ce77fc5e082, []int{1}
}
func (m *SessionDeleteRequest) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -149,7 +149,7 @@ func (m *SessionResponse) Reset() { *m = SessionResponse{} }
func (m *SessionResponse) String() string { return proto.CompactTextString(m) }
func (*SessionResponse) ProtoMessage() {}
func (*SessionResponse) Descriptor() ([]byte, []int) {
return fileDescriptor_session_217b926c109d1cc2, []int{2}
return fileDescriptor_session_8e535ce77fc5e082, []int{2}
}
func (m *SessionResponse) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -827,10 +827,10 @@ var (
)
func init() {
proto.RegisterFile("server/session/session.proto", fileDescriptor_session_217b926c109d1cc2)
proto.RegisterFile("server/session/session.proto", fileDescriptor_session_8e535ce77fc5e082)
}
var fileDescriptor_session_217b926c109d1cc2 = []byte{
var fileDescriptor_session_8e535ce77fc5e082 = []byte{
// 356 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0xb1, 0x4e, 0xeb, 0x30,
0x14, 0x86, 0xe5, 0x5e, 0xdd, 0xde, 0x7b, 0x3d, 0xdc, 0x8a, 0x28, 0x82, 0x28, 0x2a, 0x15, 0xca,

View file

@ -42,7 +42,7 @@ func (m *SettingsQuery) Reset() { *m = SettingsQuery{} }
func (m *SettingsQuery) String() string { return proto.CompactTextString(m) }
func (*SettingsQuery) ProtoMessage() {}
func (*SettingsQuery) Descriptor() ([]byte, []int) {
return fileDescriptor_settings_90d4947f5a5e2583, []int{0}
return fileDescriptor_settings_902e174a76eb35c2, []int{0}
}
func (m *SettingsQuery) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -84,7 +84,7 @@ func (m *Settings) Reset() { *m = Settings{} }
func (m *Settings) String() string { return proto.CompactTextString(m) }
func (*Settings) ProtoMessage() {}
func (*Settings) Descriptor() ([]byte, []int) {
return fileDescriptor_settings_90d4947f5a5e2583, []int{1}
return fileDescriptor_settings_902e174a76eb35c2, []int{1}
}
func (m *Settings) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -145,7 +145,7 @@ func (m *DexConfig) Reset() { *m = DexConfig{} }
func (m *DexConfig) String() string { return proto.CompactTextString(m) }
func (*DexConfig) ProtoMessage() {}
func (*DexConfig) Descriptor() ([]byte, []int) {
return fileDescriptor_settings_90d4947f5a5e2583, []int{2}
return fileDescriptor_settings_902e174a76eb35c2, []int{2}
}
func (m *DexConfig) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -193,7 +193,7 @@ func (m *Connector) Reset() { *m = Connector{} }
func (m *Connector) String() string { return proto.CompactTextString(m) }
func (*Connector) ProtoMessage() {}
func (*Connector) Descriptor() ([]byte, []int) {
return fileDescriptor_settings_90d4947f5a5e2583, []int{3}
return fileDescriptor_settings_902e174a76eb35c2, []int{3}
}
func (m *Connector) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -249,7 +249,7 @@ func (m *OIDCConfig) Reset() { *m = OIDCConfig{} }
func (m *OIDCConfig) String() string { return proto.CompactTextString(m) }
func (*OIDCConfig) ProtoMessage() {}
func (*OIDCConfig) Descriptor() ([]byte, []int) {
return fileDescriptor_settings_90d4947f5a5e2583, []int{4}
return fileDescriptor_settings_902e174a76eb35c2, []int{4}
}
func (m *OIDCConfig) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1291,10 +1291,10 @@ var (
)
func init() {
proto.RegisterFile("server/settings/settings.proto", fileDescriptor_settings_90d4947f5a5e2583)
proto.RegisterFile("server/settings/settings.proto", fileDescriptor_settings_902e174a76eb35c2)
}
var fileDescriptor_settings_90d4947f5a5e2583 = []byte{
var fileDescriptor_settings_902e174a76eb35c2 = []byte{
// 397 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x52, 0xcd, 0x8a, 0xdb, 0x30,
0x18, 0x44, 0x71, 0x49, 0xe2, 0xaf, 0x3f, 0x69, 0xd5, 0x12, 0xdc, 0x50, 0x9c, 0xe0, 0x53, 0xa0,

View file

@ -2209,11 +2209,16 @@
},
"environment": {
"type": "string",
"title": "Environment is a ksonnet application environment name"
"title": "Environment is a ksonnet application environment name\nDEPRECATED: specify environment in ksonnet.environment instead"
},
"namePrefix": {
"type": "string",
"title": "NamePrefix is a prefix appended to resources for helm and kustomize apps"
"helm": {
"$ref": "#/definitions/v1alpha1ApplicationSourceHelm"
},
"ksonnet": {
"$ref": "#/definitions/v1alpha1ApplicationSourceKsonnet"
},
"kustomize": {
"$ref": "#/definitions/v1alpha1ApplicationSourceKustomize"
},
"path": {
"type": "string",
@ -2229,13 +2234,50 @@
},
"valuesFiles": {
"type": "array",
"title": "ValuesFiles is a list of Helm values files to use when generating a template",
"title": "ValuesFiles is a list of Helm values files to use when generating a template\nDEPRECATED: specify values in helm.valueFiles instead",
"items": {
"type": "string"
}
}
}
},
"v1alpha1ApplicationSourceHelm": {
"type": "object",
"title": "ApplicationSourceHelm holds helm specific options",
"properties": {
"releaseName": {
"type": "string",
"title": "The Helm release name. If omitted will use the application name"
},
"valueFiles": {
"type": "array",
"title": "ValuesFiles is a list of Helm value files to use when generating a template",
"items": {
"type": "string"
}
}
}
},
"v1alpha1ApplicationSourceKsonnet": {
"type": "object",
"title": "ApplicationSourceKsonnet holds ksonnet specific options",
"properties": {
"environment": {
"type": "string",
"title": "Environment is a ksonnet application environment name"
}
}
},
"v1alpha1ApplicationSourceKustomize": {
"type": "object",
"title": "ApplicationSourceKustomize holds kustomize specific options",
"properties": {
"namePrefix": {
"type": "string",
"title": "NamePrefix is a prefix appended to resources for kustomize apps"
}
}
},
"v1alpha1ApplicationSpec": {
"description": "ApplicationSpec represents desired application state. Contains link to repository with application definition and additional parameters link definition revision.",
"type": "object",

View file

@ -51,7 +51,7 @@ func (m *VersionMessage) Reset() { *m = VersionMessage{} }
func (m *VersionMessage) String() string { return proto.CompactTextString(m) }
func (*VersionMessage) ProtoMessage() {}
func (*VersionMessage) Descriptor() ([]byte, []int) {
return fileDescriptor_version_301443c925f6e1d7, []int{0}
return fileDescriptor_version_9a67e1897074bbcc, []int{0}
}
func (m *VersionMessage) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -781,10 +781,10 @@ var (
)
func init() {
proto.RegisterFile("server/version/version.proto", fileDescriptor_version_301443c925f6e1d7)
proto.RegisterFile("server/version/version.proto", fileDescriptor_version_9a67e1897074bbcc)
}
var fileDescriptor_version_301443c925f6e1d7 = []byte{
var fileDescriptor_version_9a67e1897074bbcc = []byte{
// 343 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x92, 0xcf, 0x4a, 0xc3, 0x40,
0x10, 0xc6, 0x49, 0xd5, 0xfe, 0x59, 0x4a, 0x0f, 0x8b, 0xd4, 0x25, 0x96, 0x22, 0x3d, 0x88, 0x08,

View file

@ -71,7 +71,7 @@ func TestAppManagement(t *testing.T) {
}
assert.Equal(t, appName, app.Name)
assert.Equal(t, "https://github.com/argoproj/argo-cd.git", app.Spec.Source.RepoURL)
assert.Equal(t, "minikube", app.Spec.Source.Environment)
assert.Equal(t, "minikube", v1alpha1.KsonnetEnv(&app.Spec.Source))
assert.Equal(t, ".", app.Spec.Source.Path)
assert.Equal(t, fixture.Namespace, app.Spec.Destination.Namespace)
assert.Equal(t, fixture.Config.Host, app.Spec.Destination.Server)

View file

@ -10,14 +10,13 @@ import (
"strings"
"time"
"k8s.io/apimachinery/pkg/runtime/schema"
log "github.com/sirupsen/logrus"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
apierr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/watch"
@ -181,23 +180,34 @@ func WaitForRefresh(appIf v1alpha1.ApplicationInterface, name string, timeout *t
// GetSpecErrors returns list of conditions which indicates that app spec is invalid. Following is checked:
// * the git repository is accessible
// * the git path contains a valid app.yaml
// * the specified environment exists
// * the git path contains valid manifests
// * the referenced cluster has been added to Argo CD
// * the app source repo and destination namespace/cluster are permitted in app project
// * there are parameters of only one app source type
// * ksonnet: the specified environment exists
func GetSpecErrors(
ctx context.Context, spec *argoappv1.ApplicationSpec, proj *argoappv1.AppProject, repoClientset reposerver.Clientset, db db.ArgoDB) ([]argoappv1.ApplicationCondition, error) {
ctx context.Context,
spec *argoappv1.ApplicationSpec,
proj *argoappv1.AppProject,
repoClientset reposerver.Clientset,
db db.ArgoDB,
) ([]argoappv1.ApplicationCondition, error) {
conditions := make([]argoappv1.ApplicationCondition, 0)
if spec.Source.RepoURL == "" || spec.Source.Path == "" {
conditions = append(conditions, argoappv1.ApplicationCondition{
Type: argoappv1.ApplicationConditionInvalidSpecError,
Message: "spec.source.repoURL and spec.source.path are required",
})
return conditions, nil
}
// Test the repo
conn, repoClient, err := repoClientset.NewRepositoryClient()
if err != nil {
return nil, err
}
repoAccessable := false
defer util.Close(conn)
repoAccessable := false
repoRes, err := db.GetRepository(ctx, spec.Source.RepoURL)
if err != nil {
if errStatus, ok := status.FromError(err); ok && errStatus.Code() == codes.NotFound {
@ -220,6 +230,11 @@ func GetSpecErrors(
repoAccessable = true
}
// Verify only one source type is defined
if multiSourceErr := verifyOneSourceType(&spec.Source); multiSourceErr != nil {
conditions = append(conditions, *multiSourceErr)
}
if repoAccessable {
appSourceType, err := queryAppSourceType(ctx, spec, repoRes, repoClient)
if err != nil {
@ -229,27 +244,25 @@ func GetSpecErrors(
})
} else {
switch appSourceType {
case repository.AppSourceKsonnet:
case argoappv1.ApplicationSourceTypeKsonnet:
err := verifyAppYAML(ctx, repoRes, spec, repoClient)
if err != nil {
conditions = append(conditions, argoappv1.ApplicationCondition{
Type: argoappv1.ApplicationConditionInvalidSpecError,
Message: err.Error(),
})
}
case repository.AppSourceHelm:
case argoappv1.ApplicationSourceTypeHelm:
helmConditions := verifyHelmChart(ctx, repoRes, spec, repoClient)
if len(helmConditions) > 0 {
conditions = append(conditions, helmConditions...)
}
case repository.AppSourceDirectory, repository.AppSourceKustomize:
case argoappv1.ApplicationSourceTypeDirectory, argoappv1.ApplicationSourceTypeKustomize:
maniDirConditions := verifyGenerateManifests(ctx, repoRes, spec, repoClient)
if len(maniDirConditions) > 0 {
conditions = append(conditions, maniDirConditions...)
}
}
}
}
@ -287,6 +300,26 @@ func GetSpecErrors(
return conditions, nil
}
func verifyOneSourceType(source *argoappv1.ApplicationSource) *argoappv1.ApplicationCondition {
var appTypes []string
if source.Kustomize != nil {
appTypes = append(appTypes, string(argoappv1.ApplicationSourceTypeKustomize))
}
if source.Helm != nil {
appTypes = append(appTypes, string(argoappv1.ApplicationSourceTypeHelm))
}
if source.Ksonnet != nil {
appTypes = append(appTypes, string(argoappv1.ApplicationSourceTypeKsonnet))
}
if len(appTypes) > 1 {
return &argoappv1.ApplicationCondition{
Type: argoappv1.ApplicationConditionInvalidSpecError,
Message: fmt.Sprintf("multiple application sources defined: %s", strings.Join(appTypes, ",")),
}
}
return nil
}
// GetAppProject returns a project from an application
func GetAppProject(spec *argoappv1.ApplicationSpec, appclientset appclientset.Interface, ns string) (*argoappv1.AppProject, error) {
if spec.BelongsToDefaultProject() {
@ -297,7 +330,7 @@ func GetAppProject(spec *argoappv1.ApplicationSpec, appclientset appclientset.In
// queryAppSourceType queries repo server for yaml files in a directory, and determines its
// application source type based on the files in the directory.
func queryAppSourceType(ctx context.Context, spec *argoappv1.ApplicationSpec, repoRes *argoappv1.Repository, repoClient repository.RepositoryServiceClient) (repository.AppSourceType, error) {
func queryAppSourceType(ctx context.Context, spec *argoappv1.ApplicationSpec, repoRes *argoappv1.Repository, repoClient repository.RepositoryServiceClient) (argoappv1.ApplicationSourceType, error) {
req := repository.ListDirRequest{
Repo: &argoappv1.Repository{
Repo: spec.Source.RepoURL,
@ -319,16 +352,16 @@ func queryAppSourceType(ctx context.Context, spec *argoappv1.ApplicationSpec, re
trimmedPath := strings.TrimPrefix(gitPath, filepath.Clean(spec.Source.Path))
trimmedPath = strings.TrimPrefix(trimmedPath, "/")
if trimmedPath == "app.yaml" {
return repository.AppSourceKsonnet, nil
return argoappv1.ApplicationSourceTypeKsonnet, nil
}
if trimmedPath == "Chart.yaml" {
return repository.AppSourceHelm, nil
return argoappv1.ApplicationSourceTypeHelm, nil
}
if trimmedPath == "kustomization.yaml" {
return repository.AppSourceKustomize, nil
return argoappv1.ApplicationSourceTypeKustomize, nil
}
}
return repository.AppSourceDirectory, nil
return argoappv1.ApplicationSourceTypeDirectory, nil
}
// verifyAppYAML verifies that a ksonnet app.yaml is functional
@ -356,7 +389,7 @@ func verifyAppYAML(ctx context.Context, repoRes *argoappv1.Repository, spec *arg
}
// Verify the specified environment is defined in the app spec
dest, err := ksonnet.Destination(getRes.Data, spec.Source.Environment)
dest, err := ksonnet.Destination(getRes.Data, argoappv1.KsonnetEnv(&spec.Source))
if err != nil {
return err
}
@ -416,9 +449,9 @@ func verifyGenerateManifests(ctx context.Context, repoRes *argoappv1.Repository,
Repo: &argoappv1.Repository{
Repo: spec.Source.RepoURL,
},
Revision: spec.Source.TargetRevision,
Path: spec.Source.Path,
Namespace: spec.Destination.Namespace,
Revision: spec.Source.TargetRevision,
Namespace: spec.Destination.Namespace,
ApplicationSource: &spec.Source,
}
if repoRes != nil {
req.Repo.Username = repoRes.Username

View file

@ -118,3 +118,24 @@ func TestContainsSyncResource(t *testing.T) {
}
}
}
func TestVerifyOneSourceType(t *testing.T) {
src := argoappv1.ApplicationSource{
Ksonnet: &argoappv1.ApplicationSourceKsonnet{
Environment: "foo",
},
Kustomize: &argoappv1.ApplicationSourceKustomize{
NamePrefix: "foo",
},
Helm: &argoappv1.ApplicationSourceHelm{
ReleaseName: "foo",
},
}
assert.NotNil(t, verifyOneSourceType(&src))
src = argoappv1.ApplicationSource{
Helm: &argoappv1.ApplicationSourceHelm{
ReleaseName: "foo",
},
}
assert.Nil(t, verifyOneSourceType(&src))
}

12
util/hash/hash.go Normal file
View file

@ -0,0 +1,12 @@
package hash
import (
"hash/fnv"
)
// FNVa computes a FNVa hash on a string
func FNVa(s string) uint32 {
h := fnv.New32a()
_, _ = h.Write([]byte(s))
return h.Sum32()
}

View file

@ -20,7 +20,7 @@ import (
// Helm provides wrapper functionality around the `helm` command.
type Helm interface {
// Template returns a list of unstructured objects from a `helm template` command
Template(name, namespace string, valuesFiles []string, overrides []*argoappv1.ComponentParameter) ([]*unstructured.Unstructured, error)
Template(appName string, opts HelmTemplateOpts, overrides []*argoappv1.ComponentParameter) ([]*unstructured.Unstructured, error)
// GetParameters returns a list of chart parameters taking into account values in provided YAML files.
GetParameters(valuesFiles []string) ([]*argoappv1.ComponentParameter, error)
// DependencyBuild runs `helm dependency build` to download a chart's dependencies
@ -31,6 +31,16 @@ type Helm interface {
Init() error
}
// HelmTemplateOpts are various options to send to a `helm template` command
type HelmTemplateOpts struct {
// Values is list of multiple --values flag
ValueFiles []string
// Namespace maps to the --namespace flag
Namespace string
// ReleaseName maps to the --name flag
ReleaseName string
}
// NewHelmApp create a new wrapper to run commands on the `helm` command-line tool.
func NewHelmApp(path string) Helm {
return &helm{path: path}
@ -41,14 +51,19 @@ type helm struct {
home string
}
func (h *helm) Template(name, namespace string, valuesFiles []string, overrides []*argoappv1.ComponentParameter) ([]*unstructured.Unstructured, error) {
func (h *helm) Template(appName string, opts HelmTemplateOpts, overrides []*argoappv1.ComponentParameter) ([]*unstructured.Unstructured, error) {
args := []string{
"template", ".", "--name", name,
"template", ".",
}
if namespace != "" {
args = append(args, "--namespace", namespace)
if opts.ReleaseName != "" {
args = append(args, "--name", appName)
} else {
args = append(args, "--name", appName)
}
for _, valuesFile := range valuesFiles {
if opts.Namespace != "" {
args = append(args, "--namespace", opts.Namespace)
}
for _, valuesFile := range opts.ValueFiles {
args = append(args, "-f", valuesFile)
}
for _, p := range overrides {

View file

@ -34,7 +34,7 @@ func TestHelmTemplateParams(t *testing.T) {
Value: "1234",
},
}
objs, err := h.Template("test", "", nil, overrides)
objs, err := h.Template("test", HelmTemplateOpts{}, overrides)
assert.Nil(t, err)
assert.Equal(t, 5, len(objs))
@ -52,7 +52,7 @@ func TestHelmTemplateParams(t *testing.T) {
func TestHelmTemplateValues(t *testing.T) {
h := NewHelmApp("./testdata/redis")
valuesFiles := []string{"values-production.yaml"}
objs, err := h.Template("test", "", valuesFiles, nil)
objs, err := h.Template("test", HelmTemplateOpts{ValueFiles: valuesFiles}, nil)
assert.Nil(t, err)
assert.Equal(t, 8, len(objs))
@ -69,7 +69,7 @@ func TestHelmTemplateValues(t *testing.T) {
func TestHelmTemplateValuesURL(t *testing.T) {
h := NewHelmApp("./testdata/redis")
valuesFiles := []string{"https://raw.githubusercontent.com/argoproj/argo-cd/master/util/helm/testdata/redis/values-production.yaml"}
objs, err := h.Template("test", "", valuesFiles, nil)
objs, err := h.Template("test", HelmTemplateOpts{ValueFiles: valuesFiles}, nil)
assert.Nil(t, err)
assert.Equal(t, 8, len(objs))
params, err := h.GetParameters(valuesFiles)
@ -110,10 +110,10 @@ func TestHelmDependencyBuild(t *testing.T) {
h.SetHome(helmHome)
err = h.Init()
assert.NoError(t, err)
_, err = h.Template("wordpress", "", nil, nil)
_, err = h.Template("wordpress", HelmTemplateOpts{}, nil)
assert.Error(t, err)
err = h.DependencyBuild()
assert.NoError(t, err)
_, err = h.Template("wordpress", "", nil, nil)
_, err = h.Template("wordpress", HelmTemplateOpts{}, nil)
assert.NoError(t, err)
}

View file

@ -14,7 +14,7 @@ import (
// Kustomize provides wrapper functionality around the `kustomize` command.
type Kustomize interface {
// Build returns a list of unstructured objects from a `kustomize build` command and extract supported parameters
Build(namespace string, namePrefix string, overrides []*v1alpha1.ComponentParameter) ([]*unstructured.Unstructured, []*v1alpha1.ComponentParameter, error)
Build(opts KustomizeBuildOpts, overrides []*v1alpha1.ComponentParameter) ([]*unstructured.Unstructured, []*v1alpha1.ComponentParameter, error)
}
// NewKustomizeApp create a new wrapper to run commands on the `kustomize` command-line tool.
@ -26,9 +26,17 @@ type kustomize struct {
path string
}
func (k *kustomize) Build(namespace string, namePrefix string, overrides []*v1alpha1.ComponentParameter) ([]*unstructured.Unstructured, []*v1alpha1.ComponentParameter, error) {
if namespace != "" {
cmd := exec.Command("kustomize", "edit", "set", "namespace", namespace)
// KustomizeBuildOpts are options to a `kustomize build` command
type KustomizeBuildOpts struct {
// Namespace will run `kustomize edit set namespace` during manifest generation
Namespace string
// NamePrefix will run `kustomize edit set nameprefix` during manifest generation
NamePrefix string
}
func (k *kustomize) Build(opts KustomizeBuildOpts, overrides []*v1alpha1.ComponentParameter) ([]*unstructured.Unstructured, []*v1alpha1.ComponentParameter, error) {
if opts.Namespace != "" {
cmd := exec.Command("kustomize", "edit", "set", "namespace", opts.Namespace)
cmd.Dir = k.path
_, err := argoexec.RunCommandExt(cmd)
if err != nil {
@ -36,8 +44,8 @@ func (k *kustomize) Build(namespace string, namePrefix string, overrides []*v1al
}
}
if namePrefix != "" {
cmd := exec.Command("kustomize", "edit", "set", "nameprefix", namePrefix)
if opts.NamePrefix != "" {
cmd := exec.Command("kustomize", "edit", "set", "nameprefix", opts.NamePrefix)
cmd.Dir = k.path
_, err := argoexec.RunCommandExt(cmd)
if err != nil {

View file

@ -5,10 +5,10 @@ import (
"path"
"testing"
"github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
"github.com/argoproj/pkg/exec"
"github.com/stretchr/testify/assert"
"github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1"
"github.com/argoproj/pkg/exec"
)
func testDataDir() (string, error) {
@ -28,7 +28,11 @@ func TestKustomizeBuild(t *testing.T) {
assert.Nil(t, err)
namePrefix := "namePrefix-"
kustomize := NewKustomizeApp(appPath)
objs, params, err := kustomize.Build("mynamespace", namePrefix, []*v1alpha1.ComponentParameter{{
opts := KustomizeBuildOpts{
Namespace: "mynamespace",
NamePrefix: namePrefix,
}
objs, params, err := kustomize.Build(opts, []*v1alpha1.ComponentParameter{{
Component: "imagetag",
Name: "k8s.gcr.io/nginx-slim",
Value: "latest",