Use go module as dependency tool instead of glide
[src/xds/xds-server.git] / lib / xdsserver / folder-st-disable.go
1 /*
2  * Copyright (C) 2017-2018 "IoT.bzh"
3  * Author Sebastien Douheret <sebastien@iot.bzh>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *   http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 package xdsserver
19
20 import (
21         "gerrit.automotivelinux.org/gerrit/src/xds/xds-server.git/lib/xsapiv1"
22         uuid "github.com/satori/go.uuid"
23 )
24
25 // IFOLDER interface implementation for disabled Syncthing folders
26 // It's a "fallback" interface used to keep syncthing folders config even
27 // when syncthing is not running.
28
29 // STFolderDisable .
30 type STFolderDisable struct {
31         *Context
32         fConfig xsapiv1.FolderConfig
33 }
34
35 // NewFolderSTDisable Create a new instance of STFolderDisable
36 func NewFolderSTDisable(ctx *Context) *STFolderDisable {
37         f := STFolderDisable{
38                 Context: ctx,
39         }
40         return &f
41 }
42
43 // NewUID Get a UUID
44 func (f *STFolderDisable) NewUID(suffix string) string {
45         uuid := uuid.NewV1().String()
46         if len(suffix) > 0 {
47                 uuid += "_" + suffix
48         }
49         return uuid
50 }
51
52 // Add a new folder
53 func (f *STFolderDisable) Add(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
54         return f.Setup(cfg)
55 }
56
57 // Setup Setup local project config
58 func (f *STFolderDisable) Setup(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
59         f.fConfig = cfg
60         f.fConfig.Status = xsapiv1.StatusDisable
61         f.fConfig.IsInSync = false
62         return &f.fConfig, nil
63 }
64
65 // GetConfig Get public part of folder config
66 func (f *STFolderDisable) GetConfig() xsapiv1.FolderConfig {
67         return f.fConfig
68 }
69
70 // GetFullPath returns the full path of a directory (from server POV)
71 func (f *STFolderDisable) GetFullPath(dir string) string {
72         return ""
73 }
74
75 // ConvPathCli2Svr Convert path from Client to Server
76 func (f *STFolderDisable) ConvPathCli2Svr(s string) string {
77         return ""
78 }
79
80 // ConvPathSvr2Cli Convert path from Server to Client
81 func (f *STFolderDisable) ConvPathSvr2Cli(s string) string {
82         return ""
83 }
84
85 // Remove a folder
86 func (f *STFolderDisable) Remove() error {
87         return nil
88 }
89
90 // Update update some fields of a folder
91 func (f *STFolderDisable) Update(cfg xsapiv1.FolderConfig) (*xsapiv1.FolderConfig, error) {
92         return nil, nil
93 }
94
95 // Sync Force folder files synchronization
96 func (f *STFolderDisable) Sync() error {
97         return nil
98 }
99
100 // IsInSync Check if folder files are in-sync
101 func (f *STFolderDisable) IsInSync() (bool, error) {
102         return false, nil
103 }