MCPcopy
hub / github.com/argoproj/argo-cd / CreateFromFile

Method CreateFromFile

test/e2e/fixture/app/actions.go:129–184  ·  view source on GitHub ↗
(handler func(app *v1alpha1.Application), flags ...string)

Source from the content-addressed store, hash-verified

127}
128
129func (a *Actions) CreateFromFile(handler func(app *v1alpha1.Application), flags ...string) *Actions {
130 a.context.T().Helper()
131 app := &v1alpha1.Application{
132 ObjectMeta: metav1.ObjectMeta{
133 Name: a.context.AppName(),
134 Namespace: a.context.AppNamespace(),
135 },
136 Spec: v1alpha1.ApplicationSpec{
137 Project: a.context.project,
138 Source: &v1alpha1.ApplicationSource{
139 RepoURL: fixture.RepoURL(a.context.repoURLType),
140 Path: a.context.path,
141 },
142 Destination: v1alpha1.ApplicationDestination{
143 Server: a.context.destServer,
144 Namespace: a.context.DeploymentNamespace(),
145 },
146 },
147 }
148 source := app.Spec.GetSource()
149 if a.context.namePrefix != "" || a.context.nameSuffix != "" {
150 source.Kustomize = &v1alpha1.ApplicationSourceKustomize{
151 NamePrefix: a.context.namePrefix,
152 NameSuffix: a.context.nameSuffix,
153 }
154 }
155 if a.context.configManagementPlugin != "" {
156 source.Plugin = &v1alpha1.ApplicationSourcePlugin{
157 Name: a.context.configManagementPlugin,
158 }
159 }
160
161 if len(a.context.parameters) > 0 {
162 log.Fatal("v1alpha1.Application parameters or json tlas are not supported")
163 }
164
165 if a.context.directoryRecurse {
166 source.Directory = &v1alpha1.ApplicationSourceDirectory{Recurse: true}
167 }
168 app.Spec.Source = &source
169
170 handler(app)
171 data := grpc.MustMarshal(app)
172 tmpFile, err := os.CreateTemp("", "")
173 require.NoError(a.context.T(), err)
174 _, err = tmpFile.Write(data)
175 require.NoError(a.context.T(), err)
176
177 args := append([]string{
178 "app", "create",
179 "-f", tmpFile.Name(),
180 }, flags...)
181 defer tmpFile.Close()
182 a.runCli(args...)
183 return a
184}
185
186func (a *Actions) CreateMultiSourceAppFromFile(flags ...string) *Actions {

Calls 11

runCliMethod · 0.95
RepoURLFunction · 0.92
MustMarshalFunction · 0.92
AppNamespaceMethod · 0.80
TMethod · 0.65
AppNameMethod · 0.65
DeploymentNamespaceMethod · 0.65
CloseMethod · 0.65
GetSourceMethod · 0.45
WriteMethod · 0.45
NameMethod · 0.45