servicecentral

package
v0.0.0-...-e0434a4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2019 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PagerDutyMetadataKey is the key we use to store the Metadata in the Misc field
	PagerDutyMetadataKey = "pagerduty"

	// BambooMetadataKey is the key we use to store a list of allowed builds
	BambooMetadataKey = "bamboo"
)

Variables

This section is empty.

Functions

func GetBambooMetadata

func GetBambooMetadata(serviceCentralData *ServiceDataWrite) (*creator_v1.BambooMetadata, error)

GetBambooMetadata reads the allowed builds metadata out of a service

func GetMiscData

func GetMiscData(data *ServiceDataWrite, key string) (string, error)

func GetPagerDutyMetadata

func GetPagerDutyMetadata(serviceCentralData *ServiceDataWrite) (*creator_v1.PagerDutyMetadata, error)

GetPagerDutyMetadata reads the pagerduty metadata out of a service

func IsNotFound

func IsNotFound(err error) bool

func NewNotFound

func NewNotFound(format string, v ...interface{}) error

func SetBambooMetadata

func SetBambooMetadata(serviceCentralData *ServiceDataWrite, m *creator_v1.BambooMetadata) error

SetBambooMetadata stores the metadata for allowed builds into a Service's metadata

func SetMiscData

func SetMiscData(data *ServiceDataWrite, key string, value string) error

func SetPagerDutyMetadata

func SetPagerDutyMetadata(serviceCentralData *ServiceDataWrite, m *creator_v1.PagerDutyMetadata) error

SetPagerDutyMetadata stores the metadata for pagerduty into a Service's metadata

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a minimalistic Service Central client for our needs See the outdated API spec there https://stash.atlassian.com/projects/MICROS/repos/service-central/browse/docs/api.raml Or the actual API code (Python) there https://stash.atlassian.com/projects/MICROS/repos/service-central/browse/service_central/api.py

func NewServiceCentralClient

func NewServiceCentralClient(logger *zap.Logger, httpClient *http.Client, asap pkiutil.ASAP, baseURL *url.URL) *Client

func (*Client) CreateService

func (c *Client) CreateService(ctx context.Context, user auth.User, data *ServiceDataWrite) (*ServiceDataRead, error)

Create a new service. A new UUID will be allocated to this service return codes: - 201: Service created - 400: Bad request - 409: The service UUID or service name already exists - 500: Internal server error

func (*Client) DeleteService

func (c *Client) DeleteService(ctx context.Context, user auth.User, serviceUUID string) error

func (*Client) GetService

func (c *Client) GetService(ctx context.Context, user auth.OptionalUser, serviceUUID string) (*ServiceDataRead, error)

func (*Client) GetServiceAttributes

func (c *Client) GetServiceAttributes(ctx context.Context, user auth.OptionalUser, serviceUUID string) ([]ServiceAttributeResponse, error)

GetServiceAttributes queries service central for the attributes of a given service. Can return an empty array if no attributes were found

func (*Client) ListModifiedServices

func (c *Client) ListModifiedServices(ctx context.Context, user auth.OptionalUser, modifiedSince time.Time) ([]ServiceDataRead, error)

List recently modified services

func (*Client) ListServices

func (c *Client) ListServices(ctx context.Context, user auth.OptionalUser, search string) ([]ServiceDataRead, error)

Search for service - search: Search filter string, see format doc https://extranet.atlassian.com/display/MICROS/Service+Central+-+Search+Language - detail: Should the search query all subtables - limit: Limit the number of records returned - offset: Start returning items for a particular offset return codes: - 200: OK - 400: Bad request

func (*Client) PatchService

func (c *Client) PatchService(ctx context.Context, user auth.User, data *ServiceDataWrite) error

Patch an existing service with the attached specification return codes: - 200: The service was successfully updated

type Error

type Error struct {
	// contains filtered or unexported fields
}

func (*Error) Error

func (e *Error) Error() string

type ServiceAttribute

type ServiceAttribute struct {
	Team string `json:"team,omitempty"`
}

type ServiceAttributeResponse

type ServiceAttributeResponse struct {
	ID         int                     `json:"id"`
	Service    ServiceAttributeService `json:"service"`
	Schema     ServiceAttributeSchema  `json:"schema"`
	Value      map[string]string       `json:"value"`
	CreatedOn  time.Time               `json:"createdOn"`
	CreatedBy  string                  `json:"createdBy"`
	ModifiedOn time.Time               `json:"modifiedOn"`
	ModifiedBy string                  `json:"modifiedBy"`
}

type ServiceAttributeSchema

