grim/convey
Clone
Summary
Browse
Changes
Graph
Change all the copyright headers to not use /* */ comments and add some package comments
2018-01-12, Gary Kramlich
d4f80bb35ed0
Change all the copyright headers to not use /* */ comments and add some package comments
// Convey
// Copyright 2016-2018 Gary Kramlich <grim@reaperworld.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package
bitbucket
import
(
"github.com/go-yaml/yaml"
)
type
image
struct
{
Name
string
`yaml:"name"`
Username
string
`yaml:"username"`
Password
string
`yaml:"password"`
EMail
string
`yaml:"email"`
}
func
(
i
*
image
)
UnmarshalYAML
(
unmarshal
func
(
interface
{})
error
)
error
{
// first check if this is the basic format where it's just a name
name
:=
""
err
:=
unmarshal
(
&
name
)
if
err
==
nil
{
*
i
=
image
{
Name
:
name
,
}
return
nil
}
// if we got a yaml type error, try to unmarshal it as the struct
if
_
,
ok
:=
err
.(
*
yaml
.
TypeError
);
ok
{
type
rawImage
image
raw
:=
rawImage
{}
if
err
:=
unmarshal
(
&
raw
);
err
!=
nil
{
return
err
}
*
i
=
image
(
raw
)
return
nil
}
return
err
}
type
step
struct
{
Image
image
`yaml:"image"`
Script
[]
string
`yaml:"script"`
Services
[]
string
`yaml:"services"`
}
type
pipeline
struct
{
Steps
step
`yaml:"step"`
}
type
pipelines
struct
{
Bookmarks
map
[
string
][]
pipeline
`yaml:"bookmarks"`
Branches
map
[
string
][]
pipeline
`yaml:"branches"`
Custom
map
[
string
][]
pipeline
`yaml:"custom"`
Default
[]
pipeline
`yaml:"default"`
Tags
map
[
string
][]
pipeline
`yaml:"tags"`
}
type
service
struct
{
Image
image
`yaml:"image"`
Environment
[]
string
`yaml:"environment"`
Username
string
`yaml:"username"`
Password
string
`yaml:"password"`
}
type
definition
struct
{
Services
map
[
string
]
service
`yaml:"services"`
}
type
options
struct
{
Docker
bool
`yaml:"docker"`
}
type
bitbucketPipelines
struct
{
Image
image
`yaml:"image"`
Clone
clone
`yaml:"clone"`
Pipelines
pipelines
`yaml:"pipelines"`
Definitions
definition
`yaml:"definitions"`
Options
options
`yaml:"options"`
}
func
(
b
*
bitbucketPipelines
)
UnmarshalYAML
(
unmarshal
func
(
interface
{})
error
)
error
{
type
rawBitbucketPipelines
bitbucketPipelines
raw
:=
rawBitbucketPipelines
{
Clone
:
clone
{}}
if
err
:=
unmarshal
(
&
raw
);
err
!=
nil
{
return
err
}
*
b
=
bitbucketPipelines
(
raw
)
return
nil
}
type
clone
struct
{
Depth
int
`yaml:"depth"`
}
func
(
c
*
clone
)
UnmarshalYAML
(
unmarshal
func
(
interface
{})
error
)
error
{
type
rawClone
clone
raw
:=
rawClone
{
Depth
:
50
}
if
err
:=
unmarshal
(
&
raw
);
err
!=
nil
{
return
err
}
*
c
=
clone
(
raw
)
return
nil
}