type ServiceAttributeSchema struct {
	Ref  string `json:"ref"`
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type ServiceAttributeService

type ServiceAttributeService struct {
	Ref  string `json:"ref"`
	UUID string `json:"uuid"`
	Name string `json:"name"`
}

type ServiceComplianceConf

type ServiceComplianceConf struct {
	// using prgb_control instead of prgbControl here to match the response field name
	PRGBControl *bool `json:"prgb_control,omitempty"`
}

ServiceComplianceConf includes all service compliance related data

type ServiceDataRead

type ServiceDataRead struct {
	ServiceDataWrite
	CreationTimestamp *string `json:"creation_timestamp,omitempty"`
	// ServiceOwner is a read only field
	// see: VYGR-425
	ServiceOwner ServiceOwner `json:"service_owner,omitempty"`

	Attributes []ServiceAttribute `json:"service_attributes,omitempty"`

	// Compliance is a read-only field. It can be nil, in which case it means
	// they have not completed their compliance questions yet
	Compliance *ServiceComplianceConf `json:"compliance,omitempty"`
}

type ServiceDataWrite

type ServiceDataWrite struct {
	ServiceUUID        *string     `json:"service_uuid,omitempty"`
	ServiceName        ServiceName `json:"service_name,omitempty"`
	ServiceTier        int         `json:"service_tier,omitempty"`
	Tags               []string    `json:"tags,omitempty"`
	Platform           string      `json:"platform,omitempty"`
	Misc               []miscData  `json:"misc,omitempty"`
	PagerDutyServiceID string      `json:"pagerduty_service_id,omitempty"`
	LoggingID          string      `json:"logging_id,omitempty"`
	SSAMContainerName  string      `json:"ssam_container_name,omitempty"`

	ZeroDowntimeUpgrades bool   `json:"zero_downtime_upgrades,omitempty"`
	Stateless            bool   `json:"stateless,omitempty"`
	BusinessUnit         string `json:"business_unit,omitempty"`
}

type ServiceName

type ServiceName string

ServiceName is the name of a Service. Not voyager.ServiceName because not all Services in Service Central are Voyager services. I.e. set of all voyager.ServiceName is a subset of all Service Central ServiceNames.

type ServiceOwner

type ServiceOwner struct {
	Username string `json:"username"`
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store allows storing and retrieving data from ServiceCentral

func NewStore

func NewStore(logger *zap.Logger, client serviceCentralClient) *Store

func (*Store) DeleteService

func (c *Store) DeleteService(ctx context.Context, user auth.User, name ServiceName) error

func (*Store) FindOrCreateService

func (c *Store) FindOrCreateService(ctx context.Context, user auth.User, service *creator_v1.Service) (*creator_v1.Service, error)

func (*Store) GetService

func (c *Store) GetService(ctx context.Context, user auth.OptionalUser, name ServiceName) (*creator_v1.Service, error)

GetService retrieves a service from ServiceCentral by name. It only searches for services of type micros2.

func (*Store) ListModifiedServices

func (c *Store) ListModifiedServices(ctx context.Context, user auth.OptionalUser, modifiedSince time.Time) ([]creator_v1.Service, error)

ListModifiedServices returns a list of services changed since a specific time NB: this will not return all fields, if you need additional data (e.g. compliance or other misc data) you will need to make a separate call to GetService for the full object

func (*Store) ListServices

func (c *Store) ListServices(ctx context.Context, user auth.OptionalUser) ([]creator_v1.Service, error)

func (*Store) PatchService

func (c *Store) PatchService(ctx context.Context, user auth.User, service *creator_v1.Service) error

type V2Service

type V2Service struct {

	// Unique identifier of a service
	// read only: true
	UUID string `json:"uuid" sql:"service_uuid,pk"`

	// Name of the services, must be unique
	Name string `json:"name" sql:"service_name,unique"`

	// Owner of the service, must be an a valid staff ID of a person
	// Owner is READ ONLY it cannot be set when talking to service central
	Owner string `json:"owner" sql:"service_owner"`

	// Name of the team who owns the service
	Team *string `json:"team" sql:"team"`

	// Name of the business unit which owns the service
	BusinessUnit *string `json:"businessUnit" sql:"business_unit"`

	// SSAM Container attached to this service
	SSAMContainerName *string `json:"ssamContainerName" sql:"ssam_container_name"`

	// Location of the service - not sure what this means... physical location?
	Location *string `json:"location" sql:"location"`

	// Name of the platform on which the service runs (micros, vm, etc)
	Platform *string `json:"platform" sql:"platform"`

	// Description of the service
	Description *string `json:"description" sql:"description"`

	// URL of the service - which doesn't make alot of sense if it is a multi region/environment service
	ServiceURL *string `json:"servingURL" sql:"serving_url"`

	// Name of the Hipchat / Stride room where you can reach the team that maintains the service
	HipChatRoomName *string `json:"hipchatRoomName" sql:"hipchat_room_name"`

	// Tier of the service, must be one of: 0, 1, 2, 3
	ServiceTier *int `json:"serviceTier" sql:"service_tier"`

	// Unique identifier in the logging platform
	LoggingID *string `json:"loggingID" sql:"logging_id"`

	// ID of compliance policy attached to this service
	CompliancePolicyID *int `json:"compliancePolicyID" sql:"compliance_policy_id"`

	// ID of the Pagerduty service attached to this service
	PagerDutyServiceID *string `json:"pagerdutyServiceID" sql:"pagerduty_service_id"`

	// Is this service public facing?
	PublicFacing *bool `json:"publicFacing" sql:"public_facing"`

	// Is this service provided by a third party?
	ThirdPartyProvided *bool `json:"thirdPartyProvided" sql:"third_party_provided"`

	// Is the service stateless?
	Stateless *bool `json:"stateless" sql:"stateless"`

	// Is the service guaranteeing zero downtime upgrades?
	ZeroDowntimeUpgrades *bool `json:"zeroDowntimeUpgrades" sql:"zero_downtime_upgrades"`

	// Timestamp for when the record was created
	// read only: true
	CreatedOn time.Time `json:"createdOn" sql:"creation_timestamp"`

	// Timestamp for when the record was last modified
	// read only: true
	ModifiedOn time.Time `json:"modifiedOn" sql:"last_modified_timestamp"`

	// User who last modified the record
	// read only: true
	ModifiedBy string `json:"modifiedBy" sql:"last_modified_user"`
	// contains filtered or unexported fields
}

Copied from https://stash.atlassian.com/projects/MICROS/repos/central/browse/pkg/central/model/service.go Do not modify!

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL